Jax on Rails

Come closer, and I’ll let you in on a little secret. Going all the way back to the first drafts of the WebGL specification, one of my major long-term goals has been to bring WebGL to Ruby on Rails. Each iteration has brought me closer to realizing that dream.

Jax was not originally intended to be the incarnation of the Rails adapter I’ve been looking for. The way Jax is written today, it can’t interface directly with Rails applications, and trying to force it into doing so would, in all likelihood, end in catastrophe. Jax was more an attempt to bring Rails-like productivity into the JavaScript world, with particular emphasis on WebGL.

However, if you’ve ever taken a look at the Jax internals, you’ve undoubtedly seen numerous similarities to the Rails backend. Indeed, the Jax gem actually relies on railties, one of the main dependencies of Rails itself.

Fanboy though I may be, these similarities did not arise out of a blind adherence to any “Rails or bust” philosophy. Jax is written the way that it is because the railties system actually implements the vast majority of what Jax itself requires out of necessity. It sets up load paths; finds source files and provides hooks into managing them; interfaces with plugins; and is modular enough to coexist with other Rubygems that might be able to add more to the Jax experience. Why reinvent the wheel?

Still, though, in the back of my mind has always been that dream. WebGL in Rails today is not by any means an impossibility, but it’s not very Rails-like, either. A modular, extensible, MVC-based WebGL framework running in Rails does not exist today, and that is the void I’d like to eventually fill.

As it turns out, “eventually” isn’t all that far away. I’ve spent the whole of the last week experimenting with Rails 3.1, the new asset pipeline it introduces, and Jax. It’s taken a significant development effort (read: a complete rewrite!) of the Ruby side of Jax, but the result is nothing short, in my humble opinion, of impressive.

The best part is that even with the new structure, Jax still offers the ability to write static applications completely outside of Rails! This is a big deal to me, because I want people who don’t want to use Rails (for whatever reason) to keep being able to use Jax, as they are today.

At this point, it’s safe to say that Rails integration is inevitable, and it’s going to happen soon. The only thing I can’t decide on is whether it’s going to be in Jax v2.0 or Jax v1.2.

There’s lots more going on than “just” Rails integration, but that’s all I’ve got time to talk about right now. If you’d like to follow my progress, (or help me along), see the rails31 branch on Github!

Comments are closed.