Hacker News new | past | comments | ask | show | jobs | submit login

Opal is a really neat gem for translating Ruby to JavaScript. For those who know some math, I used it to convert some Ruby code I had written to perform finite field arithmetic (https://github.com/robertzk/FiniteFields) into an interactive webpage (http://therobert.org/finite_fields/). It would be just as trivial to do with Volt.



Just to make it explicit - Volt makes use of Opal.


So why not just use JavaScript to begin with?


Because Javascript is a horrible language to code in and debug.

If you're a Ruby programmer, you don't need to learn a new language, and you can have confidence that the Opal guys have looked after a lot of the issues you're not experienced enough to understand.

Your question is like asking a C programmer "why not just use assembler?" or an assembly programmer "why not just toggle 1s and 0s in, because ultimately your code is going to get turned into binary eventually, right?"

Abstractions and different models of describing a problem solutions are helpful for a multitude of reasons.


While JavaScript is a terrible language to debug, machine-generated JavaScript is little better, and leaves you guessing which code you need to change and how in order to affect it.


It can be better if it is compiled from a strongly-typed language. This gives benefits you'll never get from raw Javascript.


It has been my experience that JavaScript is a high level language.

In this particular case, Ruby is not being compiled to JavaScript but being transpired.


> In this particular case, Ruby is not being compiled to JavaScript but being transpired.

First, "transpiled" not "transpired".

Second, "transpiled" is a special case of "compiled", so you can never correctly say that something is not being compiled but is being transpiled, in the same way you can't say something is not a rectangle but is a square.


it's a mix, some stuff is high level (closure), some is low level (for loop before ECMA6). This is very uncomfortable when you're learning it, you never know on which side you are.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: