News for hackers. Stuff that matters.
Re:Opal - Ruby to Javascript compiler by 5vforest on Friday October 19, 2012 @01:46PM (#4674605)
What the use case for something like this? Am I missing something?
Re:Opal - Ruby to Javascript compiler by Sanddancer on Friday October 19, 2012 @02:03PM (#4674715)
Using the language you're comfortable with client-side. Though what this really shows, once again, is that we really need a good, open, virtual machine specification for client-side byte code so we aren't stuck with the same javascript hammer for all problems.
Re:Opal - Ruby to Javascript compiler by MatthewPhillips on Friday October 19, 2012 @03:37PM (#4675080)
? Doesn't this show that we aren't stuck with the same hammer? Opal is a different hammer.
Re:Opal - Ruby to Javascript compiler by rrouse on Friday October 19, 2012 @04:33PM (#4675282)
Not really. You're still using Javascript in the end.
Re:Opal - Ruby to Javascript compiler by ville on Friday October 19, 2012 @07:56PM (#4675856)
How is that a bad thing? Source code VMs are easier to secure and as the tooling improves, you don't need to look a the generated JS anymore to debug, it becomes "byte code".
Re:Opal - Ruby to Javascript compiler by rcthompson on Friday October 19, 2012 @05:02PM (#4675375)
Wasn't that the original goal of Java, like, 20 years ago?
Re:Opal - Ruby to Javascript compiler by Sanddancer on Friday October 19, 2012 @09:12PM (#4676022)
It was, but the big issue there was that sun decided to keep all the keys of the castle to themselves. Hence the desire for an open bytecode format.
Re:Opal - Ruby to Javascript compiler by iso8859-1 on Friday October 19, 2012 @07:16PM (#4675778)
Native Client? Or PNaCl if you insist on extreme portability.
Re:Opal - Ruby to Javascript compiler by threedaymonk on Friday October 19, 2012 @03:27PM (#4675035)
If you can perform computation on the client, you can avoid some round trips to the server. Of course, you can't trust the client, so you still need to perform (some of) the same computations on the server.

If you can use the same code for both client and server, then it opens up the possibility of sending chunks of logic over the wire.

Here's a trivial example: a website uses Markdown for comment formatting. You can improve the feedback cycle, especially for those who aren't overly familiar with Markdown, by rendering a preview on the client side. However, this means that you need two Markdown parsers, one in your server-side language, and one in JavaScript. That's a potential duplication of effort. Someone has already written a JS Markdown parser, but it might not have exactly the same behaviour as your server implementation. So why not just write the code once and have it work on both sides?

I have a feeling that there are a lot more interesting things that you can do with split computation, but I haven't seen many examples yet. I think they'll come.

Re:Opal - Ruby to Javascript compiler by mikesea on Friday October 19, 2012 @01:56PM (#4674665)
Rewriting your entire Rails app in Node so that it goes faster!
Re:Opal - Ruby to Javascript compiler by astrodust on Friday October 19, 2012 @01:49PM (#4674618)
Porting existing code without having to re-implement. Keeping a single reference implementation of a particular method.