Hacker News new | past | comments | ask | show | jobs | submit login

> Aggregation, composition, encapsulation are as are much as fundamental notions in OOP as inheritance.

You say that as if these things are not just as easily expressed in FP -- if not even easier.

Aggregation is just records-of-records.

Encapsulation is just "abstract data types", e.g. ML modules with abstract members, or non-exported data constructors in Haskell. Another option would be simply closing over whatever you're trying to hide. Another option would be existential types. (There's some overlap among all of these.)

Composition... well, actually I'm not sure what exactly you mean by "composition" in the context of OO. Can you explain what you mean?




Reminds me of PHP CEO's tweet: "If you had bad experiences with scrum you just did scrum wrong. If you had good experiences making software you just accidentally did scrum".


> ML modules with abstract members

So true! Sadly, most programmers' idea of an “abstract data type” is a class. :-p


Booyakasha! :)


> You say that as if these things are not just as easily expressed in FP

No, that's what you read. What i said what was i wrote... OOP is bigger than inheritance.

> -- if not even easier.

Again, this kind of statement really sound like empty FP propaganda to me.

> Encapsulation is just "abstract data types", e.g. ML modules with abstract members, or non-exported data constructors in Haskell. Another option would be simply closing over whatever you're trying to hide. Another option would be existential types. (There's some overlap among all of these.)

Or "abstract data types" is just Encapsulation...


> No, that's what you read.

I think you may have misunderstood my intent. I was just trying to say "FP can do these things too".

> Again, this kind of statement really sound like empty FP propaganda to me.

Right, so any type of even very modest support for X is "empty X propaganda". Can we please assume at least a modicum of good faith here?

> Or "abstract data types" is just Encapsulation...

Oh, so "semantics" it is then. Oh, well.

FWIW, I think I'm right in saying that ADTs were invented quite a bit before OOP & "Encapsulation".

I notice that you also didn't answer my question of what Composition actually means in OOP. Do you have an answer? I promise, I wasn't being facetious.


OOP is simply programming with objects. You can do that in a language of functions, you can also program with functions with a language of objects.


Define "objects", please.


That's easy, the word is well defined in the dictionary: a person or thing to which a specified action or feeling is directed. Some people try to call objects entities and claim they are doing something else, but they are just doing the same thing with different words.


Uh, how does that relate to the semantics of the language? (Formally, not dictionarily.)

EDIT: I was being a bit facetious, but we were discussing programming languages, so maybe not that much of a stretch...?




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

Search: