Lately I find myself in a position where I’m not sure what I want to learn next and what will be usefull for me career wise. This weekend I wanted to check out the play framework. A scala framework which supports coding in both scala and java.
I used to work with java for many year but I wanted something else since I wasn’t enjoying the ecosystem. I will not get into details on that, java is great as language but there are a lot of applications out there which is nightmare to work with…
The play command is replaced my an amazing tool called activator. What stunned me was the web based ide it loads out of the box to work with the code. All you need to run is “activator ui” and the following web ide loads.. ![activator ui]({{ site.url }}/assets/media/activator-ui.png)
As first what I’ve found quite enjoyable is that the directory and code structure is not that much different of symfony framework, on which I’m quite proficient.
A symfony controller… {% highlight php %} namespace AppBundle\Controller;
use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HelloController extends Controller { public function indexAction($name) { return new Response(’
Hello ‘.$name.’!’); } } {% endhighlight %}A play controller {% highlight java %} package controllers;
import play.; import play.mvc.;
import views.html.*;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Your new application is ready."));
}
} {% endhighlight %}
To me the actuall code is literally the same…(I don’t like annotations for defining routing, I prefer separate files) The directory structure is also quite easy to get it and work with. I had to issues playing with the settings, the routes etc…
What really impressed be, as I mentioned at the start, is activator. Apart from web ide, as long as you start service the app it gets automatically re-compiled and loaded on every change!!! This was something that drove me to php a few years ago since hot-deploying the jar after the compilation on tomcat was a pain in the arse and tomcat needed restart after few hot deployes.
With activator you can also create a jar out of your app, rpm and deb packages of your application and also a super handy zip file containing all the proper dependencies and an executable to fire up you application. In theory all you need is the zip file and a reverse proxy setting on your webserver to go!!
Activator uses sbt as build tool so I suppose a lot of those goodies comes from sbt but activator makes them really easy to handle for the developer side!!
Play is a super modern framework build on Akka and I would definitelly like to work with it in the near future!
Cheers