Is this the time for JavaScript

I was wondering if there were any decent benchmarks of the V8 Javascript engine and I found this:

http://shootout.alioth.debian.org/u32/javascript.php

Does this mean Javascript is one of the baskets we should put our eggs in, now that Apache has left the JCP and we don't know what Oracle has in store for Java ?

I've been toying with the idea of having a stateful web framework written in Javascript. Imagine Lift but written in Javascript.
A view first approach where the snippets use jQuery selectors to bind to the XHTML nodes and where the framework "magically" divides the function calls into server/client code (it's all javascript isn't it).

Wouldn't it be nice to be able to do:

function myForm() {  
  $("#button").onclick = function () { 
    alert("You clicked on a button ... now i'll work my magic ;)"); // This is client side stuff so it goes with the final page 
    // Here we must create a server call 
    fs.readFile('/etc/passwd', function (err, data) { 
      if (!err) 
        $("#result").append(data); // And back to the client 
    }); 
 }
}


If you look at Lift they're pretty close to this but they use a JavaScript DSL which I'm not really fond of. I really think this could be pulled off and what I feel is the best thing about the concept is the "magical" division of server/client code.
We could make it explicit initially but it should be like a JIT for the web where the optimizations are done in runtime with clever distribution of the load between the server and its clients.

 

Go vs Scala vs NodeJS

These test are run with:

ab -c 100 -n 50000 http://localhost:8000/

The memory usage is analyzed with : pmap $PID | tail -1 >> mem.txt; SLEEP 0.001

  Req/s Mem  
Go 9428.90 ~18.5M  
NodeJS 5775.84 ~646M  
Java(Netty) 7086.34 ~2 434M (No flags)
" 6931.62 ~512M (-server -Xmx128m -XX:+UseConcMarkSweepGC)
" 9682.42 ~577M (after a couple of runs for JIT warmup )

Conclusion ?

The mem test takes into account all the libraries loaded by the process as this seemed to be the fairest comparison.

The Java version might be doing a bit more than the the others since it was an experience I had here... Without explicit JVM flags it gets very memory hungry and I bet that a -server flag without memory restrictions would be a huge mem hog. Fortunately the last tests show that with a memory usage similar to NodeJS's it does a whole lot better (I'm happy cause I can keep using Scala instead of Javascript :P)

NodeJS has a lot of hype around it and it definetly deserves it but without the web workers support it is not capable of taking full advantage of several cores and you'd have to go with a local pool and a load balancer in front of it. It's memory usage is not the best.

Finally Google's Go is surely the big winner here. With very little memory usage and good performance it is the undisputed champion. Also, I'm using the 6g compiler but have read somewhere that gccgo could bring a 50% improvement. The language's not great but it sure beats C, C++ and even Java in my book ;)