Esquire Theme by Matthew Buchanan
Social icons by Tim van Damme

18

Nov

Typesafe now supporting Play 2.0 Framework

The Play 2.0 framework is looking better and better everyday:

http://groups.google.com/group/play-framework/browse_thread/thread/6d5783e28efb6931#

I had blogged a while ago about “Does Java Have an answer to Node.js”. It looks like the best answer is Play 2.0. Play 2.0 uses all the technologies I mentioned in the previous post (netty, akka, scala). 

It also looks like Play 2.0 will be THE web framework for Scala. Yeah you could use:

  • Scalatra - Which just gives you routing
  • Lift - IMHO this framework is kind of dorky and reminds of Tapestry

But then again Play is using a more modern network libraries (Scalatra and Lift still rely mainly on 1 thread per request via servlet container) and is going to be supported by the people who came up with the language.

I wonder if Spring Source will come out with a Scala Spring Web Framework. They already have Groovy (Grails) and Java (Roo) .

20

Sep

Does Java have an answer to Node.js?

Java needs to do a couple of things easily to compete with Node.js which I believe will be the next killer web framework:

  1. Event Driven Network IO - Netty
  2. Threadless Concurrency - Akka
  3. More expressive language - Scala

Unlike Node.js most Java frameworks are not written from the ground up to be asynchronous. Most asynchronous behavior in Java is accomplished through threads. For example all compliant Servlet Containers create 1 thread per request.

Threading like this does not scale but it particularly does not scale for the future of long running concurrent connections like HttpPush and Websocket. I believe long running concurrent connections are the future of web development.

So how do we get rid of the 1-thread-per-request? Event Driven Network IO! There are two libraries that do Event network IO: Grizzly and Netty. Purportedly Netty is better but Grizzly is more backward compatible with existing technologies. Some of the containers including Tomcat 7.0, Jetty, and Glassfish or any Servlet 3.0 support Websockets/HttpPush but it is extremely unclear what the threading policy is not to mention its only for these special types of requests. Remember Node.js is asynchronous for all requests and Java should be able to do likewise.

Making the network IO event driven only fixes part of the problem. We need to make the rest of the platform asynchronous but with out using lots of threads. Akka is the only library that I know that does this well.

So what is missing? Well we cannot use any libraries that use Servlet API or ThreadLocals. That eliminates many frameworks. For example Spring uses ThreadLocal to manage transactions among other things. Jersey also relies on ThreadLocals.

There is a microframework called Deft that looks very impressive and the Play framework is also working on this problem. However I would like something that builds on top of Jersey like Atmosphere does and perhaps reuses parts of the Servlet API. Basically Java is missing what Express is to Nodejs. Unfortunately there are just not many asynchronous Web Framework (URL routing, binding) options for Java right now.

If I had time I would look into making a Servlet API adapter to Netty along with extending Jersey. That would be a fun little project.

11

May

Scala AppFuse?

I wanted to use Scala for http://evocatus.com but I couldn’t pick a framework that was easy enough to understand and mature enough. I also couldn’t get AspectJ to work nicely with Scala. So we ended up going with Spring Roo. This was in part because I like AspectJ and Spring.

That being said I still don’t like Java and prefer something like F# or Scala. I hate JSP(X) even more. However one of the things I like about Java and Python web application dev is that their are lots of options. There is a good discussion of this plethora of Java Web App lib mashups on SO.

For Scala its not as clear what the “mashup” options are.

There is the Lift framework which no offense to David Pollock feels kind of like David Pollock’s playground.

Then there is the Play framework which has excellent Scala support.

Both frameworks are pretty much start from scratch  in terms of methodology, frameworks, and libraries used. Play doesn’t even use a Servlet Container.

While this is nice and all I have 10 years of Java web dev knowledge that I can’t really apply to either of the frameworks. Sure a lot of what I know is crap (JSP and its bullshit comes to mind). But lots of it is good like the Springframework, AspectJ, JPA, JAX-RS, even Servlet filters.

So I’m on a quest to build my own Scala web stack:

  • JAX-RS or Spring MVC
  • JPA
  • Lots of Traits for where I used AspectJ
  • Scalata (kill JSP/Velocity/Freemarker).

Maybe Scala will have a Raible-like AppFuse?