the blog for developers

Playing with Play Framework for Java

Recently I’ve been playing more seriously with the Play-Framework. Play is a newer rapid development web stack for developing web applications. My impressions in short: this is a very nicely framework for write applications, with much potential but which is at the very beginning. This means there aren’t awfully many features available (compare with Lift, also a recent framework for Scala on the JVM).

Good parts

The good parts I’ve found are:

  1. Java (JVM) based
  2. Aims for fun for developers
  3. Fast turnaround, automatically reloads Java classes, templates etc. which is one of the main gripes I have with Java, as stated in my “Java dead?” post:

    Rapid development and rapid turnaround. Java still falls flat, even with JRebel which allows seamless reloading of classes, RAD web frameworks like Wicket and splendid IDEs. Rails, Django and PHP are better and have a faster turn around. Period. Java is lacking here, and reloading changes look to be the biggest problem with Java development today.

  4. Real world developer oriented, not power oriented or hacker oriented. For example errors are shown in a nice way with the corresponding code in the browser.
  5. Error handling in Play

  6. Interesting modules available (Guice, Sass, GAE, OAuth), more Rails oriented than classic Java (which is a good thing!)
  7. No need to write getters and setters, they are automatically added. Another one of the gripes I have with Java
  8. Based on JPA, but other persistence like Siena supported
  9. Scala possible (Shorter, even nicer). Downside: Not as nice integrated as Lift, e.g. Option usage in Lift, composable attributes for domain classes
  10. Integrates Unit, Functional and Selenium (often aceptance tests) tests in one web page. Different testing styles can be used, e.g. JUnit with asserts, JUnit with should, Spec style and more.
    class SpecStyle extends UnitTest
                          with FlatSpec
                          with ShouldMatchers {
    
      val name = "Hello World"
    
      "'Hello World'" should "not contain the X letter" in {
        name should not include ("X")
      }
    
      it should "have 11 chars" in {
        name should have length (11)
      }
    }
    

The things I don’t like so much

There were some parts during my playing around, which I didn’t like with Play:

  1. I would prefer the Lift (or StringTemplate) way of templating, with no code in templates (or the RIFE way)
  2. Not on the NoSQL bandwagon – NoSQL really is the future for some web apps I believe
  3. Wish it would use a build system, not for building, but for dependency managment, packaging etc (Gradle for example, or at least Maven).
  4. Not yet a big community, modules limited, high risk bet
  5. Minor one: Bazar? Wouldn’t have thought this is needed with Git and Mercurial, don’t want to learn a third competing DVCS

Overall an interesting new comer, which brings new ideas to the Java table. Definitely something to watch.

You can leave a Reply here. Of course, you should follow me on twitter here.

You can share this post!
Do you want to tell others about this article? Use the social bookmark icons to submit this artice to the service of your choice. Thanks.

About the author: Stephan Schmidt has more than 15 years of internet technology experience and 10 years experience in agile. He was head of development, consultant and CTO and is a speaker, author and blog writer. He specializes in organizing and optimizing software development helping companies by increasing productivity with lean software development and agile methodologies. Want to know more? All views are only his own.

1 Comment 49 Tweets

Leave a reply.

Comments

pk11

hi stephan,

1) there are a few templating solutions available at the moment:
- the standard groovy one
-scalate (ssp,scaml)
-japid

that means four options to choose from (if I add scala xml literals that means 5)

2) it provides support for siena and GAE. Both CRUD and Fixtures under refactoring in order to suppor new, NOSQL model types

3) the reason why you do not need a build system, because you just do not need to build/compile the project in the traditional java sense. Play compiles the classes for you, on the fly (unless you want to precompile for production in order to avoid the compilation warm-up hit at the first request).

Even though you can package applications as war files, the majority of the sites in production are not using a standard servlet container *at all*. They are just using play as the platform.

4) it’s a new framework, so yeah the community is not as big as for older frameworks but it is growing rapidly. not sure what you mean by limited modules. Considering other framework, play’s module repository is huge.

5) bazaar is only used for the core lib. Anything else is on github. This topic is coming up time to time. So hopefully it will be changed in the future.

HTH

pk11

(also, a git mirror can be found here
http://github.com/pk11/play-1.1-mirror )

@pk11: Thx for your explanations.

1) I know, but all the options seem to adhere to the same model, and none is to seperate markup and code as RIFE, SprintTemplate or Lift does, all are leaking as far as I can see

3) From my – limited – experience from running high traffic sites with several million users, I’d prefer to run apps in Tomcat or Jetty, as they are proven, can easily be monitored and their runtime behavior is well known, of course YMMV

4) We differ here, I wouldn’t call 21 huge ;-)

Thx about Git

pk11

hi stephan,

1) the templating thing is a matter of taste i guess. That said, somebody mentioned on the list that a “pure” templating solution is in the making.

3) When you launch a play app as a war, you are actually running the apache mina backend with a front servlet in front of it. That said, play is fast: a GAE app is starting up in 3 sec.

as for packaging/building: because play is using its own compiler+classloader, it is not so simple to integrate it into an existing build system. Also, because play is the platform (and most features are available as modules), you get most of the dependencies via modules or play itself (It actually rarely happens that you need to drop in a lib into your app).

The actual war packaging is simple though: play war

4) I guess it depends how you look at it: compared to rails plugins, 21 is a joke, however, compared to most java frameworks 21 is pretty impressive:)

thanks for your review

Daniel

Hi Stephan,

I wonder why you didn’t mention Grails in this article. In my opinion it’s the most promising and already widely accepted RAD framework there is for Java today. Plus, it’s based on Spring/Hibernate (even acquired by SpringSource recently) which makes it a serious solution for even enterprise requirements.

Cheers,
Daniel

P.S.: Although this is my first comment, I enjoy reading your blog for a while now :-)

bran

Not sure why you’re religious about total separation of logic from presentation.

The whole web programming is about mixing data with presentation. Total separation is artificial. New constructs and extra logic (binding) are required to maintain the separation, just for the purpose of separation, not exactly agile and pragmatic.

Of course the extra binding and runtime resolution won’t help with the performance either.

IMHO.

Japid author

Sakuraba

1) I agree, templates should not be allowed to invoke methods. In my mind, templates should only be allowed to access predefined values out of some “Context”/HashMap/whatever. But I guess the current solution is the pragmatic one.

3) I guess that is just because Play uses python to run things. The upside is: a lot faster startup times compared to using a JVM-based build-solution.

Lets face it, the JVM is not made for repeatedly running a simple command very often very quickly . I mean who needs Swing/Corba/etc when simply running a unit-test? I dont wanna wait 30 seconds for e.g. “grails run-app” to finish its work.

4) Not enough, thats true, but if Play core is successful, the plugin-flood will start sooner than later.

Hi pk11,

1) You might be right, though I assume a “pure” approach is safer, indepent of taste, but I might be wrong. Good to here someone works on one

3.) I didn’t wan’t to imply that Play is slow, but it is unknown. And – risk averse as I am ;-) I prefer slower but known solutions, to unknown unknown solutions

“(It actually rarely happens that you need to drop in a lib into your app).”

Again, YMMV, but from my – limited to some years – experience, you need usually lots of libs for a decent web site. Perhaps not twitter, but for a decent eCommerce site.

Packaging war: I’m used to packagings that drop several artifacts (several WARs) to deploy them as best as possible (thread insulation, swim lanes, etc. see Nygard)

4.) Compared to a Java framework which uses Maven, not so impressive ;-) (not to compare integrated modules in Play with libraries in Maven)

No need for thanks, my pleasure. Nice work, keep going.

@bran: I’m relegious because mixing a.) makes testing much harder b.) limits reuse and limits development speed c.) nails you to a web framework. And it’s not about mixing data and presentation, but logic and presentation.

Ruby.RO author ;-)

@Daniel: In which way should I have mentioned Grails? This was about Play, not about JVM RAD frameworks. Search this blog for my opinion on Grails, there are some here (but most from 2008 I assume).

For example: http://codemonkeyism.com/graeme-the-grails-bug-buster/

There should be some mention of some of my code (Radeox) in the Grails book even, and I’ve heard Radeox is still part of the Grails dist today (though I’m not sure why or if this is true).

bran

Hi Stephen,

I’m not in Ruby. Can you tell me what the RO is?

Now back to your arguments. Japid is a strongly typed template pre-processor that compiles templates to Java code.

1) Test: since the result is a plain Java class for each template, and it returns a string, one can even use jUnit to test it.

2) limit reuse: I don’t consider some simple ifs and loops in the presentation layer as business logic. They’re part of presentation logic. Business logic of course should go to the controller.

3) development speed. Not sure how total separation helps. As long as it’s DRY and straight forward, development is smooth. Usually it’s the extra binding stuff and indirection that costs development time.

4) Framework lock-in. Japid can be used standalone, just like Velocity, Freemarker, both allowing flow control in the templates. Locked in Java? Yes.

Leaking, if it means the templates can do too much, yes. This is an issue in a very strict environment. But usually the templates will go to the hands of the controller coder thus almost in the same security domain.

@Bren: RO was my try for a component based RAD web framework for Ruby some time before Rails came up.

Will take a deeper look at Japid.

Just about 4) If you put GUI logic and business logic into your web framework layer, your’re locked in. All logic should be in Java classes with no dependencies on a framework. That’s what a clear seperation enables, and weak seperation makes hard.

” But usually the templates will go to the hands of the controller coder thus almost in the same security domain.”

From my experience, if there is no speration, code and logic will leak into templates, they get hard to maintain and you’re locked in. At least this is what I have seen in every application as soon as the framework allows leaks.

@Bran: Took a look,

Perhaps it would be possible to configre Japid and disable features during runtime?

Things like

Scripts : %{…}%

pk11

Hi Stephan,

I put together a new module that lets you manage your dependencies:

http://www.playframework.org/modules/ivy-1.0/home

(ivy uses maven repos underneath, so now you can use any maven repos with play)

@pk11: Wow, would be nice if it works, will try it, had a lot of problems the last days kickstarting a website, with dependencies to dispatch, aop, … and missed the easyness of dependency kickstarting of Maven (Not that I love Maven otherwise) Thx

pk11

sure. let me know if you run into issues.

@pk11: Thx I will

Plus, bazaar is slow! We’re looking at Play and Lift at work, but will most likely go with Lift for the reasons you outline above.

Tempted to play with Play (ha!) and Compojure/Ring for my personal projects though.

@Michel: I will play with Play! some more time, might add a layer on top, learning from Lift (especially Option[] and Box[] will be useful)

opensas

Hi! It’s been a long time

In a couple of months, play! 1.2 should be released… It solves many of the things you didn’t like so much

There are now more than 50 modules, some of them gives you templates alternatives an other allows you to connect to nosql db

Among the new features you’ll find:

- A dependency manager, based on ivy

- Evolutions (something like rails migrations)

- New asynchronous features

It would be marvellous if you could have a look at it and make a review…

Oh, and play is now hosted on github

saludos

sas

Leave a Reply

What people wrote somewhere else:

RT @PritishNandy: Priya Ramani’s column yesterday in Mint. Enjoy. http://www.livemint.com/2010/03/19202137/An-open-letter-to-Raj-Quickgu

This comment was originally posted on Twitter

@mikado69は『Mでクーデレです。好きなプレイはロープを使ったへそ責め』です。 http://shindanmaker.com/4472 #hanage ちょwwwwwww

This comment was originally posted on Twitter

Followrama: A 1ª rede de Followers 2.0 do Brasil! A única que busca Followers automaticamente! http://tinyurl.com/yf3ud8f #Followrama 14

This comment was originally posted on Twitter

iFllw## New Media Makers Toolkit http://feedproxy.google.com/~r/WikinewsLatestNews/~3/GFFvLk7J3Lc/Severe_sandstorm_strikes_Beijing,_China

This comment was originally posted on Twitter

RT @StTitusofCrete: TKS @medli67 ~TKs #FF the words of @StTitusofCrete channeled by the late Judy Burkhammer. The e-Book of Truth- http://www.st-titus.com

This comment was originally posted on Twitter

Pink Floyd – Shine On You Crazy Diamond (parts VI-XI) http://twic.li/ieB

This comment was originally posted on Twitter

Blog: Latest Well Fargo Mortgage Auctions http://mortg.ag/e/2010/03/latest-well-fargo-mortgage-auctions-58/

This comment was originally posted on Twitter

Dadilja će od vašeg dragog sinčića stvoriti preljubnika http://tinyurl.com/yza3kz5

This comment was originally posted on Twitter

Кто нибудь пробовал тут знакомиться? http://goo.gl/O720

This comment was originally posted on Twitter

Want to see the pictures from the ASAP XV Summer Party in Boracay? Check out our multiply site… http://bit.ly/bO3g7T

This comment was originally posted on Twitter

McLaren evoluciona el MP4-25 para Australia y advierte que va “por buen camino” http://bit.ly/c9bBZU

This comment was originally posted on Twitter

What is the normal prescription for diflucan to treat thrush for a breastfeeding mom? http://bit.ly/97ai1a

This comment was originally posted on Twitter

http://twitpic.com/19z6hv – 5 star?

This comment was originally posted on Twitter

Q:udah ya asknya.. gw mau belajar nih A:oke thanks http://formspring.me/annisanabila/q/336554229

This comment was originally posted on Twitter

Sip deh kakak cantik (y) RT @restong: @gabybygab nanti yaa pas dikomputer http://myloc.me/53P9e

This comment was originally posted on Twitter

If you want more followers give this a try – http://cli.gs/4bv3se

This comment was originally posted on Twitter

New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4

This comment was originally posted on Twitter

RT @codemonkeyism New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

@codemonkeyism re: http://bit.ly/arkpg4 Biggest gripe is dependency management. Huge step backwards. Packaging isn’t so bad via ‘play war’.

This comment was originally posted on Twitter

Code Monkeyism: Playing with Play Framework for Java http://bit.ly/cYZWjg

This comment was originally posted on Twitter

Currently Browsing: http://is.gd/aTe1K

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

http://codemonkeyism.com/playing-play-framework-java/ playing with play framework !

This comment was originally posted on Twitter

“Playing with Play Framework for Java” /by @codemonkeyism http://bit.ly/arkpg4 #playframework #java

This comment was originally posted on Twitter

RT @playframework: RT @codemonkeyism New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

RT @rgaidot: “Playing with Play Framework for Java” /by @codemonkeyism http://bit.ly/arkpg4 #playframework #java

This comment was originally posted on Twitter

RT @codemonkeyism: New Blog Post: “Playing with Play Framework for #Java ” http://bit.ly/arkpg4 Please RT Thx

This comment was originally posted on Twitter

Neat and quick review about the @playframework: http://bit.ly/arkpg4 by @codemonkeyism

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: Playing with Play Framework for Java http://bit.ly/arkpg4

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: Playing with Play Framework for Java http://bit.ly/arkpg4

This comment was originally posted on Twitter

Playing with Play Framework for Java – http://su.pr/1XVAGg

This comment was originally posted on Twitter

[del] [from maleko] Code Monkeyism: Playing with Play Framework for Java: http://url4.eu/1xThL

This comment was originally posted on Twitter

Currently Browsing: http://tinyurl.com/y88veqf

This comment was originally posted on Twitter

Citim “Playing with #Play Framework for #Java”: http://codemonkeyism.com/playing-play-framework-java/ #programare

This comment was originally posted on Twitter

Playing with Play Framework for Java http://bit.ly/97AXpa

This comment was originally posted on Twitter

@pmorelli Already have – http://bit.ly/cv86LU – but will write another one with the experiences so far

This comment was originally posted on Twitter

Code Monkeyism: Playing with Play Framework for Java http://bit.ly/8YVRvZ

This comment was originally posted on Twitter

Great review. RT @codemonkeyism Playing with Play Framework for Java http://bit.ly/arkpg4 #yam

This comment was originally posted on Twitter

Additional comments powered by BackType

Guide to CodeMonkeyism

Over the last 4 years I wrote many articles on this blog. To make it easier for you to find the relevant ones, I've organized them into topics.

Top 10

6 reasons why my VC funded startup did fail

Go Ahead: Next Generation Java Programming Style

Java Interview questions: Write a String Reverser

The dark side of NoSQL

7 Bad Signs not to Work for a Software Company or Startup

Is Java dead?

Scala vs. Clojure

Never, never, never use String in Java

No future for functional programming in 2008 – Scala, F# and Nu

Clojure vs Scala, Part 2

Java Developer

Is Java Dead?

Go Ahead: Next Generation Java Programming Style

Be careful with magical code

All variables in Java must be final

Never, never, never use String in Java

Bending Java: More readable code with methods that do nothing?

NoSQL Guy

NoSQL: The Dawn of Polyglot Persistence

The dark side of NoSQL

Essential storage tradeoff: Simple Reads vs. Simple Writes

Sharding destroys the goals of your relational database

The unholy legacy of databases

Startup/CTO

Development Dream Teams

6 reasons why my VC funded startup did fail

American vs. European style of Software Development

12 Things to Reduce Your Lead Time and Time to Market

The high cost of overhead when working in parallel

Essential storage tradeoff: Simple Reads vs. Simple Writes

Job Seeker

Another Good (Java) Interview Question

7 Bad Signs not to Work for a Software Company or Startup

Java Interview questions: Write a String Reverser (and use Recursion!)

Java Interview questions: Multiple Inheritance

As a Manager: What I value in developers

Top 10 Tips (+1) to Get a Pay Raise

Agilist

What Developers Need to Know About Agile

5 Practices Better to Change in Your Scrum Implementation

Scrum is not about engineering practices

ScrumMaster and ZenMaster: The joke of certification

What is Trans-Scrum?