3 ms·
"OOP is not the holy grail. It's a cute idea, and it was quite an improvement over procedural languages back in the 70's when it was invented. But it's honestly
by schemer4 14y ago
"OOP is not the holy grail. It's a cute idea, and it was quite an improvement over procedural languages back in the 70's when it was invented. But it's honestly not all it's cracked up to be. In many cases it is clumsy and verbose and it doesn't really promote reusable code or modularity.
That is why the C++ community is today far more interested in generic programming, and why everyone are finally starting to realize that functional programming is quite clever as well. OOP on its own just isn't a pretty sight."
Smalltalk has had anonymous functions in the form of block objects since 1972! And they are so fundamental to the language that all control structures and iteration constructs are implemented using them! Look at the following if/else code in smalltalk:
(...boolean expression...)
ifTrue: [...true block...]
ifFalse: [...false block...]
That sends an ifTrue:ifFalse: message with two arguments, a true block and a false block (lambdas), and if the receiver, a Boolean expression that should yield either the True or False object, is true, then the first block gets evaluated and the second ignored, and if it's false, than the second is evaluated and the first ignored.
Anonymous functions are a core part of OOP, because OOP is supposed to be a streamlined subset of Lisp, preferably with specialized message-passing syntax. The idea that anonymous functions are some recent, novel addition to OOP, or that functional programming constructs are at odds with "pure" OOP, or that by peppering your C++/Java/C# code with lambdas, your "object-oriented" code has suddenly become multi-paradigm, shows just how distorted an understanding of OOP and functional programming the average programmer, and even language designer, has.
Stroustrup clearly didn't understand OOP or Smalltalk when he bolted classes on to his wretched mess of a language, and that's why C++ looks the way it does, instead of like Objective-C, a language that was a faithful, somewhat successful attempt to add Smalltalk-style OOP to C.
- protomyth 14y agoHis ideas for OOP were based off of Simula 67 rather than Smalltalk.
- sbmassey 14y agoC++ OOP was based on Simula, rather that Smalltalk, which was OO back in the 60's, and didn't have blocks/anon functions/lambdas. (It did have coroutines though; not sure why that didn't make it to C++). Unlike Java or (I suppose) C#, C++ has been considered multi-paradigm certainly since 1998 with templates and the STL: this is not related to the recent addition of lambdas to the standard. Very little of the popular Boost library can be considered OO, for example, as it generally discourages inheritance hierarchies, as does most modern idiomatic C++.