Introducing Play 2.0
- March 13, 2012
We announced in November that Play framework, the highly productive Java and Scala web application framework would become part of the Typesafe Stack. Now, just a few months later, we are happy to announce that Play 2.0 has arrived and is now available as part of the open source Typesafe Stack 2.0 and the commercial Typesafe Subscription.
Let's see some of the highlights!Native Java and Scala SupportWhile the original version of the Play Framework was written primarily in Java (and provided Scala support through a plug-in), Play 2.0 embraces Scala more completely. Not only has Play’s core transitioned to Scala, but the new release also makes the Scala language a first class citizen for developing Play applications. As a result, the new version of the framework now provides two equally polished sets of APIs: one for Scala developers and one for Java developers.
A Controller class using Java
The same Controller class using Scala
Rapid Application Development
One of the features that provided the “Play feel” in the 1.x series of releases was the development console and browser-based error reporting. Play 2.0 greatly extends these capabilities by allowing developers to execute code snippets, tests, and shell scripts in the runtime application context and also by compiling and building many additional parts of a typical web application.
Pushing Type Safety to a New Level
Play 2.0 takes compilation and type checking even further. Routes (which define URL and action mappings), templates, and even assets are now compiled (using LESS, CoffeeScript and the Google Closure compiler), providing a unified development workflow for both client side and server side developers. The result of all of this is that more errors will be detected earlier, speeding your development process. It also makes it a lot easier to work on large projects with many developers involved.
Example route compilation failure detectionPlaying NicelyPlay 1.x implemented many of its original ideas (like providing properties for Java classes and hot class reloading) through techniques that required a relatively Play-specific runtime environment. Play 2.0, on the other hand, takes a more standardized approach to runtime deployment. This was made possible partly by writing the core framework in Scala and also by building on top of SBT, the popular build tool for Scala. Play 2.0 delivers the same simple “play new, run, start” experience as the 1.x series, while standing on a more extensible foundation. Play 2.0 comes with a preconfigured build script that will work unmodified for most, but if you need to change the way your application is built and deployed, you have the ability to customize and adapt it as needed. As a result, you’ll find it even more straightforward to deploy Play 2.0 applications in a wider variety of scenarios. Pick and Choose
Because web application design has evolved a lot in the last few years, Play 2.0 features a modular architecture that helps to avoid making hard assumptions about your technology stack. You do not want to use a database? You can disable the DBPlugin. Want to use your own templating engine? Just plug it in. Do not need a full featured web framework with all the bells and whistles? Use Play as a library. How much of the architecture you want to use in your application is entirely up to you.
Play is based on a lightweight, stateless, web-friendly architecture that features predictable and minimal resource consumption (in terms of CPU, memory, threads) for highly-scalable applications. This is partly thanks to Akka 2.0, the event-driven middleware at the heart of Play 2.0. Developers also have direct access to the many additional features Akka provides, to build highly distributed systems that can scale to meet any level of demand.
One of the recent trends in web app development is the emphasis on push-based and non-blocking technologies. Play 2.0 uses an Iteratee IO implementation to provide out-of-the-box support for many advanced push-based/streaming technologies, from WebSockets and Comet to file streaming.