[ANN] JS.Class 2.0

Hello list,
Do please forgive me if this is a little too off-topic but I thought some
folks here might be interested. I recently released version 2.0 of JS.Class,
my JavaScript library that implements some of Ruby's OOP features in
JavaScript. It is not a Ruby interpreter; rather it brings various idioms
found in Ruby OO programs to JavaScript, allowing for classes, modules,
inheritance, metaprogramming hooks, and ports of a few classes in the Ruby
stdlib amongst other things.

If there's anybody here who's into JavaScript I would be thrilled if they
would give it a try and let me know about any weak spots where it might
deviate from Ruby-like behaviour. This release is the closest to Ruby I've
managed to get so far, and I'd love some help from the Ruby community to
iron out any obscure use cases.

Anyway, without further ado:
http://jsclass.jcoglan.com/

Any help/feedback very welcome indeed.

···

--
James Coglan
http://blog.jcoglan.com

James Coglan <jcoglan@googlemail.com> writes:

[Note: parts of this message were removed to make it a legal post.]

Hello list,
Do please forgive me if this is a little too off-topic but I thought some
folks here might be interested. I recently released version 2.0 of JS.Class,
my JavaScript library that implements some of Ruby's OOP features in
JavaScript. It is not a Ruby interpreter; rather it brings various idioms
found in Ruby OO programs to JavaScript, allowing for classes, modules,
inheritance, metaprogramming hooks, and ports of a few classes in the Ruby
stdlib amongst other things.

If there's anybody here who's into JavaScript I would be thrilled if they
would give it a try and let me know about any weak spots where it might
deviate from Ruby-like behaviour. This release is the closest to Ruby I've
managed to get so far, and I'd love some help from the Ruby community to
iron out any obscure use cases.

Anyway, without further ado:
http://jsclass.jcoglan.com/

Any help/feedback very welcome indeed.

Ok, well, first impressions:

* It seems fairly large for what it appears to do. But I've not
  investigated this in depth.

* There's no in-line documentation, which is a pain if you're
  evaluating code.

* I'm quite certain using constructors as the basis for classes is
  just wrong in javascript. I don't have the time now to go into this
  in depth. I put some earlier explanations about constructors online
  here:

http://joost.zeekat.nl/constructors-considered-mildly-confusing.html

  At the moment I think that any code that's serious about building
  classes in JS should start from something similar to Crockford's
  "begetObject":

http://javascript.crockford.com/prototypal.html

  and forget about constructors all together.

* I'm not certain that you should even try not to "deviate from
  Ruby-like behaviour". You're not writing a ruby library, after all.

···

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

James Coglan wrote:

Hello list,
Do please forgive me if this is a little too off-topic but I thought some
folks here might be interested. I recently released version 2.0 of JS.Class,
my JavaScript library that implements some of Ruby's OOP features in
JavaScript. It is not a Ruby interpreter; rather it brings various idioms
found in Ruby OO programs to JavaScript, allowing for classes, modules,
inheritance, metaprogramming hooks, and ports of a few classes in the Ruby
stdlib amongst other things.

If there's anybody here who's into JavaScript I would be thrilled if they
would give it a try and let me know about any weak spots where it might
deviate from Ruby-like behaviour. This release is the closest to Ruby I've
managed to get so far, and I'd love some help from the Ruby community to
iron out any obscure use cases.

Anyway, without further ado:
http://jsclass.jcoglan.com/

Any help/feedback very welcome indeed.

That looks pretty complete and well documented.

I am mostly interested in how you implemented Ruby's meta model
(classes, modules and meta-classes), as that's the hardest part
at all. Mainly the circular dependency between Class and Object
(a Class in Ruby inherits from Object, and Object is an instance
of Class and as such an instance of itself :).

Note that I wrote RubyJS [1] which is a Ruby to Javascript compiler.
It supports all Ruby constructs (including method_missing) with the
only limitation being that classes and methods are fixed at compile
time, but you can use meta-programming in the pre-compilation stage
(most of the time you will not notice the difference!).

Regards,

   Michael

[1]: http://www.ntecs.de/projects/rubyjs