Live data from Hacker News

Opal: Ruby in Your Browser – the Basics

sitepoint.com

41–47 of 47 posts

Re: Opal: Ruby in Your Browser – the Basics

#41
post #39

We're using this on a large'ish project at the moment and thrilled with the productivity gains. Right now we're using Rails 4.1RC2 + Opal and thrilled with the readability that we now have across the board. This is good sized project for several thousand concurrent users and was to test the waters before using for something larger on our plate.

I'm curious what kind of features you have on the client side that you're using this for.

Quite a few with some diversity. Right now there are a mapping functions / integration with Google Maps and various social functions, including heavy communications (mostly text at the moment). We have a bit of animation and using the opal-jquery plugin as well, which is quite nice. The opal-browser library also gives a nice Nokogiri feel to working with the DOM.

Re: Opal: Ruby in Your Browser – the Basics

#42
post #19

I looked at this just a few days ago but decided not to pursue it any further because of how much junk JS it needs to generate and how readable that junk JS would be during debugging.

You might want to look at https://github.com/rubys/ruby2js

Opal is much more mature and useful. I took a good long look at this before, but we decided on pursuing things with Opal instead.

Re: Opal: Ruby in Your Browser – the Basics

#43

How is this "Ruby in Your Browser", per se? You're just saying that you've used Ruby to build a web page now in the browser, correct? I ask because I'm seeking something more like a Ruby on Rails Implementation waiting for you in your browser, in effect, when you arrive at the service's website, which you can then take with you if you'd like, as a VM, in any number of ways.

Well, funny enough you can do rails with opal (they implemented Active Support (https://github.com/opal/opal-activesupport), which was kind of an answer to DHH and another before him thinking it couldn't be done, BUT... the real power comes from using it with something like rails. For example, we use it with rails 4.1rc2 at present to have ruby everywhere. So instead of just .js files or coffeescript, we have .js.rb files that pass through opal. Amazing readability improvements and a great feelings just going straight ruby across the board. There are some really slick little frameworks like `lissio` and `vienna` as well that offer `sinatra` like solutions right on opal.

The maker of `lissio` also started hacking on a little project that is not complete, but gives an idea of a WIP lissio project here: https://github.com/meh/gwentoo

Just kinda nice to see how it goes together and how very flexible it is.

Re: Opal: Ruby in Your Browser – the Basics

#46
post #39

We're using this on a large'ish project at the moment and thrilled with the productivity gains. Right now we're using Rails 4.1RC2 + Opal and thrilled with the readability that we now have across the board. This is good sized project for several thousand concurrent users and was to test the waters before using for something larger on our plate.

I'm curious what kind of features you have on the client side that you're using this for.

Oh, and fyi, going to be using it for some heavy graphics soon and even going to test out some game development. Personally I intend on wrapping ImpactJS for Opal and then using it for a demanding project so we can work entirely in ruby.

Re: Opal: Ruby in Your Browser – the Basics

#47
post #40

Earlier quoted context omitted.

Opal creator here. Debugging in Opal is no problem at all with source maps. I only need to look at generated code when Im working on improving the compiler/fixing bugs. Developing end apps always results in using the chrome debugger stepping through source-mapped code. About the raw JS, to use my current app as an example, I have one line of inline JS (using `...` notation) which is just to initialize FastClick. Writ…

What kind of client side coding are you using it for?

Various projects. Two recent ones are a POS system running on the iPad. The app is wrapped using Cordova for native scanner/receipt printer access, but the rest is built in Opal with a Sinatra backend. So lots of client models, lots of UI rendering using our opal-haml integration. Considering the POS system is dealing with thousands of product lines, performance on the iPad is great. Also, testing using rspec for all the opal client side code as the models are shared on the backend. Testing the same code using the same specs on both client and server is really nice, and saves a huge amount of duplication. It all comes from some extensions to Vienna which treats the opal stuff as a view layer replacement. Hoping to blog most of it soon, including the Cordova integration.
Post reply on HN