Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

JS.Class – JavaScript in a Ruby Style

By Peter Cooper / September 26, 2008

jsclass.png JS.Class is an attempt at making JavaScript more Ruby-like. More specifically, it's a library that makes object oriented development easier in JavaScript (in comparison to JS's prototype technique, at least) by implementing Ruby's core object, module, and class systems as well as some of Ruby's meta-programming techniques.

As well as ports of Enumerable, Observable, Comparable, and Forwardable, you get subclassing, mixins, reflection, late-binding arguments, singleton methods, method binding, and Ruby-like inheritance. Of course, JavaScript gives access to many of these elements already, but JS.Class presents things with a Ruby flavor.

The official JS.Class site is particularly well done and each main area is well documented.

Comments

  1. Alex Young says:

    This looks like an excellent library. Whilst Prototype has some Ruby influences it's always great to see a different take. The JS.StackTrace utility class looks especially useful for debugging.

  2. draegtun says:

    For an alternative check out Joose

    Also it isn't tied into Prototype which I think is a good thing ;-)

    /I3az/

  3. James Coglan says:

    Hi guys, thanks for the plug, very much appreciated. Just wanted to point out that JS.Class is not tied to Prototype, it has no external dependencies on other JS libraries. I assume Alex was drawing a comparison, but if the site gives the impression that Prototype is required, do let me know where so I can correct it.

Other Posts to Enjoy

Twitter Mentions