Why not make Opal default for Rails?

Hello People,

I just read this blog post http://piotrsarnacki.com/2014/01/01/i-am-tired-by-rails-should-fundamentally-change-crowd/ .

Rails started with a mission to make web development easy. Part of its strategy is to bring Ruby to masses so that tasks that were tough till then became a breeze. Now most applications are moving to javascript, a language that is not liked by many Ruby people because Ruby is elegant.

Rails has answered this problem a bit by making coffeescript as default, but I feel keeping everything ruby like will make it better. There is this project called Opal http://opalrb.org/ which I am following, and I feel it will be great if Rails has this as its default say from Rails 5 or some thing.

What you people feel about this idea, will it change the universe or it just sucks?

Regards

Karthikeyan A K

It just sucks.

I would be opposed to this. In fact, I don’t really like having CS as default, though I use it for preference, for the same reason: Javascript, not anything else, is the de facto language of the client side. Javascript should be the default.

CS as a default isn’t so bad as it is designed primarily to expose ‘the good parts’ of JS in a syntactically cleaner format. How close it gets to JS is another matter, but 90% of basic code you write in CS will come out as recognisable JS. Ruby is not nearly as similar to JS as CS; your Ruby code might look pretty going in, but the more ‘Rubyish’ your Ruby, the uglier and harder to maintain the resulting JS will be. (Even transpiled CS takes a bit of getting used to, especially if you’re using the class syntax.)

There is a great explosion of compile-to-JS projects happening at the moment, some of which is very interesting; but Rails’s purpose isn’t (or shouldn’t be) to make web development easier for Ruby people, but to speed up development of real-world web projects as such. That means favouring the lingua franca of the client side where possible. Does Opal play nicely with Jquery? Backbone, Ember, Angular, Underscore, Handlebars … ? I know one language that certainly does, with no hiccups: Javascript. If the future is front to back Javascript, which I don’t really think it is, then you need to know Javascript - simple as.

Of course, it’s pretty minor, since adding or removing any compile-to-JS thing you require is simply a matter of changing a line in the Gemfile.