in reply to Re^2: I dislike object-oriented programming in general
in thread I dislike object-oriented programming in general
For example in Ruby if you sort an array of numbers, it defaults to sorting them as numbers. In JavaScript it defaults to sorting them alphabetically, no matter what their types are.
For another example, in Ruby I can trivially add a new method to Integer, and then call my new method on the integer 5. In JS it works, but much less consistently. This works:
But this doesn't (at least not in Firefox):Number.prototype.foo = function () {alert("Hi!")}; x = 5; x.foo();
That isn't what I expect from a completely object-oriented language!Number.prototype.foo = function () {alert("Hi!")}; 5.foo();
Furthermore the OO hooks in Ruby are much more pervasive than in JavaScript. For instance I once tried to write a fairly efficient factorial function in Ruby. I found that it was more efficient than the routine to convert big integers to strings! So I replaced the routine to convert big integers to strings.
I wouldn't even dream of messing around in the internals like that in JavaScript.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: I dislike object-oriented programming in general
by pvande (Initiate) on Oct 20, 2007 at 20:37 UTC | |
by tilly (Archbishop) on Oct 21, 2007 at 04:00 UTC | |
| |
Re^4: I dislike object-oriented programming in general
by Joost (Canon) on Oct 20, 2007 at 01:02 UTC | |
by tilly (Archbishop) on Oct 21, 2007 at 21:14 UTC | |
Re^4: I dislike object-oriented programming in general
by dragonchild (Archbishop) on Oct 20, 2007 at 02:20 UTC | |
by tilly (Archbishop) on Oct 21, 2007 at 10:47 UTC | |
Re^4: I dislike object-oriented programming in general
by Anonymous Monk on Oct 22, 2007 at 17:44 UTC | |
by tilly (Archbishop) on Oct 22, 2007 at 17:48 UTC |