Hacker News new | ask | show | jobs
by shady-lady 3343 days ago
hmm, not so sure I agree to that extent.

[To me,]

FP is more about nobody owning the data. Everything operating on all the data. (Mostly) All data exposed and accessible.

OOP is about certain classes owning data and limiting exposure to that data.

1 comments

It has nothing to do with ownership. In FP, a function can only operate on data of a particular type. In OOP, a particular type (or class) gathers all the applicable functions (or methods) under one roof. Same difference.
Well, not really.. In effect, your class owns the relevant piece of data that it operates on and only allows pre-defined operations on that data.

Maybe my point is better articulated by saying [to me,] functional programming is more data oriented than OOP.

The word "own" is pretty meaningless. What does "own" even mean? Classes and objects (thought of as "types") are an organizing principle for organizing your functions. If you didn't organize them in this manner, then you'd have the same functions that operate on the same data types, only they're scattered everywhere, just like in functional programming.
> the same functions that operate on the same data types, only they're scattered everywhere

???

OO is different because you have things like private variables. Meaning that only methods of an object's class can access the variable. So you now have a special group of functions that can access the variable. FP is not like that.