Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm designing a web application that is locally focused on JSON objects to do all the data stuff (and after that I would pass it to a server to cloud synchronize). However, somebody in an answer from another question suggested me to use Node.js to up/download data directly formatted as JSON.

I read some stuff at the developer's website, and they claim it's as a web server. However, I'm not sure if it's just a data server (which makes sense to me) or it could be a replacement to Apache (I would go for no).

I'm aware that your answers depend on the needs of my application, so, to sum up: it should be able to dispatch data from a database ([No]SQL, whichever) and synchronize it back when I choose (either in the background or by direct action). The client-side should store the data as a mid-step (before syncing and after downloading the stuff) in JSON. Eventually in the future, it should need to synchronize across a bunch of accounts at the same time (you know, team modifications, just like Google Docs and so).

And now, back to the question:

Which are the pros and cons of Node.js?

I'm pretty sure that the direct use of JSON objects from the server to the client and the pushing calls are pretty good reasons to choose Node.js. However, I'm not sure if security (either my code or the data itself) or concurrent connections are mature enough, or I should go for a typical Apache with PHP files querying a MySQL, and in the early future poll instead of push (or find a pushing server).

I know the question may sound easy to answer if you're already on one side (just node, node+Apache, just Apache), but these days I'm from nowhere. Thanks for your answers, mates.

share|improve this question
4  
Producing JSON responses is seriously one of the simplest problems for any modern web framework or language; it's an extremely simple format with good support (esp. outbound) in a zillion languages. – Pointy Apr 14 '11 at 22:52
@Orbling how do I close it? – Kor Apr 14 '11 at 22:58
@Kor: If people who have high reputation agree with me, they will vote to close - once it hits the required number it will happen automatically. – Orbling Apr 14 '11 at 23:06
If you need actual push capabilities, why not simply use WebSockets? I'm unsure why you use middle-layer to transport data, it's up to you but if you can choose which browser your users will use to access your app - WebSockets ftw when it comes to pushing over the web. – N.B. Apr 14 '11 at 23:07
1  
@Kor node is a complete HTTP server. Replace apache. Search the node.js tag for more information. – Raynos Apr 14 '11 at 23:51
show 3 more comments

migrated from stackoverflow.com Apr 15 '11 at 1:46

4 Answers

up vote 3 down vote accepted

Eventually in the future, it should need to synchronize across a bunch of accounts at the same time

Pro: With node.js + socket.io synchronizing json is fast and easy.

client.on('message',function(msg){
  client.broadcast(msg);
  db.save(msg);
}

Con: node.js is only at v0.4.6 it's production worthy, but still very young (and undocumented) compared to PHP etc. . .

edit: a couple articles

http://www.theregister.co.uk/2011/03/01/the_rise_and_rise_of_node_dot_js/ http://metamarketsgroup.com/blog/node-js-and-the-javascript-age/

share|improve this answer
Two more points that may be relevant to PHP developers interested by switching to Node: you can't (afaik ?) mix HTML and server-side JS like you can with HTML and PHP (but that's not an issue if you're using a template system). Also [which is important when working into teams], it only takes one bad script to block the whole server (see the "Blocking and non-blocking" example at nodebeginner.org ). – wildpeaks Nov 7 '11 at 16:50

Pro: its new, its fresh, its JavaScript so it does lambdas up the whazoo.

Cons: its new, I believe less than a year old - untested, not a full system like say PHP. Its a level lower than PHP. Not as many libraries available, not as big of a codebase.

My two cents - its a great start and fun to play with - but not ready for main stream. With that note in mind, portions of Github do run on it.

share|improve this answer
1  
Wow, that's cool, I didn't know Github would use it already. Howerever, the big point is "portions". Maybe that's the best answer, right? – Kor Apr 14 '11 at 23:12

IMHO the only real Pro:

  • It lets you run javascript on the server. Only having to think in a single language for client and server is very nice.

Cons:

  • Very young
  • Not much example code
  • Not many libraries to interface with other systems

Every major web framework supports JSON in/out just fine. That should not be a decision criterion for you.

It's true that node.js supports websockets pretty well. But if you're building a system that relies on your users' browsers having websockets, you're clearly just playing around and not building a real site anyway.

share|improve this answer
It actually doesn't rely on specific web browsers. The fact is that I would choose to pull if I could do it cross-browser rather than... doing a Chrome extension and having WebSockets – Korcholis Apr 15 '11 at 6:53

The biggest downside of node.js is that it's not yet widely used, so if you're looking for mature, tested solution, you should rather choose Twisted.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.