Hacker News new | ask | show | jobs
by Dirlewanger 3880 days ago
I see the benefits of Opal, but can anyone enumerate the downsides? I imagine it generates quite a bit of cruft as CoffeeScript does (of course, one argues that developer satisfaction in using said language outweighs the extra lines added to JS files).
3 comments

CoffeeScript is largely just a shorthand built on existing JavaScript idioms, so the output is more or less 1:1. In order to provide some of the capabilities and behaviors that you would expect to find in a real Ruby environment, Opal has to use a fair amount of runtime code. As a result, the tracebacks and error messages that you get from Opal are often very unhelpful.

I also found that quite a few of the libraries in the Opal ecosystem (like the opal-browser library that wraps a bunch of important native web features) are fragile and under-documented.

That said, Opal worked far better than I actually expected. I built a simple demo with it a few months ago and was pleasantly surprised by many aspects of the experience. There's a third-party React wrapper called React.rb that is quite impressive.

I wrote about my Opal demo app here: https://www.rethinkdb.com/blog/ruby-opal/

And here are the slides from a talk I gave about full-stack Ruby development: https://speakerdeck.com/segphault/realtime-web-apps-with-ret...

I have not used it, but I would guess interop with existing JS libraries is awkward. The cognitive overhead of working in such a different syntax from the underlying libraries. I'm guessing these are quite a bit higher than say Coffeescript (which I have quite a big of experience with).
It's been a while since I tinkered with it, but the size of the library was the biggest turn off. It's currently at 259k for the min version. That's a lot to add, especially if you're targeting mobile.
> It's currently at 259k for the min version.

It's only 59.0 KB, see http://cdn.opalrb.org/opal/current/opal.min.js

I'm showing 259KB in linux, 259KB in OSX, and 253KB in windows.