On Tuesday, July 19, 2011 05:41:47 PM Alexey P. wrote:
UPD, this one seems to be interesting and is very active. And (a big
plus), it generates human readable js.
GitHub - adambeynon/opal: Ruby to Javascript compiler
I remember starting a project like this. I more or less gave up when I
realized there didn’t seem to be a good way to have it continue to
generate
human-readable JS, and also support continuations.
This seems to suffer from the same limitation. Notice there’s no
enumerators.
In MRI, I can do stuff like this:
ruby-1.9.2-p180 :010 > (1…10).each_cons(2).to_a
=> [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9,
10]]
Opal doesn’t do that – all of the enumerable methods (each and friends)
simply die if I don’t pass a block.
I guess if that ends up being the only edge case, and people are OK with
this,
it makes sense. But it seems like the more weird corner cases like this,
the
less benefit there is to trying to pretend it’s a full-fledged Ruby.
Even if
your gems don’t hit any of the corner cases imposed by the interpreter
itself,
you’re still running in a restricted environment that may pose its own
problems…
Maybe it would be better to create a language specifically designed to
work
well in that environment – to build on the good ideas from JavaScript,
give
us Ruby-esque syntactic sugar, but to stick close enough that the
resulting
JavaScript makes sense and is debuggable… and I just described
CoffeeScript.
So, it looks really, really cool, but I think I’m still going to use
CoffeeScript if I use anything beyond pure JS.