Introducing Akka Cloud to Edge Continuum. Build once for the Cloud. Seamlessly deploy to the Edge - Read Blog
Support
play

Introducing Play 2.0

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 Support

While 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.

Introducing-play20-01

 

A Controller class using Java

Introducing-play20-02

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.

Console-big

 

Pushing Type Safety to a New Level

One benefit of using a statically-typed language for writing Play applications is that the compiler can check parts of your code for you. This is why Play 2.0 uses a Scala-based template engine as the default for Play applications - even for developers using Java as their main programming language. This doesn’t mean that you have to become a Scala expert to write templates in Play 2.0. But it’s there under the covers, working for your benefit.

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.

 

Compilation-error-big

 

Example route compilation failure detection

Playing Nicely

Play 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.

 

Play-releases

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.

Screen_shot_2012-02-20_at_12
Disabling plugins in conf/application.conf
Scales Up, Down, and Out with Akka
 
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.
Introducing-play20-03
In this example you can see how Calculator actor's result can be mapped to a Play result in a non-blocking fashion

 

Introducing-play20-04

 

In this example you can see how ChatRoomActor is sending messages in chunks to the client using Comet

 

Advanced IO and Stream Handling
 
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.

 

Introducing-play20-05

 

A scala controller that uses the built-in WebSockets support

Ready, Steady, Play!

Play 2.0 is the result of an invigorating collaboration between Typesafe (led by Peter Hausel), Play project founder Guillaume Bort, the Play community, and Zenexity, the web oriented architecture consultancy where Play was born. It’s been fun and exciting to work alongside such a talented group of software practitioners.

We’re excited to have Play seamlessly integrated into the Typesafe Stack, together with Scala, Akka, and the commercial support, maintenance, and deployment tools (like the new Typesafe Console) that make up the Typesafe Subscription. Typesafe also offers training courses and consulting for the new 2.0 release to get your team up to speed on Play framework quickly.

 

We believe Play 2.0 represents a watershed moment for the Java and Scala communities, delivering a breakthrough end-to-end web development experience that brings with it new levels of scalability and developer productivity. 

 

To get you started with Play 2.0, we’ve bundled several sample applications with the new release. So go Play, and decide for yourself. And have fun!

 

While you're here, don't miss our other recent posts introducing the Typesafe Stack 2.0, Akka 2.0, and the Typesafe Console.

The Total Economic Impact™
Of Lightbend Akka

  • 139% ROI
  • 50% to 75% faster time-to-market
  • 20x increase in developer throughput
  • <6 months Akka pays for itself