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

I could be off-base, but your thinking seems to be, essentially, "More buzzwords can be applied to Ruby, while 'OO' is the only one that applies to Java, so Java must be more purely OO." This is not a very accurate view of the two languages.

Ruby's support for "functional" programming essentially comes down to its ability to encapsulate code in closure objects and the core libraries' pervasive support for these code-objects, called "blocks." But there's nothing about blocks that's anathema to OO. Ruby's blocks are ripped off wholesale from Smalltalk, one of the pioneering OO languages and the one that coined the term "object-oriented programming." Blocks are objects. You can send messages to them, store them in arrays, etc.

Ruby is very similar in general to Smalltalk, much more so than Java. It's also very different from a real functional language like OCaml or Haskell, and trying to write a program as though it were one is an exercise in frustration.

Here are some aspects of Ruby that are more strongly OO than Java:

• Classes are objects — they have methods and instance variables and can be used anywhere another object would be used.

• Due to classes being true objects, class methods can be overridden. In Java, class methods are pretty much just namespaced functions. There isn't even a self/this in Java's static methods. That is totally broken OO — Ruby does it right, Java does it wrong.

• Every type in a Ruby program is an object type. In Java, some types are objects and some aren't. For many types in Java, there are both object and primitive variants. I'm not commenting on whether this is good or bad, but having non-object types in your language is not pure OO.

I would be hard-pressed to come up with similar counterexamples that show Java to be more in line with OO principles than Ruby.




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

Search: