Everyone’s been talking about the Google App Engine and its recently added support for the Java programming language. This is big news due to JRuby: the implementation of Ruby for the Java Virtual Machine.
I decided to write an application to take advantage of various Google technologies inside of a Rails application. I wrote a proof of concept app called Stockapp. Stockapp is a super-simple, feature-incomplete stock portfolio application that utilizes Google Accounts for login, the Google Datastore for data permanence, URLFetch for network I/O, JSON, and Yahoo Query Language to fetch the stock quotes on the fly. This is a rather incomplete application, but serves as a nice template if you’re looking to build an application and deploy it with the Google App Engine.
Stockapp: Source Code | Demo
The application utilizes:
- Ola Bini’s Bumble to communicate with the Datastore
- URLFetch to make requests across the network because Ruby’s native Net::HTTP class won’t work with the App Engine due to security limitations.
- Ola Bini’s BEEU for account authorization
My Impressions of App Engine + Rails
I think the App Engine is quite remarkable. The idea that Google provides the public free access to distributed computing— and for $0.00— is revolutionary. As for using this method of deployment with Ruby on Rails, I would advise against it at this point. I found it to be a real pain to develop something as simple as the Stockapp.
- You can’t use the handy Rails generators (script/generate model …) because they seem to become broken when removing ActiveRecord. I guess someone could just rewrite some handy generators for use with the App Engine.
- Ugly, un-Ruby-like code due to weird idiosyncrasies resulting from to too many moving parts required to get the thing working
- No true database adapter. While Ola Bini’s Bumble library is super helpful, I would like to see an ActiveRecord database adapter for the Datastore, rather than having to disable ActiveRecord and all of the wonderful things you get with it.
- Bad development workflow. While the Google App Engine API comes with a development server, I didn’t have much luck with it. Several times, I would experience inexplicable errors in the production environment that weren’t reflected in the development environment. So I just stopped using the development server all together, which wasn’t pleasant.
- Compile, Deploy, Wait… Every time I would make a change to the code, I’d have to update the WAR, and re-upload, and then on the first hit— because the app becomes Java— I’d have to wait for the app to get compiled in the container. While I created a little script to automate this, it still becomes quite time consuming, and takes away the fun of writing an application with Rails. You might as well just use Grails.
The App Engine is awesome. Deploying a Rails application in the App Engine— not so awesome. I think Google ought to expand their supported languages to include Ruby. I think there’d be a lot of happy people if they did.