Play with Java and Scala Web Apps

Posted by feydr | Posted in Uncategorized | Posted on 27-04-2010

View Comments

I got wind of the play framework a couple of months ago and have been passively reading their mailing list each day. I have to say — it’s very active and the framework is just top notch. We here at telematter have used a lot of the frameworks in ruby land and our main app is written in merb. Lately though merb has become a ghost-town of support, documentation, and community involvement. Upgrading a server takes an exorbinant amount of time, patience and the willingness NOT to throw you computer through the window.

Dependencies are a big problem here but so are the tests. With the ruby community’s ever so crushing pride about various ways to accomplish a task you usually wind up having to either pick between the options of using a LOT of plugins/dependencies or not using any. Also, you know you have problems when after spending the better part of a morning upgrading your dev environment you can’t run your tests.



So we started looking at different web application frameworks. We have a rather large existing codebase in java already to do some text parsing but xml config files and the ever-growing concern of java developers to deal with encapsulation in the most fucked up manner imaginable leads us having java with a sour taste in our mouths. Scala on the other hand has been what I have deemed “what java SHOULD have been”. Seriously, that language is so elegant compared to it’s predecessor that they should just scrap everything and move on from that point forward. The JVM is really solid shit but java itself — ehh…

Anyways on to the meat of this quick article. Why do I like play?

  • class reloading
  • easy setup
  • fucking awesome test runner
  • great documentation && active community
  • NO xml config files
  • use with scala

Class Reloading

Do I even need to explain this one? Having the ability to reload your classes on the fly without having to go through configuration hell is so ridiculously helpful it’s insane. Your development productivity will gain leaps and bounds and with integrated auto-testing you are assured a winner.

Easy Setup

It does not get easier than a:

wget http://download.playframework.org/releases/play-1.0.2.1.zip
unzip play*
sudo cp -R play* /usr/bin/play
play new my_new_app
play run

Fucking Awesome Test Runner

I need to attach these screenshots to show you the awesomeness of this.

Test Index


play framework test index

Selenium Test Runner


play framework selenium test

Great Documentation && Active Community

When you first boot up Play (and it boots FAST) you will find that you have all the basics to start hacking up the HelloWorld into whatever you wish. A simple click of the mouse gives you your environment settings (which show you everything from paths to thread info, to monitors). Play also has a cool little route built in http://127.0.0.1:9000/@documentation that has screencasts, sample apps, faqs, and pretty much everything you need to know to start playing around.

Admittedly there were only 12 users online in IRC earlier today when I wrote it but the mailing list has ~30 emails/day with active development/discussion.

NO XML Config Files

Yes, that’s right ladies and gentlemen — no goddamn config files written in fucking XML. WTF! Your main config file, application.conf is just your basic java properties set — no need to get all crazy and declare everything under the sun.

What’s the routes look like?

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
 
# Home page
GET     /                                       Application.index
 
# Map static resources from the /app/public folder to the /public path
GET     /public/                                staticDir:public
 
# Catch all
*       /{controller}/{action}                  {controller}.{action}

yeh….. they are that simple looking

Use with Scala

There is a scala module that I highly recommend you download and use — oh and if you like scala — you can get on the akka bandwagon as well. It’s also highly recommended.

Do yourself a favor and Play Now!