Keep the JVM, dump the rest (Scala+Play+MongoDB)
by havoc
I decided to try three new things at once and get back into some server-side development.
- Scala uses the JVM for the hard work, but feels more like Ruby or Python. It’s statically-typed, but for the most part infers types rather than making you type them in.
- Play ignores the Tomcat/J2EE legacy in favor of a more modern approach — “just press reload” to see changes.
- MongoDB dodges the ORM problem by storing objects in the first place. People like JSON, so the database should store JSON. Done!
I was curious whether I could lose all traces of Enterprise Readiness and use the JVM with a nice language, a nice web framework, and no annoying SQL/ORM gunge.
TL;DR Answer: Promising, but lots of rough edges.
Some disjointed thoughts follow.
Books
Before starting, I read Programming in Scala and MongoDB: The Definitive Guide. Also the free Programming Scala but I would recommend the Odersky book instead.
I like Scala a lot.
If you aren’t familiar with it, Scala is a pragmatic language design.
- it compiles to Java bytecode and runs on the JVM. Thus, no headaches for operations team, no need to port it to new architectures, quality JIT and GC, etc. A Scala app looks like a regular Java jar/war/ear/*ar.
- you can use any existing Java library from Scala with no special effort, just import it.
- it’s statically typed, but sophisticated generics and type inference keep the code looking clean and concise.
- it supports both functional and OO styles, sanely mixing the two.
- it has multiple inheritance (mixin traits) that works properly, thanks to linearization.
- it has a basket of features that save typing, such as pattern matching and automatically creating accessors for fields.
- language features give you ways to avoid Java’s preprocessor/reflection/codegen hacks (think aspect-oriented programming, dependency injection, Kilim, and other extralinguistic hacks)
While C# fixes Java by adding a bunch of features but keeping a pretty similar language design, Scala fixes Java by trying to bring the conciseness and fun people find in Ruby, Python, Haskell, or whatever onto the JVM.
There’s a popular controversy about whether Scala is too complex, and just reading about it I had the same fear.
- I found I could get a web app working without hitting any complexity hiccups. You don’t have to design a DSL or understand variance annotations to write a web app.
- I didn’t get any mystery error messages of the kind I used to get all the time in the early days of C++.
- I’m not sure it’s more complex than Java if you include the usual stack of extralinguistic hacks in Java, and I doubt Scala is a larger language than C#.
Scala’s Option type wasn’t very helpful.
Scala has thing called Option, which I believe Haskell calls a Maybe type. It’s a container that contains a single value or else nothing. While Scala has null (for Java compatibility), Scala encourages the use of Option instead to clearly indicate in the type system whether a value can be missing.
In a web app, this was often used to check whether data store lookups returned anything. And in most cases I wanted to show an error page if not, accomplished in Play by returning a special object from the controller method.
While I’ve read posts such as this one, I couldn’t find a great pattern for using Option in this context. It was leaking up the call stack like a checked exception (code using an Option value had to return another Option value and all the way up). I found myself wanting to do:
val foo = maybeFoo.getOrThrow(WebErrorPageException(“whatever”))
then I wanted the framework to globally catch that (unchecked) exception and show an error page. For all I know Play has such an exception. You can unconditionally Option.get, but that will turn up as an internal server error, which isn’t nice.
Without using exceptions, Option tended to produce nested if() (or pattern match) goo just like null, or creep up into calling functions like a checked exception.
Play itself is very polished, but Play with Scala is not.
Play’s big win, which you get with Scala too, is to bring “just press reload” development to the JVM. You change either code or templates, then go to your browser and test. There’s no pressing build or even waiting for Eclipse to build, and there’s no creating a war file and deploying it.
Play brings other niceties, using convention rather than configuration (in the Rails style). Its template engine is much nicer than JSP/JSF/etc. ugliness, and you get quick and easy mapping from URLs to controller methods. If you’ve used Rails or Django or whatever Play will feel pretty normal. But this normal is a prettier picture than the traditional Tomcat/JSP/blah setup.
Originally, Play was for Java only. The Scala support is marked experimental, and I hit some issues such as:
- The docs are spotty and sort of outdated.
- The docs talk about using JPA (Hibernate) with Scala, but Googling around I learned it’s broken and not recommended. Some of Play’s magic convenience is lost if you aren’t using Play’s database and ORM. I started out trying to use JPA with SQL, but when I learned I’d be manually doing DB stuff anyhow, I switched to MongoDB.
- Some bug in the MongoDB driver makes it break if you also use Joda Time.
- The template engine sometimes couldn’t find object fields from superclasses (my guess, I haven’t tested yet, is that adding @BeanProperty would work around this).
- File upload support only works via a temporary file (a File object) and not streaming.
- Some hacky-feeling conversion from Scala to Java collections/iterators was sometimes needed for the benefit of the template engine.
Little bugs aside, I did get a simple app working and I enjoyed it a lot more than writing in Java.
The stack isn’t nonblocking by default as node.js is.
Play supports suspending an HTTP request and returning to it later, without tying up a thread. Scala, especially in combination with Akka, offers some nice primitives for concurrency while avoiding shared state.
node.js gets huge mileage because the core platform defines what the “main loop” looks like and has primitives for a nonblocking file descriptor watch, nonblocking timeout, and so on. All libraries and modules then work within this framework.
In theory, Play and Akka would let you do the same thing, but since it isn’t the default, you’re going to suffer. You would have to manually write little stub controller methods that always suspended the request and forwarded it to an actor. And your persistence layer probably has a blocking API (such as MongoDB’s blocking API) that would need another bunch of glue code and a thread or actor pool to encapsulate. It’s even an issue, though a simple one, that Akka doesn’t come with Play or Scala, and the Play module for it seems to be well behind the latest Akka version.
I suspect that in a real-world project, you’d start finding blocking IO all over the place, hidden in every third-party jar you tried to use.
It would be great if I could write an actor, annotate it as a controller, and it would receive web request messages and send back web reply messages. Similarly, it would be great if there were a MongoDB-via-actors kind of nonblocking API.
Play’s philosophy is that most controller methods should block because they should be fast; this is likely true, but it’d be nice if the framework overengineered it for me. BTW, here’s a comparison of Play and Node.js.
(I can’t decide whether I like the idea of this Play/Scala/JVM stack or node.js more. I think I like both. The simplicity of node.js, the nonblockingness, and the same language from client to server, make it appealing. But sometimes I like the idea of JVM solidity, the full-featured statically-typed loveliness of Scala, and the giant ecosystem of Java tools and libraries.)
Eclipse support isn’t great yet.
I’ve heard the Scala plugin for Eclipse was recently improved, and honestly I’m not sure whether I have the important improvements in the version I’m using. But it was not great.
- I had an error “class scala.annotation.implicitNotFound not found” that just wouldn’t go away, though it seemed harmless. Suspect that it’s some version mismatch.
- Perhaps because Scala is less verbose and redundant than Java, it’s much easier to get the editor confused about your code.
- Autocomplete/intellisense/whatever-you-call-it rarely worked, the IDE didn’t seem to know what methods my variables had most of the time.
- Refactorings and code generation shortcuts you’d be used to from Java weren’t there (though they were also far less necessary).
All this said, with Play and Scala you’d be fine with an editor instead of an IDE. Working autocomplete would be nice, though.
MongoDB is the Right Thing.
I love MongoDB (disclaimer: I haven’t deployed it, only coded to it). From a development perspective, it’s exactly what I want.
If everyone wants objects anyway, and in particular they want objects with JavaScript’s type system since they’re eventually going to display in a browser (or use node.js), then the data store should freaking store objects! Figure it out for me.
If the data store’s native representation matches the form I really want my data in, then it should (at least eventually) be able to store and query that data intelligently. JPA/Hibernate is a very, very leaky abstraction. I don’t need part of the storage engine inside my app, trying to convert what I really want into SQL. Then the SQL engine has to optimize without high-level information.
As far as I know, MongoDB is the “NoSQL” thing that adapts to how my app works, instead of vice versa. Nice.
Overall
There’s a lot of promise here, but if I were building a real app on this stack, I’d be tempted to hack on the stack itself a fair bit (always dangerous!). Play defaults to Java+SQL, and Scala+MongoDB isn’t the well-traveled path.
Disclaimer: I’ve done a lot of Java in the old school Tomcat/JSP/Hibernate style, but Scala, Play, and MongoDB are new to me. Your corrections and elaborations in the comments are very welcome.
So if I read this right then the title should be “Keep the JVM and the libraries, dump the language”. Hard to argue with that.
(And a quibble — dependency injection is neither a hack nor necessarily extralinguistic.)
well, dump the language and the J2EE-ish stuff that’s aged poorly compared to newer web frameworks.
the Java way to do injection is annotations discovered by the container via reflection, right (post java 1.5 anyway)
Scala would allow that, but an alternative is to mix in the deps as traits. One or both of the books I linked discusses it.
I’ve read a couple of books on Scala, but I’m finding myself more intrigued by Clojure than Scala so far.
If Scala can do dynamic class redefinition / exec style evaluation, yay.
getOrThrow basically already exists:
val foo = maybeFoo.getOrElse(throw new WebErrorPageException(“whatever”))
Of course, you could define an implicit conversion yourself, if you wanted, but I think getOrElse is plenty good here.
(getOrElse usually provides an alternative value to be used if the Option is None, but since throw is an expression in Scala, you’re golden.)
nice! thanks for the tip.
Also, if you find yourself with lots of crazy nested Option types, take a look at using a “for”. It can really clean it up.
For example, if you have something like:
val foo: Option[A] = getFoo()
val bar: Option[B] = foo match {
case None => None
case Some(b) => Some(getBar(b))
}
val baz: Option[C] = bar match {
case None => None
case Some(c) => Some(getBaz(c))
}
then it can be rewritten as:
val baz = for {
foo <- getFoo()
bar <- getBar(foo)
baz <- getBaz(bar)
} yield baz
and if you would just like to do something to the value in an Option, or do nothing if it's None, then you can use the map and foreach methods. For example, Some(x).map(f) is the same as Some(f(x)) and None.map(f) is just None. Viewing Option as a collection type that has only zero or one element really makes it a huge step up over lots of manual null checks.
We did a very similar experiment internally recently except using Lift for the UI. The lack of a non-blocking impl wan’t that much of a problem for us as it was extremely fast (Mongo kicks arse, and we had it in journalled mode).
Second a lot of your findings, although I don’t find the Option at all as annoying as you seem to, and there’s always Either for errors.
I’ll be interested in other UI options as well such as unfiltered:
http://unfiltered.lessis.me/
to be clear, I don’t necessarily find Option annoying, I just wasn’t feeling like I had a good pattern for dealing with it. probably should have left that tangent out.
in several cases, if the function had just returned null I probably would have forgotten to check for it…
You *want* Option to “leak” into the calling functions, all the way up to the point where you have a sensible way to handle it. You don’t want to turn it into an exception and throw it; that defeats the purpose of using it.
kinda sounds like a checked exception 😉
I have mixed feelings on this. I appreciate Option “making” me handle null, and would probably have missed some nulls otherwise. On the other hand, it felt like there were a lot of lines of code dedicated to dealing with null query results, so I don’t think I had the right pattern for using it.
I think all error handling mechanisms have the potential to be either annoying or to be ignored dangerously. (I’ve posted about that at http://stackoverflow.com/questions/3701995/better-language-feature-than-exception-handling-in-c/3702346#3702346 before.)
There is such a thing as Option overuse (http://stackoverflow.com/questions/1332574/common-programming-mistakes-for-scala-developers-to-avoid/4238744#4238744) in Scala, and you should be on the lookout for this. On the other hand, learning the best patterns for dealing with Options isn’t something you learn on your first day in Scala, and if you can talk to an experienced Scala programmer, he may be able to walk through your code with you to help you find better patterns for dealing with Options. (We commenters may also be able to help you, but I don’t know whether you’re interested in sharing the code that you’re talking about in this blog post.)
I wonder if my issue here was mostly domain-specific. Since to show an error page with Play you need to return something from the controller method, and it’s sort of inconvenient to do that from a couple layers down in the call stack when you realize a query returned no results.
Regarding the Eclipse plugin, the first beta of the improved version from Scala Solutions was released this Monday, March 28. So I believe you were still working with the old one before that. The errors you were reporting look like things that have been fixed now.
Thanks, I’ll try out the new one.
Hi,
In terms of IDEs, IntelliJ IDEA CE with the Scala plugin is your best bet at the moment. However, a lot of work is going into the Eclipse plugin:
http://www.scala-ide.org/2011/03/scala-ide-beta-1-available/
http://www.scala-ide.org/2011/03/the-next-development-phase-for-the-scala-ide-for-eclipse/
It probably needs a month or three to compete with IDEA.
Regarding your comment about nested ifs when dealing with Option, that should not happen with proper usage. In general, map/flatMap/getOrElse/foreach (or for comprehensions that rely on many of those methods) should be good enough for the majority of cases.
Best,
Ismael
Intellij 10 (there’s a free version) has better support for Scala than Eclipse does.
If you like mongodb, it’s also worth taking a look at couchdb as well. The areas they’re useful for differ slightly
– mongo’s has a query system, where as in couch you only do map/reduce.
– couch replicates brilliantly – if you wanted to do offline storage, couch would be the way to go.
– mongo has a more traditional design, so fits better if you have a 3 tier design already.
http://www.ocastalabs.com/2011/03/some-observations-on-mongodb-couchdb/ is a good read on that.
Awesome blog post. Using Play since 1.0 and always wanted to switch to Scala, but the lack of proper tool support, and the fact that the Scala-plugin is pretty much a separate framework with its own API is too much of a turn-off for me.
The main thing holding me back right now is Hibernate. And maybe part of the form-object-binding, because my many2many relationships are too crazy for it to handle.
Re the option type. This feature is essentially a monad, so use it as such and don’t try to get around it with nested ifs – that’s why we have monads in the first place, they’re designed to replace nested ifs.
ctrl+f monad. Yes, this is exactly the design patten you’ll want.
Note that when these folks say “monad”, they mean that it has map, flatMap, etc defined, and can be used either with those methods directly or in a for expression.
If you have more time for experimenting then check https://github.com/asual/summer/tree/master/samples/scala
It’s another way of doing Scala web development on top of the Spring Framework ecosystem. The HTML templates can be reloaded but for the rest you’ll need something like JRebel. The sample includes a nice JPA integration but unfortunately the library still lacks good documentation.
Hacker News thread for those who prefer to comment on there: http://news.ycombinator.com/item?id=2384922
If you want to keep the JVM and dump the rest, what about going one step further and dumping the JVM too?
It seems like you dislike torture (Java, J2EE, Hibernate, etc) and went for a little less torture. Just get rid of it! There are so many options that just work for web development and that let you do it right. I’m currently using Python, Flask with SQLAlchemy but there are some other nice solutions that are not based on the JVM.
You started to remove the crust, don’t stop now 🙂
I do sort of like static type safety in a language, and the JVM has quite nice JIT and GC, and tons of libraries available.
But as I said, I’m torn – node.js is nice too, even though it’s the complete opposite thing …
And of course Python and Ruby aren’t bad.
I don’t quite understand why people say Scala is good. IMO, when I read the syntax, it’s so confusing and inconsistent. e.g. All other languages you put type in front of variable name, then default value. Non-statically type languages are the same except for the type they put var or def. Scala? def degree : int = 0
But when creating class or object, you do the regular way, define and then class name: class Celcius{…}
Why?
besides, non-statically type languages put var in front, it’s just because it doesn’t have a type so it tells the compiler to declare this as variable. But then once you have var or int or double in front of a variable name, that line is self explanatory. In Scala, you have to put both def and int. What’s the point of that???? Weird syntax.
I agree the post-variable-name type is less familiar to most people.
However, the Scala syntax does have some nice virtues. The big one I think is that it’s pretty good about “don’t repeat yourself,” and you don’t usually have to write the type at all. Overall you end up without a lot of clutter to look at.
Thanks Havoc.
But isn’t the example I wrote that you have to write everywhere in the code since it’s the basic an example of “Repeat Yourself”?
def degree : int = 0
def and int are a repeat 🙂
The “: int” part is optional because it can be inferred from “= 0”; def vs. var vs. val change the meaning, so they are not redundant. At least, that’s my understanding.
I’m sure Scala makes you repeat yourself sometimes, but far less than Java for sure.
You’re definitely right on the def/var/val thing.
def degree = 0 creates a zero-argument method that always returns 0. val degree = 0 creates an immutable field set to 0. var degree = 0 creates a mutable field set to 0.
The big difference between the def and the val comes when subclassing. The contract for a val is that it’s always the same – therefore, you have to override it with another val to create a subtype. However, the contract for a def says no such thing, so it can be overridden by many more things.
Scala is much like ActionScript 3 when defining variables; I thought it was weird at first but after a while you get used to it.
I expect to see this more as AS3 ideas bleed back into ECMAScript.
var name : String = “joe”
works in both Scala and AS3, and once you learn it it more natural than
String name = “joe”;
You are right; the syntax is a little unorthodox, but you shouldn’t judge Scala solely on that. As havoc replied to you earlier, the “: int” is optional, most of the time it’s left out.
Syntax is easy to learn, just take your time and you’ll get the hang of it 🙂
Did you try using option.map or option.flatmap?
Probably not competently. I did mess around with them.
One question is whether there’s a better way to 1) strip out all None from a list and then 2) pull the Option off, besides the sort of obvious way:
someOptions filter { _ != None } map { _.get }
Welcome to Scala version 2.9.0.RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_25-ea).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Seq(Some(1), None, Some(2), Some(3), None).flatten
res1: Seq[Int] = List(1, 2, 3)
Hope that helps,
Ismael
I did try that and I guess it’s the general answer. The problem I get is:
scala/src/library/scala/collection/Iterator.scala has flatten in it (maybe my source tree doesn’t match what I’m using, or that isn’t the same Iterator here, not sure what’s going on)
What version of Scala are you using? It works for me:
scala> Seq(Some(1), None, Some(2), Some(3), None).iterator.flatten
res6: Iterator[Int] = non-empty iterator
Ismael
2.8. wondering if mongo gave me a Java iterator or something. I’ll poke at it.
If that turns out to be the case, you can solve it easily by importing scala.collection.JavaConversions._
Iterators in Scala are kind of funky. They’re not a part of the standard collection hierarchy, so lots of the collection stuff doesn’t work on them. You can try calling toStream on the iterator, which will give you a collection that works in a similar way (for example, still only generating the Posts one at a time).
It could also be that you have a Java Iterator…
If you want the first Some from a sequence of Options, you can use the following (amongst the other alternatives). It returns an Option, because there may be no Somes in the sequence, but you can just call get() on the restult if you are sure there is one:
val firstValue = someOptions find {_.isDefined}
Hi Josh and Havoc,
The Option type is subtle, but after a few months of scala development you find that you haven’t seen a NullPointerException for as long as you can remember, and suddenly the profundity of it becomes apparent. I find the nicest way to use it is with for expressions:
for (p <- person; a <- p.address) yield a.zip
will yield a None if either person is None, or person.address is None, or address.zip is None, otherwise it will yield a zip code.
One way that helps to understand Option is that is is somewhat like a collection that has at most one (typed) element. That way you can either have an empty collection, or a collection with a single thing in it. I think the for expression is a little more clear if you think about it in those terms.
Also, if you have a mix of Some(x) and None in a collection, calling flatten will eliminate the Nones, and give you back a list of the contents of the Somes.
That's just a couple of idiomatic ways to deal with Option types other than pattern matching.
By the way, the for expression example will yield a zip code wrapped in a Some if it can (the alternative to None is always Some in an option type – wasn’t sure if that was clear in the example above).
“(disclaimer: I haven’t deployed it, only coded to it)”
This is, basically, where your post goes wrong. Ideally, in theory, deployment of a data-store for POJOs would be like the perfect implementation of MongoDB, and you’d get unicorns and rainbows when you did a deployment.
The reality is way, way different.
There’s a reason that Hibernate works so well, even though it’s a massive mess of code on the back end to serialize and deserialize your objects. It all comes down to Java’s (and, really, Scala’s) strong typing. You want to know what happens when you use a client library to access MongoDB and you decide to add or modify a field? The ever-so-fun ClassCastException. That doesn’t go away in Scala. With Hibernate, and the new JPA annotations, rolling out changes to your schema is really, really easy.
As for the Play framework… it seems really, really, _really_ rough. It looks like they took some bits from Struts2, and some bits from RESTEasy (which, in my opinion, is the single greatest framework produced in the past five years) and decided to make them _harder_ to use. There’s a configuration file that you have to edit — a la the old struts-config.xml — only it seems like there’s less information in there, and oh by the way, Struts2 solved all this by using annotations; I haven’t written a struts-config.xml in a long time.
The requirement that methods are static voids, and the view content type being based upon the view template filename seems really, really, really hack-y to me. The interceptors aren’t as refined as RESTEasy’s. The view syntax seems arbitrary, because oh no, we can’t support JSTL, that would be wrong!
I mean, if one of the main bullet points is “you don’t have to wait for Tomcat to hot redeploy your app”, I don’t get it…
Overall I’m sure you’re right that writing a real app and deploying it would reveal lots of warts not found in my toy app experiment.
I don’t claim to be an expert in the domain, my post is more of a “what happens if you try this and aren’t an expert” kind of exercise. Notes on first impressions if you will.
I spent around 2006-2008 working with JBoss/Hibernate/JSP on non-toy stuff, and thought it was pretty gratuitously painful. What I don’t know is what happened to that stack in the last couple years. I thought I’d try this trendy new stuff first.
re: waiting for redeploy, several years ago, the issue was basically that ant took forever to build the .war (once the app was big), and then it took a long time to deploy a big .war. There’s also just the issue of having to compile (push the build or deploy button), while Play provides the illusion that there’s no compile step. It shows errors right in the browser if the compile fails.
It seems minor but in my experience, time to see a change you just made is kind of a huge deal. It’s a big reason people use Python or Ruby or JavaScript.
Doesn’t Eclipse/Tomcat integration try to make this smooth? It’s probably pretty good by now. I haven’t tried it lately, last time I did it was flaky.
An unfortunate thing is that Play does still have to compile stuff. While you can just press reload, the reload is slower than it would be in an actual scripting language.
re: Play, I think a lot of the appeal is that it’s smaller, and all-in-one. Developers are willing to accept a lot of rough edges or slightly-less-goodness in exchange for simplicity. Play is going to get you going in 5 minutes, it creates the project tree for you, the technology choices are all made in advance, the docs are all in one place.
re: MongoDB schema changes, I was manually writing code to convert the JSON documents to Scala objects rather than using a thing like Morphia, so any schema changes I would have had to handle by hand. i.e. I didn’t get a sense of how the libraries would do it or not do it.
Here’s what I think though: surely if one were designing both data store and Java API from scratch, nobody would do it as Hibernate+SQL. You’d communicate the object-oriented representation directly to the storage engine, and then the storage engine should be able to work in those terms.
I have to believe that over time, a data store that natively stores objects, has to be possible to make better than a data store that doesn’t – assuming that apps are written to an object-based API.
At the same time, of course MongoDB isn’t as mature today. But disruptive technologies are always worse in a lot of ways at first.
I don’t know yet whether MongoDB is “mature enough” for a given app, but I gather there are real-world production projects using it.
“I spent around 2006–2008 working with JBoss/Hibernate/JSP on non-toy stuff, and thought it was pretty gratuitously painful.”
JSP is essentially dead– there’s no reason to use JSP at all, ever, when doing Java development. All our new development is done using JSF and Seam, which make connecting your POJOs/EJBs to the view layer about as painless as you can imagine.
Take a look at IntelliJ for your IDE. You can do class injection, and JBoss (or Tomcat, or Resin, or whatever you use) can run inside the IDE container, so you can inject classes on the fly, which causes for very fast build turnaround time. Also, take a look at RESTEasy, it’s an amazing way to annotate and deal with REST endpoints without the crazy overhead that Play seems to provide.
And last, the issue of POJO serialization, I don’t think you’re ever going to get away from that; there’s always going to be a need to have a data layer that you don’t necessarily access from your application. Think of a gigantic data warehouse that people are querying from multitudes of applications, some of which may not be Java/Scala/what have you. Without some sort of sane serialization (eg, Hibernate to SQL) it’s essentially impossible for outside applications to look at and query your data. Sending the objects to Mongo doesn’t change the fact that there will necessarily need to be some overhead to serialize and deserialize those objects from the database.
we were using tags, not “raw” jsp, to be clear. no code in templates.
JSF we tried but it was really bad back then; it conflicted with consumer web app UI expectations. for example it had terrible user visible messages for validation problems that could not be overridden, and no “Ajax awareness”
agree there’s always pojo but the “impedance mismatch” can vary.
will look at resteasy and intellij, btw, thanks for pointers
hi havoc,
could you pls tell me, what exactly does play use jboss netty for, if processing of request is still blocking?
ps: i know, that the built-in play-server is netty-based. What i want to know with the question is, does the play-server have any advantage of using netty (NIO framework)?
While the processing of requests is still blocking, and when one wants non-blocking processing, it must be implemented manually with the SUSPEND/CONTINUE API. I dont see any advantages of using netty therefor.
I’m not sure. you can do nonblocking “manually” though. seems like a question best answered by the Play developers.
You should also take a look at Erjang, an Erlang implementation on the JVM.
For REST services on top of Akka, you might try Spray – https://github.com/spray/spray/wiki
looks really nice, was thinking along those lines. now want an Akka async encapsulation of Mongo, glue Spray to a template engine, package it all up
with deployment/logging/etc. figured out, etc. it could be a sweet web platform.
[…] unos días comentando en cierta comunidad hablando de cierta entrada en el blog de Havoc Pennington; encontramos una discusión interesante, la primer respuesta de […]