Hangout with Ruby Social Club about Opal

It’s been a great Hackatron yesterday.

Gianluca (@yanwt) came from Vicenza to attend his first hackatron and we hanged out with the Ruby Social Club to talk about Opal: a ruby to javascript compiler.

One of the reason why Node.js was created was to help developers minimize context switching by using only one programming language to develop server-side and client-side code: javascript.

Many ruby developers enjoy writing javascript using coffeescript. Coffeescript is neither javascript nor ruby, it’s a nice alternative to javascript but it doesn’t solve the problem of using one only programming language rather you should learn a new programming language from scratch.

With Opal you just write ruby code. Wrappers for major javascripts libraries are under development to allow you not to write a single line of javascript but if you need to you can always surround text with `` ` (backticks) to inline javascript code.

There’s also a gem developed by Elia to integrate Opal with Rails called opal-rails. opal-rails integrates Opal and Rails 3 assets pipeline. Create a new file inside app/assets/javascripts with .js.rb extension to use Opal power. The resulting javascript code is compiled during assets compilation.

One more reason to use Opal is to get benefits from the RSpec testing library also for front-end code. Write specs as usual to test your javascripts. You can also use Opal to add specs to existing javascript code! This is great.

Debugging javascript code generated by Opal is not so easy but Adam Beynon is working on a solution to get an exact mapping between your implementation and generated code to help developers find bugs on their code.

Elia bets on Opal official integration with Rails 4, what do you think about it?