Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The older I get the more I like having having separate data and functions.

Am I missing something or is this just OO but with func(obj) instead of obj.func()? Like the data is your instance but you have to track the types and remember what functions work on what. The coupling is just implicit now.



There is an old joke somewhere about some monk and a programmer who is looking for enlightenment and circling through OOP, realizing it has always been FP, which has always been actors, which has always been OOP..


yes but, when you think some more about that means a lot.

There is no such thing as inheritance, you route your data through different functions. There is no such thing as private data, its all public by default.

You can still have strict types I guess, to make sure you are passing the right kind of data into the right function. But most of my experience coding this way is js and lua.

I only code like this for my home projects, I have no idea what it would be like working in a team of 10 programmers all rushing to jam new features into a giant code base.


> There is no such thing as private data, its all public by default

Not in C, put the strict declaration in the h after and the definition in an implementation source file.

Callers of the implementation functions can pass the strict around without seeing any of the fields. Only functions in the implementation can access the fields which results in all acce to the fields going through the implementation only.

Cleaner and safer than letting the caller see everything while only accessing some things.


You don't have to use inheritance, but it's there when you need it.

Private data are also very useful.


Coupling is only implicit if you use a dynamically typed language.

Also, in languages with UFCS func(obj, something, else) can be expressed as obj.func(something, else). The calling syntax can thus remain the same even without defining the function within some arbitrary object.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: