afaik,it's not really a ruby to javascript compiler(like coffeescript compiles down to js). You cant write xhr = XMLHttpRequest.new and expect it to compile in js.without importing some libs.
It is really a ruby to JS compiler. Ruby, however, is not just a thin layer over JS the way CoffeeScript is. The thing you are referring to is a sign of CoffeeScript being a thin layer over JS, not CoffeeScript's compiler being a "real compiler".
Opal: Ruby to JavaScript Compiler
31–40 of 69 posts
Re: Opal: Ruby to JavaScript Compiler
#32Re: Opal: Ruby to JavaScript Compiler
#33What is a good use case for this? Interesting project otherwise! :)
Re: Opal: Ruby to JavaScript Compiler
#34I think it makes sense to transcompile type-checked languages to JS, though. Elm is pretty neat.
Re: Opal: Ruby to JavaScript Compiler
#35Earlier quoted context omitted.
Ruby and JS are both Turing-complete languages (as with just about any other programming language you'll ever use), which means that one can simulate the other. The simulation might be messy, complicated, or slow, but it will still work. In this case, Ruby and JS are close enough that it can be done without too much trouble (see the compiled JS).
But does "anything written in language A can be simulated using language B" imply "A can compile down to B"?
Re: Opal: Ruby to JavaScript Compiler
#36Earlier quoted context omitted.
Ruby and JS are both Turing-complete languages (as with just about any other programming language you'll ever use), which means that one can simulate the other. The simulation might be messy, complicated, or slow, but it will still work. In this case, Ruby and JS are close enough that it can be done without too much trouble (see the compiled JS).
But does "anything written in language A can be simulated using language B" imply "A can compile down to B"?
Re: Opal: Ruby to JavaScript Compiler
#37How do people know that one lang would compile down to another? Is there something about the lang that make this possible? Also, is it possible that something won't translate from ruby --> js and cause a bug?
* throw some error from the compiler.
* cause a bug in the resulting code.
Re: Opal: Ruby to JavaScript Compiler
#38How would Opal handle meta programming like method_missing and define_method?
`define_method` as well: https://github.com/opal/opal/blob/f958d6b2468e57acf7f324e10a...
Re: Opal: Ruby to JavaScript Compiler
#39I'm curious, do you plan to support Encodings and proper Ruby strings, or it isn't worth the effort, and you'll keep using plain javascript strings?
(I tried to look for this detail on the website but came back empty-handed)
Re: Opal: Ruby to JavaScript Compiler
#40Earlier quoted context omitted.
As DouweM said; there is a case to be made for having the whole stack in a single language. While I use different languages server side, Ruby (either with Rails or Sinatra) is my go to option more often than not these days. I have used CoffeeScript extensively, but this has always been on contracts where the decision was made by someone else. It is important to learn and use real JavaScript (IMHO) rather than all of…
>I have used CoffeeScript extensively, but this has always been on contracts where the decision was made by someone else. >It is important to learn and use real JavaScript (IMHO) rather than all of these transpiled languages. This is the route I take when I have a choice on the client side; I use JavaScript. I've been using Rails and Coffeescript. Intuitively, I feel like using Javascript directly would be better som…
I'm a pretty experienced JS dev, so I know exactly what my CS is compiling to and what that's going to do. If I didn't, CS would make me tear my hair out within a week. As it is, it's just shorthand for JS with a bunch of quality of life improvements (?, no var, etc).