4 ms·
I really find Carmack and Armstrong's quotes very appropriate. The root problem seems to be trying to do eveything the OO way when all you need is a function. J
by kul_ 12y ago
I really find Carmack and Armstrong's quotes very appropriate.
The root problem seems to be trying to do eveything the OO way when all you need is a function. Java for e.g. is plagued by this problem. Why would I want to write a class/object when all i need is print "Hello World".
That being said there are problem where it fits really nicely e.g. Implementing user roles.
- sly010 12y agoAgree. Almost always you have the option to place some functionality on the hierarchy somewhere, but actually composition would be better. To make matters more difficult, you have to make these kind of decisions very early before you write your code. By the time you properly understand the problem, you will have invested in a particular solution. There is N>3 ways to do things and there is only one best way, so chances are you are doing it the wrong way. OOP is not bad, it's just often misused.
- klibertp 12y ago> Why would I want to write a class/object when all i need is print "Hello World". There is a huge gap between what OO could/was meant to be and how it is seen nowadays. I prefer thinking of OO as it's implemented in Smalltalk or Io instead of in C++ or Java. To be more specific, in Smalltalk your hello world would look like this: Transcript show: 'Hello world' and in Io: "Hello world" println No class/object declaration in sight, right? And then this: > The root problem seems to be trying to do eveything the OO way when all you need is a function is a wrong question altogether - there is nothing stopping you from writing a function in OO (other than broken and dumbed down implementations in major languages, that is). In Smalltalk: my_func := [ 'Look, I'm a function!' ]. "There's this slightly unusual way of calling the function though:" my_func value. "returns 'Look, I'm a function!'" similarly in Io: my_func := block( "Look, I'm a function!" ) my_func call # same as above So, to make my point clear: there is NOTHING in OOP itself which REQUIRES verbosity and over-abstraction. On the contrary: going "full OO" makes it easier to write short, readable, to-the-point code. It also makes it easy to use FP patterns should you want it. What you're arguing against are the currently popular implementations of OO, which are just bad. And before I forget: Erlang (and I program in it quite a bit) is one of the best Object Oriented languages I worked with.
- colomon 12y agoAgreed, but note that C++ doesn't require you to ever declare a class or an object. That's a Java thing you're complaining about.
- klibertp 12y agoC++ is equally "bad" in this regard - it doesn't force you to write classes, but when you don't you're using underlying primitives which are not first class objects. In both Smalltalk and Io the expressions I gave as examples produced real objects (BlockClosure and Block instances, respectively), while in C++ this: void my_func(){ std::cout << "I'm a function"; } produces a simple pointer. Of course, this is how it should be - it follows from C++ design goals and totally makes sense for a number of reasons; however, from the perspective of OOP, this makes C++ less "pure OO" than mentioned languages (and many others).
- mikkom 12y agoI'm not sure if you are trolling or not but erlang is not an object oriented language. Joe Armstrong said it quite clearly in the article where his quote was taken > As Erlang became popular we were often asked “Is Erlang OO” - well, of course the true answer was “No of course not” - but we didn’t to say this out loud - so we invented a serious of ingenious ways of answering the question that were designed to give the impression that Erlang was (sort of) OO (If you waved your hands a lot) but not really (If you listened to what we actually said, and read the small print carefully). http://harmful.cat-v.org/software/OO_programming/why_oo_sucks http://harmful.cat-v.org/software/OO_programming/why_oo_suck...
- klibertp 12y agoI'm not trolling; of course whether Erlang is OOP depends on a definition of OOP you consider "real". If you think of OOP as Java-style programming, then of course, Erlang has very little in common with it. On the other hand, if you go back to what Alan Kay had in mind when he invented OO, namely objects as "black boxes, similar to computers in miniature" and "message passing as the only way of doing something" then Erlang is very, very much OO. Its processes are objects, and sending (asynchronous!) messages is built into the language. Then you get encapsulation, data hiding and interfaces with module exports and behaviours. That doesn't stop Erlang from being FP, too. Really, there are many different paradigms and many implementations of each one, it benefits no one to only consider one particular implementation as representative for a whole paradigm. Footnote: Alan Kay post on a similar topic: http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-October/017019.html http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-...
- GFK_of_xmaspast 12y agoHow often are you writing a program that only needs to print "Hello World".
- judk 12y agoEvery time I need to put a program in discussion board comment to prove a vague point about program design.