8 ms·
Looks nice, but I'm not sure why JavaScript needs to be like Ruby.
by papertiger 16y ago
Looks nice, but I'm not sure why JavaScript needs to be like Ruby.
- richcollins 16y agoLack of classes is one reason to prefer JavaScript to Ruby. People always feel the need to add complexity where it isn't needed.
- jrockway 16y agoYes, the lack of the class abstraction does add complexity to your code. That's why frameworks like this exist.
- richcollins 16y agoI was making the opposite assertion. How are classes simpler than prototypes? If you want to add behavior to the proto and the clone, you just add a method to the proto. If you want to add behavior to a class and its instances, you have to do a fair bit more.
- jrockway 16y agoPrototypes offer no contract, so it's up to the consumer to ensure that the object received is acceptable. Classes offer a contract, so if an object is an instance, it's guaranteed to work (Liskov, etc.). Basically, the idea of OOP is information hiding and polymorphism, and prototype-based objects throw both of these concepts away. The result is more complicated code in general.
- richcollins 16y agoRuby Classes don't provide a contract either. You can add and remove methods to your heart's desire. information hiding is the principle of segregation of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from extensive modification if the design decision is changed http://en.wikipedia.org/wiki/Information_hiding http://en.wikipedia.org/wiki/Information_hiding How are prototypes inferior to classes with respect to information hiding? They provide the ability to easily change the implementation while maintaining the interface. How do prototypes inhibit polymorphism? All of the prototype languages that I know of (Javascript, Io, Self, Lua ...) make it easy to take advantage of polymorphism.
- alanstorm 16y agoLess context switching when you're developing web applications that require a significant amount of Javascript code. Less context switching means you get to stay in flow and get more done.
- jpcx01 16y agoThere's a lot of useful functionality here that comes in handy. Just as a standard library, I think its useful. Ruby Hashes and Enumerators have way more functionality than the stock js types. Is it worth the 40k minimized for the full include? That I dunno.
- richcollins 16y agoWhat do those have to do with Ruby? Those things have nothing to do with Classes, Modules private / public ivars ...
- jagtesh 16y agoIt's an interesting experiment as far as I can see. Something on similar lines as http://phpjs.org/ http://phpjs.org/