Wednesday, April 13, 2011

(Roughly) comparing Play! version 1.2 with Rails

Both the Play! and Rails frameworks implement MVC and have very agile development environments. Play!, being written in Java (but also supporting Scala development) accomplishes this agility by using the Eclipse incremental Java compiler so if you edit any Java code or HTML template files (with embedded Java/Groovy expressions) you immediately see the results after refreshing your web browser.

While Play! is not nearly as complete of a stack as Rails, it does include modules for
  • MongoDB
  • AppEngine
  • Objectify
  • GWT
  • Search
  • PDF generation of any view
  • Scala use
  • CoffeeScript
  • OpenAuth working with Google, Yahoo, Twitter, etc.
  • Simple CRUD scaffolding
  • Facebook Connect and Graph API
  • Lucene search of JPA models
  • etc.

I have several years of Rails experience and I am using Java EE 6 for a customer project. With this background, I put Play! in the sweet spot between Java EE 6 and Rails: easy to learn if you know Java and supports agile development. My favorite part of Java EE 6 is JPA, which Play! supports.

I have played with Play! off and on for over a year, but just for a few hours at a time, and never any serious projects. (This is largely because most people who hire me usually want me to do Lisp or Ruby development.) I have more or less decided to use Play! for one of my own projects because I already have so much reusable Java code I have written for it and I like the interactive Play! development process. My wife and I are just starting a vacation, and after finding myself in a quiet place with time on my hands (we catch an early flight tomorrow morning and are staying near the airport) I just reimplemented a bit of data modeling code that I wrote in Clojure, Ruby, and Common Lisp last weekend, this afternoon in Java + JPA + Play! I really have been struggling with the decision of which language and framework to use, so I am in experimentation mode! BTW, I am using PostgreSQL with its native indexing and search functionality and I find that JPA and Java object models mix fairly well by mostly using JPA with some native quieres like this contrived example using PostgreSQL's indexing and search functionality:
List results = News.em().createNativeQuery("select * from news where to_tsvector(content) @@ to_tsquery('japan | nuclear')", News.class).getResultList();
that maps results back to my Java POJOs.

No comments: