Why?Because I love to play, with Play 2.0 and scala (still learning).
But also because I'm currently investigating technologies that I might choose for a new product line currently building in my company, NextLab (in Belgium).
With ?This time, I've more played with client side libraries or frameworks (no I won't post yet another entry on JQuery...), but I also tried how it is easy to create totally async code (so parallelized) using server side ones.
The technologies that will be quickly introduced in this post can be found hereafter, but everything has been packaged in a github repo, and a running instance on Heroku.
At first the current spike was dedicated to the slowly growing Play 2.0's Neo4J REST plugin, we are creating at NextLab. But, in order to demonstrate what could be done with the coupling of these two technologies, I've extended the spike's scope to something more funny.
So let's introduce the technologies:
Even if it is neat, complete and well thought, Bootstrap comes with another handy factor... it has been built using LESS. And by chance (I know, chance is not part of the equation) LESS is supported by Play 2.0 by default.
Just a note, LESS will let you reuse color codes, mixins, etc etc that Bootstrap has already defined.
That's where Spine.js comes in the game. This lightweight MVC library brought me the small tools that I needed for fetching, saving resources without having to write not even a single request by hand...
Its functional approach of decoupling data from the document, and link them using layouts helps you to concentrate on each part of the data usage independently:
- the incoming/rought data mapping to a representative data
- the mapping from represented data to document (most of the time, one data for one element)
CommunicationThe communication layer is of course HTTP, with a little help from the emerging HTML5 features. One in particular, Server-Sent Events (here is a great intro).
This, stable, HTML5 feature comes with the handy functionality to let the server sent events to connected client, without hacks; that said Comet or Polling.
Open a connection, push data, and that ONLY when the server needs to.
Play 2.0 (Scala)Of course... But I used some "advanced" feature like,
AsyncAsync is a Play 2.0 feature that let the server deal with the tasks it has to schedule.
That is, when you think that the server might have to wait for actions being executed before being able to respond a request, Play 2.0 let you, really simply, create Async request (non blocking).
Very handy when you have to call third parties services for instance...
The only way I would consider from now to consume data. Iteratee is a fairly difficult thing to understand (read this wiki) but it gives you the same smart decomposition that in d3.js, that is, decoupling the management of a sources, its useful representation and its computed result.
Actually I needed, a request to launch async tasks (you know like event generation and dispatching)... so what else!
Within NextLab, we started a open sourced Play2.0 plugin for calling the REST api provided by a Neo4J Server (helpful on Heroku). It's still emerging, and continue to evolve a lot because features are implemented on the fly (need), and a re-pass is forecasted to add a meaningful DSL (like FaKod did).
Why do we make this choice to implement a distinct plugin instead of wrapping the java library?
- yet another library, which brings me too much (I need REST only)
- I want requests being async and under control
Libraries RepoSee below, we'll use Heroku. So in order to deploy this application wich uses our plugin, I needed to publish somewhere.
This is what can offer Cloudbees. Among other great things like git repo, CI and so on, Cloudbees provides you for free four maven repositories that you can make public if you wish.
So I used sbt to publish on my "snapshot" repo on cloudbees, letting heroky has access to it for downloading the plugin dependency.
Free, reliable, easy to use with scala and Play 2.0... which else than Heroku?
I think that this post is already too long... However, I can let you play with the resulting app here.
Check out the code (and fork it) there.
Depending on the comment, I will expand this post to other ones to respond potential demands (if there is any ^^).
Oh yes, one last note, the application is to Create Stuff which contains dummies. Stuff are created using a simple form that must be fulfilled. Stuffs can be linked one to another by clicking the graph.
Please create Stufs and links, it will be a good test for Neo4J, the plugin and Play 2.0.
Hope you've reach this.