Recent Posts
Archives

Posts Tagged ‘Typesafe’

PostHeaderIcon [DevoxxFR2013] Play Framework vs. Grails Smackdown: A Head-to-Head Comparison Through Real-World Development

Lecturers

James Ward is a professional software developer since 1997, currently at AWS, dedicated to helping teams build effective applications. With experience across mountains of code and literal peaks, he shares discoveries through presentations, blogs, and demos. Previously a Technical Evangelist at Adobe and Typesafe, he focuses on scalable, reactive systems.

Matt Raible is a Java Champion and Developer Advocate, renowned for building web apps since the web’s dawn. Founder of AppFuse, author of Spring Live, and committer on Apache Roller and Struts, he has spoken globally on open-source adoption. His roles span UI Architect at LinkedIn, Evite.com, Time Warner Cable, and Oracle, emphasizing practical, performant solutions.

Abstract

James Ward and Matt Raible pit Play Framework against Grails in a comparative showdown, building identical “UberTracks” apps to evaluate productivity, performance, and ecosystem. Through lines of code, deployment simplicity, and scalability benchmarks, they dissect strengths: Grails’ convention-driven ORM versus Play’s reactive, stateless design. The session weighs server-side rendering, JavaScript integration, and backward compatibility, offering developers empirical guidance for framework choice in modern JVM web development.

Origins of the Smackdown: Hype Meets Hands-On Evaluation

Ward and Raible conceived this comparison amid hype surrounding full-stack JVM frameworks. Grails, leveraging Groovy’s conciseness, had dominated rapid development; Play, with Scala/Java options, promised superior performance and reactivity.

They built UberTracks—a music tracking app with user registration, OAuth, search, and social features—to benchmark real-world scenarios. This neutral app avoids framework biases, focusing on core web tasks.

Productivity Showdown: Lines of Code and Development Velocity

Grails shines in CRUD generation via scaffolding, minimizing boilerplate. Raible’s version clocked fewer lines overall, thanks to Groovy’s syntax sugar.

Play demands explicit controllers and views but excels in hot-reloading and type safety. Ward’s iteration emphasized Play’s compile-time checks, reducing runtime errors.

Both support rapid prototyping: Grails with grails generate-all, Play with activator new. Deployment to Heroku proved seamless for both, though Play’s statelessness eased scaling.

Performance and Scalability: Throughput Under Load

Benchmarks favored Play: higher requests/second in JMeter tests, lower memory footprint. Grails’ Hibernate sessions introduce state, complicating clustering; Play’s Akka integration enables reactive, non-blocking I/O.

Raible noted Grails’ plugin ecosystem for caching (Ehcache) mitigates issues, but Play’s built-in async support provides edge in high-concurrency scenarios.

Ecosystem and Community: Plugins, Documentation, and Job Market

Grails boasts 900+ plugins, covering security (Spring Security), search (ElasticSearch), and social (Spring Social). Documentation is exemplary, with books and tutorials abound.

Play’s ecosystem grows rapidly, emphasizing modularity via Typesafe Stack. Ward highlighted reactive manifesto alignment, fostering microservices.

Job trends show Grails’ maturity but Play’s ascent, particularly in startups.

JavaScript Integration and Modern Web Patterns

Both frameworks accommodate AngularJS or Backbone for SPAs. Raible’s Grails app used Grails-Asset-Pipeline for minification; Ward’s Play version leveraged WebJars.

Server-side templating—GSP in Grails, Twirl in Play—handles SEO-friendly rendering. Play’s JSON APIs pair naturally with client-side MV*.

Backward Compatibility and Maintenance Realities

AppFuse’s history informed this: Grails maintains smooth upgrades; Play 2.0 broke from 1.x, but migration guides exist. Raible praised Grails’ semantic versioning; Ward noted Play’s evolution prioritizes performance.

Conclusion: Contextual Winners in a Diverse Landscape

Raible and Ward conclude neither dominates universally. Grails suits data-heavy enterprise apps; Play excels in reactive, scalable services. Developers should prototype both, weighing team skills and requirements. The smackdown underscores JVM’s web strength, with both frameworks advancing the field.

Links:

PostHeaderIcon [DevoxxBE2012] Rapid Application Development with Play 2

Peter Hausel, a core team member of the Play Framework and software engineer at Typesafe, demonstrated the efficiencies of Play 2 for swift web development in both Java and Scala. With a background in web technologies and open source, Peter showcased how Play streamlines workflows, emphasizing live coding to illustrate its features.

He initiated by creating a new Java-based application, highlighting Play’s MVC structure: controllers for logic, views for Scala-based templates, and routes for URL mapping. Peter noted that even Java projects use Scala templates, which require minimal learning akin to JSP.

A key advantage is on-the-fly compilation; changes reload automatically without restarts, accelerating iterations. Peter modified a controller and template, refreshing the browser to see instant updates.

Type-safe templates and routes prevent runtime errors, with compile-time checks ensuring correctness. He integrated front-end tools like CoffeeScript, LESS, and Google Closure Compiler, compiling them seamlessly into production assets.

Peter explored asset management, using RequireJS for modular JavaScript, and reverse routing to generate URLs dynamically, avoiding hardcoding.

For production, he packaged the app into a distributable ZIP, running it standalone. He peeked into running applications via REPL for interactive debugging.

Testing was touched upon, with future scaffolding promised to generate tests easily.

Peter’s demo underscored Play’s design for productivity, blending familiarity with powerful abstractions.

Core Structure and Development Workflow

Peter detailed Play’s layout: app folder houses controllers, views, and assets; conf holds configurations and routes. Routes define HTTP methods, paths, and controllers, supporting parameters for dynamic handling.

In live coding, he added a new route and controller method, demonstrating error handling where compilation failures display directly in the browser, guiding fixes.

Templates use Scala syntax for logic, with type safety catching mismatches early. Peter included layouts via @main, composing reusable structures.

Front-End Integration and Asset Handling

Play compiles CoffeeScript and LESS on-the-fly, minifying with Closure for optimization. Peter added a CoffeeScript file, seeing it transform into JavaScript.

RequireJS integration modularizes scripts, with routes serving them efficiently.

Deployment and Advanced Features

Packaging creates self-contained distributions, runnable via commands. REPL allows inspecting live state.

Peter recapped: routes centralize mapping, auto-reload speeds development, and reverse routing enhances maintainability.

His session positioned Play as a tool for rapid, robust applications.

Links: