JavaScript Servers Compared
snydeq writes "InfoWorld's Peter Wayner test-drives five leading JavaScript servers and finds the results compelling though still a work-in-progress. 'I enjoyed the challenge and stimulation of rethinking everything I know about the server, but I still found myself hesitant to push these new ideas too far or too fast. The speed of experimentation and development is heady and exciting to the open source crowd, but it will probably seem scary to corporate developers who like the long, stable lives of tools from Microsoft or Oracle. Some of these platforms will probably morph three or four times over the next few years, something that won't happen to the good, old JSP standard in the Java world,' Wayner writes in review of Node.js, Jaxer, EJScript, RingoJS, and AppengineJS."
Second post! Would've been first if slashdot had a faster javascript server.
Third post! Would've been first if slashdot had a faster javascript server.
First post! Good thing slashdot has a fast javascript server.
Burn the bible
Or, i dunno... maybe we could use JavaScript to add flexible dynamic scripting to our existing stable Java platforms? ...otherwise what's the point? To use a domain specific language for tasks it wasn't designed for or is very good at?
Personally, I'd rather use a slow dynamic scripting language to glue the fast compiled language code together, (see: Perl), not write the whole damn server in slow JS.
Hint: Just use Rino and be done with this nonsense.
Read the print version of the article in one page:
http://www.infoworld.com/print/161969
+1 Funny Signature
To use a domain specific language for tasks it wasn't designed for or is very good at?
JavaScript works very well as something it wasnt designed for every time you use GMail, Meebo or any other application that's running within the browser these days.
Remember when javascript had a terrible rep? Then people were all like, "No! It's totally awesome! It has first-class functions and prototypal inheritance!" Yeah, you remember. You read all the blogs. You had flashbacks to your not-so-pleasant encounters with javascript while developing client-side web applications. Then, all the sudden, prototypal inheritance became the in-thing, like popped collars. No matter how ugly or ridiculous it looked, you didn't want to be the only one who didn't think it was cool. You started writing gobs of hard to organize, impossible to refactor serverside javascript code. You convinced yourself, somehow, that you saved time by not having to issue some "compile" command. No, it just starts, DYNAMICALLY! What a cool word, dynamic -- like Ugg boots! And like wearing Ugg boots in the summertime, you tortured yourself searching for simple runtime errors. Static checking? Compiling? These are the things of white-collared enterprise folks.
You are not a white collared enterprise guy. You are a renegade. With a popped-collar. And ugg boots.
Similes are like metaphors
Personally, I'd rather use a slow dynamic scripting language to glue the fast compiled language code together, (see: Perl), not write the whole damn server in slow JS.
That is the whole idea. Write processor intensive tasks in a fast compiled language (C or whatever) and glue them with a server that is good at handling asynchronous requests. That's what Node.js is about and JavaScript is actually a good fit for it because of closures.
While we're at it, the JavaScript engines are all single-threaded per server? So you get no benefit from having multiple cores or multiple CPUs in your server? What a colossal train wreck of a design.
Check out my sci-fi/humor trilogy at PatriotsBooks.
Except that JavaScript, today, is not a slow dynamic scripting language. The latest JS engines in IE 9, FF 4, and Chrome are lightning fast. You'll be hard pressed to find a faster dynamically typed scripting language today. Honestly, if you want a fast, dynamically typed, interpreted scripting language, then look no further than JS. Also Rhino IS slow (compared to most other JS interpreters) and has been included with Java by default since Java 6.
wow, how is JavaScript on the server side new?
anyone remember the Netscape FastTrack server, and the LiveWire environment, where LiveScript was used to code both server & client side of a web application. LiveScript being of course the original name of JavaScript. this was back in 1996, merely 15 years ago...
history seems to repeat itself...
We used to call it "SSJS" -- server-side Javascript. Times really have not changed, but why would you expect them to? Despite the superficial changes, the underlying structure of the Internet and the Web has not really changed. We have not really seen much in the way of "revolution" in the past 15 years, just incremental changes (or if you would prefer, "improvements") to the way everything works.
Palm trees and 8
That should be solved in the next version of the Linux kernel which allows you to run multiple processes _per machine_. Think of it! "Multitasking" is the future!
Just the tip of the fudberg: - States 2MB for each Java thread created (WTF... Where did they pull this number? Isn't the default stack size for each thread 512KB?)
Default is 512k, yes. But there are some extra details: 'Java stack size myths'
Oh god! that's why you have such projects as multi-node. If you bothered to figure it out for yourself you might realise why single threaded apps can be good in the right situation.
"I'm increasingly convinced this asynchronous callback style of programming is too difficult for most developers to manage," Robinson said. "Without extreme discipline it can easily lead to 'callback hell,' with deeply nested callbacks and complex code to implement logic that would be simple on a synchronous platform." What's next for him? He sees the older framework being rethought and reworked using the best ideas from Node.js. In place of callbacks, he sees ideas like "promises," "co-routines," "actors," and other objects that hang on to the information in the variables for use later. These objects may be easier to juggle than the callbacks.
Callbacks and promises are not mutually exclusive. In particular, a promise API can be built on top of callbacks. This has been well-understood for a long time in both the Ajax world (e.g. dojo.Deferred), and in Node.js development (e.g. node-promise module by Kris Zyp). So, I think this critique is a bit unwarranted.
We do remember it. Probably because it was the first line of the article.
Or .jsp, which has been around for quite a long time.
history seems to repeat itself...
This.
Don't worry - I'm pretty sure that, 10 years down the line, they'll be touting the addition of static typing to JavaScript as the next big thing to improve productivity etc.
Yes, generally "The default thread stack size varies with JVM, OS and environment variables. A typical value is 512k". However one approach is to have a single thread and use that more efficiently. Nothing wrong with that. NodeJS along with nginx can solve the C10K problem out of the box, Tomcat can be tuned to deal with more than 10K concurrent connections, but eventually your multi threaded app *could* eat up all you memory.
Not really. 15 years is a long time in technology.
Too bad that chrome's V8 javascript engine does not support multithreading, thereby making itself unsuitable for server-side scripting.
(Of course, you can run each script in a separate process, but that is way too expensive)
If Pandora's box is destined to be opened, *I* want to be the one to open it.
really it's not changed. I'd think about that again? Where have you been?
Why wasn't it designed for those applications? It's a general purpose programming language. Perhaps the browser's APIs (DOM) weren't designed with those applications in mind, but even the first standardization of the DOM (DOM Level 1) APIs could implement most if not all of those applications' features, one way or another (eg. submitting forms to a frame—a feature introduced with JavaScript in Netscape 2—and periodically appending new scripts which contain server data).
There's a lot of reasons that those kinds of applications didn't appear until later, but they could have been made much sooner. But poor standards support in browsers made interoperability a nightmare, slow client hardware made performance questionable, and ultimately poor understanding of JavaScript and the DOM delayed serious uptake among developers for about a decade.
It seems the author of the article knows little about how real servers use multithreading to reduce latency.
From the article:
Node.js is one good solution. It uses only one thread for your server and everything runs within it. When the requests come flying in, Node.js takes them one at a time and hands them to the single function that was specified when the server is invoked.
Sadly, one of the best javascript engines is V8 (used in google chrome), and it does not support multithreading.
If Pandora's box is destined to be opened, *I* want to be the one to open it.
Node is working on adopting Web Workers, but it already has the ability to spawn new processes.
The article made it sound like you have one instance of a JavaScript server that runs as part of your web server (Apache, presumably) and all JavaScript requests get funneled into a handler, all within a single thread. Apparently, that's not the case. Thus further emphasizing the point that the article doesn't describe things too well. :-)
Check out my sci-fi/humor trilogy at PatriotsBooks.
What like when they added closure support for Java. Yawn!
hmm, maybe thats why the google applications are actually compiled into javascript instead of being written in it
No idea why this was posted anonymously.
+1 Profoundly Fucking Insightful
The Javascript engines in browsers come nowhere close to the runtimes for the mainstream server-side platforms (J2EE, .NET, etc) in performance. It's not always orders of magnitude difference anymore, but one of those runtimes will still reliably be several times faster than the fastest JS engines.
Yup mod parent up.
Hi. We (I'm a google employee) have GWT, which compiles java to javascript, but we don't actually use it much. Most projects I'm aware use Javascript written as javascript. We do use build scripts to pre-process, include dependencies, and minimize/obfuscate, though.
I said the underlying structure has not changed much, but that there have been superficial changes. Can you please point out where the underlying structure of the Internet or the Web has undergone a significant change? When last I checked, we are still using IPv4 and we are still using HTTP, and we are still using a client-server model. This most significant change that I can think of is AJAX, and that is not a terribly significant change (it really just means that things people would have done in an applet can now be done by the browser itself).
Yes, things look a lot different now, and we are making more sophisticated use of the underlying technology (sometimes), but for the most part we are still talking about the same system.
Palm trees and 8
I've been intrigued by this whole serverside js thing since i started doing a lot of flex and therefore using actionscript a lot. :)
Callbacks are so cool
But thing is js is still a mess if you have a lot of code.
What we really need is server side actionscript to get proper OO syntax, strong typing and namespaces.
If i ever got that, i'd be a happy camper !
While we're at it, the JavaScript engines are all single-threaded per server? So you get no benefit from having multiple cores or multiple CPUs in your server? What a colossal train wreck of a design.
Fire up a different process per core and route each request through a load balancer. Alternatively use web workers to service the requests with the main thread acting as the conductor which spins them up and services common functionality.
uhm, thats pretty much EXACTLY what Javascript was intended for ... you do know where it came from ... right?
Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
Your definition of 'lightning fast' is my definition of 'painfully slow language' even in the new JS engines.
Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
In terms of numerical computation? Probably. In terms of actual useful web applications, Node.js meets or beats compiled Java in the benchmarks that I've seen, even with the Java Code using esoteric and not commonly used behaviours like Non-Blocking IO: http://www.subbu.org/blog/2011/03/nodejs-vs-play-for-front-end-apps
V8 is actually really damn fast.
jsp is java, not javascript, which is entirely different other than the name.
Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
Yes the underlying structure is much the same. But our paradigms have changed a lot. The early web was request response, with very little focus on the client at all. That's changed, there is now far more parity between what happens on the server and client. This is only going to increase. The point is this, if you have a common language (Javascript) that fits the web, very, very well and you have browser vendors implementing features in HTML5 that encourage distributed, real time apps. Together with improvements in HTTP1.1 (which is really one of the main drivers). Then you have a web that in reality looks nothing like the one we had 15 years ago. What I don't understand if the fear people seem to exhibit with stuff like this. There is absolutely nothing wrong with a modern implementation of server side Javascript. There is nothing wrong with single threaded apps, there is also nothing wrong with multi-threaded. Single threaded systems can have certain qualities that perhaps multi-threaded apps don't. They certainly use resources in a much more effective way. We don't need multi threaded-ness everywhere. These are tools. Use them. Technology changes, embrace that.
You could use JScript in ASP too. Thankfully I never had to.
Dilbert RSS feed
I assume you write all your web apps in machine code then?
Ah,
It meant I didn't have to bother learning VB in order to write ASP Pages, and it looked a lot closer to the PHP, C and Java I was used to writing.
Err... <%@ Language=Javascript%>
I prefer my webservers to run purely on ASICs. Sure, updating the web site is a little costly, but I can handle more traffic than Amazon.
Honestly, if you want a fast, dynamically typed, interpreted scripting language, then look no further than JS.
Honestly? Well, honestly, the more code I write/debug in dynamically-typed interpreted languages, the more I like statically-typed compiled languages (and it has nothing to do with execution speed)
I'm about 8 years out of date on my web development, but can someone give me a quick rundown on the subject of the article vs. what I know as server side javascript, aka ASP classic?
Karma: Can only be portioned out by the Cosmos.
PHP is also single-threaded per server; PHP doesn't jive well with multithreading. So what we get is mpm_prefork with one instance of mod_php per process, or alternatively, a web server using fastcgi that spawns multiple PHP processes.
they are supposed to add statically typed closure you insensitive claud !
Jehovah be praised, Oracle was not selected
My favourite language, by far, is Scala, so don't think I don't know where you are coming from. And, honestly, my favourite dynamic language is Python, though I am using JS on occasion now.
Nobody would.
Javascript is adequate. I am never going to complain that Javascript somehow keeps me from doing my job. I can do anything in Javascript. I have bigger fish to fry and the need to occasionally write Javascript doesn't make the list of my "real" problems.
But Javascript sucks. It is wrong. I would rather program in PHP (!) than Javascript. (Maybe even perl? Well, no. I would rather program in Javascript than perl.) But anyway: Classes. Prototypes are lame. Anyone who starts a new project involving Javascript in any situation other than running in a web browser, is totally fucked in the head. Someone has so many choices and they pick Javascript? Please. Yes, it can function as a general-purpose programming language, but it's not one, and it is very sad that the world is possibly going to be forever burdened by it.
Damn you, Netscape. You may end up being a longer-lasting plague than Microsoft.
As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
I guess it wasn't obvious, but I was comparing JS to other dynamically typed scripting languages. I'm also talking in respect to tasks that scripting languages usually tackle. If JS is painfully slow for you, I'm just assuming you are using it for something you probably shouldn't be using ANY scripting language for.
The bottleneck on a dynamic webserver is either network or SQL access times. It does not matter if you have the fastest web server software in assembly when it takes 1,000 ms to access a SQL query to display for a client's browser.
Static it is a different story, but who besides a small mom pop page uses simply static pages anymore? So this is why Java took off a decade ago while slashdotters scratched their head wondering why could something so slow and slugish could ever scale. It is about SQL
http://saveie6.com/
Guess what.
The leading proponent of all 5 Javascript Server projects is....Intel!
Sleep your way to a whiter smile...date a dentist!
You can't make method calls. You can communicate via explicit message passing, like a Unix pipeline. That's why we have bidirectional sockets.
I can throw myself at the ground, and miss.
multi-node. The above is not an issue. Also get Apache out of the mix as this will become the next bottle neck. Use something like Nginx that's an evented web server unlike Apache
Thank you.
what just like Java was originally designed for set top boxes and fridges? Oak. anyone, anyone?
Since we seem to be comparing JS to Java, it's worth noting that server-side java frameworks such as EJB discourage or even forbid explicit thread creation, arguing that "the container" is much better at managing concurrency and lifecycle than the average JavaEE code-monkey.
... optimized animated .gif server so ytmnd.com could load 5GB loops faster.
I8-D
- It has idiosyncracies, but several orders of magnitude fewer than PHP.
- It is standardized and has multiple, F/OSS implementations
- Its syntax has much less line noise
- It probably has the fastest implementations of all scripting languages; last time I checked (might have changed) the only contender was LUA-jit or something.
- The various implementations are thoroughly stress tested in browsers by something like a billion users.
- Similarly the high stakes in browser securities guarantee that there is a strong incentive for security and more generally code quality compared to other scripting languages.