in reply to Re^3: I dislike object-oriented programming in general
in thread I dislike object-oriented programming in general

You're absolutely correct in your examples. The implementations of Javascript do not provide proper autoboxing. This isn't that surprising, given Javascript's history and the browser wars.

What I was referring to was Javascript's prototype-based (vs. class-based) OO. I find that you can easily build classes on top of prototype, but you can't build prototype on top of classes as easily. I can't imagine how I'd build a prototype OO system in Ruby. There's a dozen really decent implementations in Javascript of a class system.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re^4: I dislike object-oriented programming in general

Replies are listed 'Best First'.
Re^5: I dislike object-oriented programming in general
by tilly (Archbishop) on Oct 21, 2007 at 10:47 UTC
    Um, only the second example involved anything that looks like autoboxing. (And that one did not involve autoboxing, as pvande pointed out it was a parsing issue.) The first was a case where JavaScript is not using available hooks in places where it makes sense to do so, and the third was a case where JavaScript simply does not provide conveniently placed hooks.

    But if your complaint with Ruby's OO system is that it cannot easily implement a prototyped system, that's like saying that Perl is more OO than JavaScript because it is easier to implement a prototyped system in Perl than to implement multiple inheritance in JavaScript. This is true, but irrelevant - Perl's support for OO everywhere is not as pervasive as JavaScript's.

    Furthermore you're mistaken. I found a trivial implementation here:

    Proto = Class.new(Class) # Beware: magic. def Proto.clone Class.new(self) end
    While I don't doubt that there are many good class implementations in JavaScript, I doubt that any are as short and cute as this prototype implementation in Ruby. Follow the link for a demonstration of usage. While I have to admire how cleverly it ties objects to classes, it unfortunately doesn't work with ancient versions of Ruby such as the one I have on my computer. (Ruby 1.6.8 complains that you can't create a subclass of Class. That version is from 2002.)

    There is also prototype in the Ruby gems library. I didn't like some things about it (in particular it looks like it doesn't support noticing that the prototype changed), so I implemented my own reasonably full-featured system using a minimum of strange magic that works even in ancient versions of Ruby: