Google App Engine for Java Developers
Is it ready for prime time?
It has been a few posts since I spent any time on technical topics, but I've been spending some time on this issue and I thought I would post my results. Google's App Engine is based on a great idea, cloud computing but without having to provision individual servers to host your application. Most people deploying to the cloud don't really care about how many servers are handling their app at any given time, they just want it available whenever a customer needs it. They also don't really want to spend their time optimizing database performance, or caching performance, or any of the details that are best left up to experts like those at Google.
App Engine allows you to deploy an application and let Google handle the details of delivering it to customers. Initially it only provided support for Python applications, but now also supports Java. For various reasons that unimportant to this article I ruled out Python as an implementation language and wanted to focus on JVM based solutions to deployment on App Engine. In addition, I was really only interested in solutions that allow portability. I want to be able to run the same application with few changes on a standard application server. I'm also interested in rapid application development with a full stack solution to the problem. I don't want there to be a long lead up to any development effort. Many of the jobs I take on are relatively small and I don't want to waste effort that could be concentrated on customer needs.
With these criteria there were only a few ways to do development on App Engine.
- Groovy on Grails
- Ruby on Rails using JRuby
- Scala and Lift
So I'm left with Grails and Rails. Both of these are terrific frameworks and I thought that either one would do what I wanted. What I found was a bit different.
I started experimenting with Grails first. Being primarily a Java developer using Groovy and Grails lets me leverage many years of experience without sacrificing the advantages of a dynamic language in this space. After learning that using standard GORM mappings wouldn't work on App Engine, and learning about other problems with the platform, I decided to give JRuby a try. Certainly I should be able to develop a Ruby application and deploy it anywhere using JRuby? First I had to get a good grip on the Ruby language. It is a nice language that has much in common with Smalltalk and Common Lisp, two languages that I am familiar with. After a few days of going through the docs and playing with it a bit I felt like I could be productive in this language and I started working through the Rails tutorials. Rails is quite nice and has much in common with its descendant Grails. Unfortunately I found it impossible to even get a "Hello World" application working under App Engine. While trying to work out exactly how to do so, I found out that using Rails, I would have to change the definition of domain classes to handle Google App Engine specifically. Given that this was the kind of thing that I wanted to avoid, I decided to have another look at Grails.
There are a number of problems with using Grails under App Engine, but the biggest is that you can't use your normal domain classes. Grails is built on Hibernate and Hibernate only talks to relational databases, not BigTable used by Google. So you have a choice when developing for App Engine, you can either use JDO annotations for your data mapping or you can use JPA annotations for your data mapping. Using either of these choices would be a deal breaker for me if I didn't get all the finders and validation from GORM that I would normally get. I want a normal Grails application that just happens to be deployed on App Engine. Well with the gorm-jpa plugin you get all the GORM goodness, but with JPA annotations. I wish the system could just provide the JPA annotations on a normal domain class, but that isn't how it works.
After jumping through numerous hoops to get a sample application to deploy on App Engine what I found was that numerous things just didn't work the way they should in a normal Grails application. Flash scope doesn't work correctly. I get server errors when validation fails while trying to save invalid data instead of just getting an error message from the scaffolded application. Oh, and by the way, scaffolding doesn't really work. Unless you generate the code, it doesn't work correctly. So even a simple test application really doesn't work correctly under App Engine.
I'm going to continue to monitor progress on this front. I am quite excited about the service that Google is trying to provide. I'm also going to continue to work with my Grails application and see if I can get it to deploy to App Engine without sacrificing portability and without having visible warts. I'm skeptical about this possibility right now. For now, development on App Engine is probably realistically restricted to Python based solutions, or Java solutions using simple Servlets and JSP, and not anything with a higher level framework. That is, of course, only if you are interested in portability. If you don't mind targeting App Engine and only App Engine, and you are OK with customer lock in, there are solutions available to you.