From a couple of presentations I watched and reading online, nodejs advertises that it makes writing web servers easy. Do everyday programmers actually need node or is it meant to be a niche language?
Yes and no, I've spent the last two weeks building and launching a node.js project and it's really really fast.
Blazingly so.
I've got a PHP project at http://fstr.net and its pageloads take about 4 to 5 seconds under normal load. With my other project pageloads are less than a second most of the time (though there seems to be some variability when dealing with the first connection).
Both projects do essentially the same thing (query database, present list). It's really shocking just how much faster node.js is.
Another nice aspect of NODE with a MongoDB solution is that I can scale it very easily. On AWS I can send all traffic into a load balancer, then as the server's load increases I can just fire up additional (CLONE) instances and add them to the load balancer.
A reserved Amazon micro instance costs ~$5 per month or a 'high CPU' instance comes in at $17. Scaling node is really as easy as turning on another machine (or running multiple instances of the application on a machine with multiple cores).
Compare the performance of almost anything to PHP and you're going to be delighted.
Yes, the V8 engine is fast. That's what it's designed for. But that's only remarkable because it's a JavaScript engine. You can get the same performance from Go (with better memory utilization to boot) or even Java.
> I've got a PHP project at http://fstr.net and its pageloads take about 4 to 5 seconds under normal load.
Whatever language you are using, if loading a page takes >1 second, you are doing something very wrong.
I have built web apps out of shell scripts that perform hundreds of forks and open dozens of files per request, and still easily managed <200ms response times while running on a crappy xen server.
>I have built web apps out of shell scripts that perform hundreds of forks and open dozens of files per request, and still easily managed <200ms response times while running on a crappy xen server.
You're probably very right there. FSTR could definitely be 'tuned' to be faster, but since this one and the other have all other things held constant in terms of programmer skill, then doesn't it come down to the language?
I mean if I'm doing something wrong in PHP, then I'll likely make the same mistakes in node.
You are right though, PHP+apache can be just as fast as anything else. I'm told that apache has a lot of overhead because of all the modules that come enabled by default. Apparently by removing all but what you need, you get a system that's a lot faster.
That's a bit more advanced though - while node's quick by default.
Anyways, I'm far from a language zealot in any way. I've loved every language that I've worked in.
I'd love t see some of the stuff you're talking about that's lightning fast with hundreds of forks... sounds like something I could learn from :)
I clicked through and the site feels quite fast in comparison to a lot of other similar sites. It's the external social media stuff that takes ages to load.
Anyway, I think we all want to know more about those forking web apps you've made. They sound quite impressive.
it's not a language at all. it's a library for writing server-side code in javascript. it's event driven, like python's twisted. in fact, it's hard (if you assume people are rational [edit: and have perfect access to information]) to see why people find nodejs so cool, yet have been ignoring twisted for years.
I think it was a combination of things. One, the timing was nice because JavaScript was getting more and more attention as its engines were starting to seriously compete for speed. Two, I think the fact that it was JavaScript on the server really helped get it a lot of buzz as it was somewhat "controversial". "Controversial" because I can't think of another language whose users are so split between liking and hating it. Having it invade the server meant a lot of people's blood began to boil as they thought of having to potentially deal with it outside the browser, and a lot of other people who were excited about being able to use it outside the browser. Either way, the combination of love and hate gathered a lot of talk and attention in my opinion.
Now to contrast this with python: I personally have never heard of Twisted before all the talk of Node came about. Mind you, I'm not a python developer and if someone's blog title doesn't grab my attention by having some connection to me, or what I do, I'll probably just skip over it.
twisted - "A completely different set of batteries included."
I have deployed services using both twisted and node - some off the cuff points:
- Twisted is large, and includes many new concepts and vocabulary, with somewhat patchy documentation. There is a big hump to climb over before being productive. I was pretty much there with node on one 35 minute train ride.
- The twisted async. mantra only flies within the (albeit large) twisted cloud of classes. I often find myself deferring to threads etc. for synchronous file IO etc.
- Writing plugins for node is very approachable (including things that interact with the event loop). I use ctypes + .so for the same work in python land, but it took some experimentation and discovery (albeit not very difficult) to arrive at a good pattern for this.
Once you understand it - twisted is an enormously powerful resource, and I am still writing complex services using it. Node gets used for wrapping up computation services.
From my point of view, it's down to a combination of good marketing and 'right place at the right time'.
I've never heard of twisted - but I feel like I'm getting in on the ground floor with node. Additionally, I was positively salivating to learn a new language when it started 'emerging'.
I think part of it comes down to the fact that I was already very comfortable with Javascript, so I started with node.js knowing that I at least knew some of the basics ... and thank got I did, because programming in node is very different from what I'm used to.
It's sometimes difficult to know which lines of code are blocking and which aren't.
Blazingly so.
I've got a PHP project at http://fstr.net and its pageloads take about 4 to 5 seconds under normal load. With my other project pageloads are less than a second most of the time (though there seems to be some variability when dealing with the first connection).
Both projects do essentially the same thing (query database, present list). It's really shocking just how much faster node.js is.
Another nice aspect of NODE with a MongoDB solution is that I can scale it very easily. On AWS I can send all traffic into a load balancer, then as the server's load increases I can just fire up additional (CLONE) instances and add them to the load balancer.
A reserved Amazon micro instance costs ~$5 per month or a 'high CPU' instance comes in at $17. Scaling node is really as easy as turning on another machine (or running multiple instances of the application on a machine with multiple cores).