Live data from Hacker News

Opal: Ruby to JavaScript Compiler

opalrb.org

11–20 of 69 posts

Re: Opal: Ruby to JavaScript Compiler

#11
post #3
post #2

What is a good use case for this? Interesting project otherwise! :)

Ruby aficionado programmers who think coffeescript is too pythony perhaps? :)

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 these transpiled languages. This is the route I take when I have a choice on the client side; I use JavaScript.

If I were to use a transpiled language though Opal makes more sense (IMHO) than CoffeeScript if you are working on a project with a Ruby backend. At least then you are creating a uniform stack and hopefully getting some type of productivity boost for your development team instead of always context switching between different languages.

Re: Opal: Ruby to JavaScript Compiler

#12
post #2

What is a good use case for this? Interesting project otherwise! :)

I have a few developers that can't wrap their head around too much languages without popping one out. The less variability we have, the more robust the final code will be. Theoretically, all developers are ideal learning machines with a robust CS background and a powerful abstracting mind with infinite time to learn and jump around languages at will, with perfect understanding of each language caveats and idiosyncrasies. In practice, one has to build stuff. This kind of things, while not a perfect solution, allows my team to produce better code more reliably.

Re: Opal: Ruby to JavaScript Compiler

#13
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.

Re: Opal: Ruby to JavaScript Compiler

#15
post #5

Great, I love Ruby. But what do I do for debugging?

If you use any 'something-to-another' abstraction, be it language, ORM, whatever... You pray that it doesn't come to debugging.

Might be a great tool for adding a grain of JS salt. But of course if you want to build an entire project based on JS, you better get a book and learn JS...

Re: Opal: Ruby to JavaScript Compiler

#16
post #5

Great, I love Ruby. But what do I do for debugging?

(Opal developer here).

When it comes to debugging, I just use the standard chrome dev tools with source maps. Variables and properties on objects all compile using their ruby names, so viewing local vars and ivars in the debugger is easy. I only ever debug the generated javascript when I am debugging a bug with Opals runtime/internals/compiled code.

Re: Opal: Ruby to JavaScript Compiler

#17
post #8
post #4

Earlier quoted context omitted.

There's something to be said for writing the client and server app using the same language. Node.js serves a similar use case.

What is the thing to be said?

Sorry if you were attempting to troll but if not 'there is something to be said about..' is a phrase which translates along the lines of 'there are definitely good things that could be said about..'

Re: Opal: Ruby to JavaScript Compiler

#18
post #3

Earlier quoted context omitted.

Ruby aficionado programmers who think coffeescript is too pythony perhaps? :)

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 somehow, but I prefer the Coffeescript syntax. (I started using it just because Rails nudges you that direction.)

What are the benefits of using Javascript directly instead of Coffeescript in a Rails environment?

Re: Opal: Ruby to JavaScript Compiler

#19
post #14

The name is a bit awkward, given the existence of Opalang, which is another $SomeLanguage to JavaScript compiler.

Given that Opal.rb was started in 2010 and Opalang (back then called opages) in 2010 as well, I would file that under "unfortunate".

https://github.com/opal/opal/commits/master?page=107 https://github.com/MLstate/opalang/commits/master?page=126

Re: Opal: Ruby to JavaScript Compiler

#20
post #6
post #2

What is a good use case for this? Interesting project otherwise! :)

Say you have a function that validates a file written in ruby. Now you want to have client side validation in the browser for good UX. The spec for validation may be complicated or you are not sure about the implementation (no docs, person that written it just left). This is internal format with no good parsing library. I'd try it out.

Or you're completely sure about the implementation, but it may change in the future (because requirements evolve) and you don't want to have maintain two different versions.
Post reply on HN