Book Image

Learning Play! Framework 2

By : Andy Petrella
Book Image

Learning Play! Framework 2

By: Andy Petrella

Overview of this book

<p>The Learning Play! Framework 2 has been created for web developers that are building web applications. The core idea is to focus on the HTTP features and to enable them through a simplification lens. Building a web application no longer requires a configuration phase, an environment setup, or a long development lifecycle - it's integrated!<br /><br />Learning Play! Framework 2 will enable any web developers to create amazing web applications taking advantage of the coolest features. It's the fastest way to dive into Play!, focusing on the capabilities by using them in a sample application. Although essentially Java based code, a Scala version is presented as well – giving an opportunity to see some Scala in action.<br /><br />After setting up the machine and learning some Scala, you will construct an application which builds from static to dynamic, before introducing a database. <br /><br />Then we'll focus on how data can be consumed and rendered in several ways. This will enable some real time communication through WebSocket and Server-Sent Event – on both server and client sides.</p> <p>The book will end with testing and deployment, which completes any web development project.</p>
Table of Contents (20 chapters)
Learning Play! Framework 2
Credits
About the Author
Acknowledgement
About the Reviewers
www.packtpub.com
Preface
Materials
Index

Why do we need Play! Framework?


The first thing to understand and to keep in mind while using Play! Framework 2 is that it is a pure and full-stack web framework on the JVM. Creating web applications using cutting-edge technologies is its first purpose, and it is the best at it. It is the best as it gives developers a great and positive experience while creating web applications. This experience comes with the fresh and neat vision that Play! Framework has on how web development should be done.

The most appreciated feature from the developer's perspective is the short overhead between the code session and the result in a web page, which is near to zero, thanks to the hot reloading of any source files and the compilation errors shown in the browser.

Framework for the Web

This new framework has been built by taking some references from the Web world and its success stories. Some of them are Ruby on Rails or Django in Python. They bring to the JVM some facilities that aim at simplification of the work; for instance, eliminating the boilerplates necessary to set up a development environment around the framework.

Indeed, its full-stack approach means everything is prepared for us—all we need is already there. Not that we're forced to use everything or we cannot swap a library for another, but it's just that without specific actions and efforts by the web developer, we don't have to do anything else but simply install the framework and start working. And it's on the JVM—that means we have all the tools from one of the biggest communities out there to help us in our daily work.

In short, Play! Framework 2 is the fastest way to create amazing applications that make usage of all new features brought by the Web. Thus, it's also the best way to show these new features!

Not JEE-based, but JVM

We have to mention that Play! 1 didn't follow the JEE specifications and abstractions, and there are no reasons to have Play! 2 follow them either. Where most of the abstractions in J2EE, at some point, eased the developer's work, nowadays they are constraining him/her with what was foreseen years ago. But the Web is evolving so fast, with needs that are completely different than were half a decade ago or so.

For instance, every year HTML5 has better support, and this specification along with the Web is including many new features that help in building applications very easily and in an integrated way. Examples are WebSockets, caching control, security headers or metadata, and so on. While these features have to be enabled in JEE, they haven't been hidden in Play! 2.

Learning from the past, where the first version supported the Scala language through a plugin, this new version has been built upon Scala from the beginning. Because Scala and the functional paradigm fit very well with highly-concurrent applications, like a web framework should be, they both helped a lot for Play! 2 to be a highly-reactive web framework.

However, even if Scala is gaining in reputation, the Java community with its tooling and its amazing set of libraries, and also its "quasi-omnipresence" still has a place of choice; that's why a Java-specific and adapted API is there for us. This might enable a developer to mostly ignore the Scala language itself, apart from the templating and build system.