play framework (1)


First Impression about the Play Framework

play framework

I was on my never ending hunt for new technologies and ideas and managed to catch a not completely new, but still young and very interesting framework. It has the simple name Play and can be found here http://www.playframework.com/. In this post I’m going to give you my first impression about my experience. Before I start, let me say that I’ve left the Java boat a while ago. Mostly because a lot of frameworks on the JVM platform have grown big and in my opinion a bit messy. Some J2EE projects I was involved in had almost as many configuration files as source code files. Sure, one can argue that’s always up to the developer but I tend to prefer framework and tools with a clear structure and maybe even some borders to make sure everyone uses the same style and architecture.

Play Framework 1.0 vs. 2.10

A few hours after the Play Framework caught my interest, I was lucky enough to be on a train ride for a few hours and managed to get a hold on the Play Framework Cookbook by Alexander Reelsen. I found it easy to read and follow. He also covered most of the topics I care about: Basic structure, form handling, AJAX, security, REST etc. The only, and big cavet, it’s based on Play 1 while we’re at 2.10 by now. It still helped me to get a first impression about the slickness of the framework. Talking about the version, this is already the first thing that bothers me for a while. I certainly understand that there has to be some kind of evolution sometimes, even if it breaks the backward compatibility but I think it also causes a number of problems. When you search for a tutorial, a module or anything else related to play you’ll mostly find content related to the out dated version 1. I sometimes wished they changed the name because so many things have changed. The whole template system, which was based on Groovy templates, uses Scala by now. I guess some people are going to tell me that I can replace the template system. Well, I can but I don’t want to go a non-standard way, I’d like to stay where I find the most knowledge, the most articles and the most developers. In case you wonder, I tried to replace the Scala templates, it wasn’t difficult.

Luckily, there are some books in the work for Play Framework 2. Two are currently on my watch list: Play for Scala by Peter Hilton, Erik Bakker, Francisco Canedo and Developing on Play Framework 2 by Andy Petrella.

The basics for Play Framework

Since Play follows the MVC pattern very clearly, I felt almost at home when I started with it. Here are some random facts I found when I started to work with Play:

  • It work with the MVC pattern
  • A lot of code has been written using Scala but you can also use Java and maybe other JVM based languages
  • You’ll only need a copy of the Java JDK in addition to the Play Framework
  • There’s a copy of the H2 database included in the framework, no need to install anything in order to get a database into your application
  • Unlike most Java frameworks, you can change a single code file and reload the page in your browser, the framework will automatically compile the code. It takes a few seconds but it’s still quick enough to enjoy this feature. I feel that this could make things messy, but mostly enjoyed it because it makes learning so much easier
  • There’s a console you can use to create a new app (play new yourApp), run an app (play run) and more.
  • It’s stateless and should scale well. I’m saying “should” because I haven’t tried
  • There’s an asset compile which compiles your LESS files to CSS among other resource compilers. You can even build your own!

Performance of the Play Framework

The framework is pretty lean and runs on a built-in Netty webserver. You can run a different setup, for example with a reverse proxy, but when developing, the built-in webserver is very hand.y It looks like there isn’t much overhead, I managed to get 2500 requests per second on a quite complicated template. It’s not really much of a benchmark but as the title says, this article is just a first impression and the first impression about performance is great!

Closing Words about Play Framework

Should you use Play Framework? The worst thing in my opinion is the fact that we have two quite different versions out there. As a beginner you’ll need some time to find the right tutorials from time to time. However, the longer Play 2 is out there, the more tutorials, examples, project and books you’ll find. At some point this should become less of an issue. The fact that a company like Linked.in decided to switch to the Play Framework should also help, more about this in this great article http://engineering.linkedin.com/play/play-framework-linkedin. They posted a great introduction to get the famous Hello World up and running.

In other words: I can recommend the Play Framework and intend to use it for one project we’re working on and others might follow.