Last Updated: February 25, 2016
· wstucco

Opal (the Ruby to Javascript compiler) and Meteor

If you're a rubyst, you probably know Opal already.

For those who don't

Opal is a ruby to javascript compiler, an implementation of the ruby corelib and stdlib, and associated gems for building fast client side web applications in ruby.

On the other side, Meteor is

an ultra-simple, database-everywhere, data-on-the-wire, pure-Javascript web framework.

Which basically means Meteor is a reactive framework, built on node and javascript, it is isomorphic (a.k.a it enables the developer to write the same code on the client and the server) and automatically synchronise changes across clients and between clients and server.

I was working on a Meteor project and was unsatisfied of Javascript, so I tried Coffeescript, but Meteor still does not integrate perfectly with it, so I started thinking if there was a way I could use Ruby through Opal.

A weekend later I published an Opal build plugin for Meteor, it's very basic, but it works.

On the Atmosphere page you can find some preliminary documentation on how to use it.

I've also published a Gist with a basic Opal-Meteor example on how to wrap Meteor builtin objects into Opal classes.

This is the code in all its glory

# user.rb
class User
  attr_accessor :name

  def initialize(name)
    @name = name

  def admin?
    @name == 'Admin'
# meteor.rb
# Meteor Objects wrapper
class Meteor
  def self.server?

  def self.client?

  def self.startup(&block)
    `#{ if block_given?}`

# main.rb
user ='Admin')
puts user
puts user.admin?

puts "hello from client #{}!" if Meteor.client?
puts "hello from server #{}!" if Meteor.server?

I encourage you to put the plugin under test and signal me bugs or desiderata.