top | item 46513152

(no title)

Supernaut | 1 month ago

Absolutely. Our thought leaders have been pushing functional programming for a long time now.

discuss

order

ruszki|1 month ago

Is it possible to have an OOP language which is also functional? Or is it impossible without imperative paradigms?

bigfishrunning|1 month ago

There's some muddiness in the terminology here -- OOP is really a design style, and "OOP languages" are generally imperative languages that have sematics that encourage OOP design. It is very possible, even encouraged, to represent state as "Objects" in many functional languages; it's just not really enforced by the language itself.

A good example of this are the object systems in Scheme and Common Lisp (which are less strictly Functional (note the capital F in that word) then something like Haskell).

smj-edison|1 month ago

Gilad Bracha talks about how they're not mutually exclusive concepts, and I mostly agree (OOP can have tailcall recursion and first order functions for example). But, the philosophy seems very different: functional programming is "standing above" the data, where you have visibility at all times, and do transformations on the data. OOP is much more about encapsulation, where you "send a message" to an object, and it does its own thing. So you could totally write OOP code where you provide some core data structures that you run operations on, but in practice encapsulation encourages hiding internal data.

Though on further thought, may be this isn't FP vs OOP, because C has a similar approach of "standing above", and C is the hallmark imperative language.

spopejoy|1 month ago

Smalltalk, the original OOP lang, is "both", at least if you're not one of those people who thinks FP c'est impossible if it's not ML or haskell

gf000|1 month ago

Scala has been that for decades. They are not opposing paradigms. (In fact, mutability has a few edge cases that doesn't play nicely with OOP to begin with)

rpcope1|1 month ago

I mean Scala kind of does both (and then some). I'm not sure I would call it an OOP language, but you can sure write the same gross Java enterprise bloatware in Scala too if you want.