
I’ve spent a lot of time recently investigating a variety of languages other than Java, such as JRuby and Scala, and truly believe from these experiences that traditional Java MVC web frameworks are inherently flawed in design and implementation. The effort involved in implementing on a framework like Struts or Spring MVC is astronomical, especially if you are going to implement things “the right way”.
It’s amazing to me how much these platforms push “hello, world” examples that are simply not realistic web applications. After trying these short examples, developers turn around and start trying to implement a complete application, and this simple example balloons into a mess of code, and that’s without any real functionality yet in the application. A co-worker of mine is a fan of saying “[These frameworks] make the simple things trivial, and the hard things impossible”.
Historically, I’ve been known to say “If you are doing web-development in Java, use Wicket“; this was based on the fact that to my experience Wicket took the most advantages from the strongly-typed, and strongly IDE-supported, Java language, as opposed to trying to hide them behind anemic and broken templating languages that have horrid editors and basically trade one problem for another.
Recently, however, I spent some time doing some significant development with the Play Framework. I have to say that I think the Play Framework has eclipsed my Wicket fever. That’s not to say that I don’t still think Wicket is very powerful, but I have been particularly impressed with the feedback loop provided by Play. It has, without a doubt, the most direct code-test-cycle I have seen in any platform for Java (it approaches the instant feedback of Rails), and also has the distinct advantage of being stateless out-of-the-box (something Wicket is definitely not).
Play manages this feedback loop problem in a rather novel way – embedded in the framework is the Eclipse compiler for Java (ECJ). This means that when you’re coding for the play framework, you’re not sending it your class files, but rather your source files. This allows Play to recompile code in a running instance on the fly – I literally only restarted my application a handful of times while I was coding over the course of several days. It also integrates seamlessly with IDEs, and ships with an embedded HTTP runtime (no deployment is necessary during development).
There are a number of other benefits Play can provide by working with source files instead of class files. Much like Rails ability to add functionality to your application at runtime, Play can (and does) pre-process certain Java classes to add functionality.
I was further heartened to see that the next release of Play is meant to fully support Scala, which would allow for other modern language features to be used with this highly interactive framework.
It’s hard to describe all of the neat features Play provides in a few hundred words, but I would highly recommend you check it out – they have a 10 minute screencast they sells it better than I can. While I’m still convinced Java (as a language) will be surpassed for an overwhelming majority of the web-development as the language continues to stagnate, this is a compelling framework for the Java platform as a whole, even if Java isn’t your language of choice.
Tags: Java, Play Framework, Scala
I am switching from Grails to Play, because it is faster, more stable and requires less restarts. They have an awesome browser based test runner for all your tests, which makes testing a lot faster and easiert as doing it with Grails. It is amazing. My Integration-Tests for Play run in microseconds, whereas with Grails it takes at least 10-30 seconds to bootstrap the entire environment and then run my tests.
Besides the screencast, there is the usual suspect – a tutorial about creating a blog application – that takes you through all of the basics of Play in a very nice way: http://www.playframework.org/documentation/1.0.1/guide1
After being disgusted from working for 5 years with ASP.NET (I am a victim of Webforms), I started looking for other frameworks that could bring happiness to my web development work. I spent a few months with Cakephp and Django. I liked both of them, especially Django, but I wasn’t feeling comfortable with PHP and Python. Then I stumbled upon Play! framework and never looked back. I’ve been using it for a month and I am totally pleased with it. The documentation is not very good (nothing compared to Django’s docs), but the support via the google group is excellent. Working with Java, Intellij IDEA and Play! framework is a joy. The pluggable architecture (like django), the code-test cycle, JPA for data access, no compiles, Groovy for templates and blazing performance with the included HTTP server are things that made me fall for this framework.
I thought Wicket was the best Java Web framework, until I came across Play. There is nothing to compile (it’s handled automatically) — just modify the source or add new files and refresh the page in the browser.
Play feels similar to other MVC apps, seemingly modeled after Rails, but improves upon the syntax of, for example, Wicket templates — no namespaces required (all those “wicket:” prefixes muddy up the markup). And the iteration is just a little more terse: no “it.” references. Just:
#{list MyClass.findAll()}
${_.title()}
#{/list}
Of course, the “_” may be named, instead. But it’s nice to have a short form.
Play makes it easy to add new tags (with parameters, if desired), work with JPA entities, inherit templates from other master templates, and call any Java libraries you wish. It also has several pre-built Modules available for working with (for example), GWT, akka, bespin, pdf, guice, lucene, spring, and even Scala.
The error messages in Java code are extremely friendly, showing a formatted snippet of the problem with correct line numbers. But a syntax error in a Template file can be a pain to track down, since a generic NullPointerException is reported.
The Eclipse plugin is barely sufficient, but supports syntax coloring and creation of the basic three file types: Model, View, and Controller; as well as running all test cases.
Play is a well-conceived and implemented Java Web framework that finally makes it fun and easy to start a new Web project. Just type “play new myApp”, followed by “play start” and the new app is viewable at “http:://localhost:9000″.
Really amazing framework!!!
at last a java tool, without the innecesary complexity of java \normal\ framework