Take the 2-minute tour ×
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 have read that Node.js is a server-side javascript enviroment. This has put few thought and tinkers in my mind.

Can we develop a complete data-drivent web application utilizing just JavaScript (along with node.js), HTML5 and CSS? Do we still need to use some server-side scripting language (e.g. C#, PHP)?

In case we still need to use other scripting languages, what is node.js worth for, or useful?

NOTE: Pardon with my knowledge about node.js.

share|improve this question
2  
One of the selling points of Node.js is that it replaces some server-side scripting language (like c#, php) so that you only need to know javascript for both the client and server side –  WuHoUnited Nov 22 '11 at 13:50
3  
I think Felix's Node.js Convince your Boss Guide has a few decent points ;) –  rlemon Nov 22 '11 at 14:01
    
@rlemon , thanks mate, the link had some great points –  Pankaj Upadhyay Nov 22 '11 at 14:17
add comment

3 Answers

up vote 5 down vote accepted

Can we develop a complete data-drivent web application utilizing just the javascript(alongwith node.js) , HTML5 and CSS.

Yes, using node.js can mean that the only programming language you use is javascript, throughout the application stack.

In case, we still need to use other scripting language, then what node.js is worth for or useful ?

No need for another scripting language.

Even if you do use other scripting languages node is still useful - its non-blocking nature and fast response may make it ideal for some parts of your application.


Things to keep in mind about node.js:

  • The programming model uses callbacks. A lot. This takes time to get used to.
  • You can pass JSON between client and server and they will both be able to consume it natively.
  • node has no blocking (achieved by using all those callbacks), so responds very fast.
share|improve this answer
    
Thanks mate...that's what i was looking for....A one language option for all your server and client scripts requirement....BTW if you have worked with it, how does it fare in performance with regard to PHP ??.... I assume everything should be fast if we are dealing in just one language over the server and client –  Pankaj Upadhyay Nov 22 '11 at 14:00
1  
@PankajUpadhyay - No personal experience, but what I have read seems to say that performance is very good. But the programming style is... unusual. Lots of callbacks. And being able to transfer data between server and client natively using JSON is a bonus. The fact that you are using the same language has no bearing on speed. –  Oded Nov 22 '11 at 14:02
    
@PankajUpadhyay it's trivially faster then PHP. –  Raynos Nov 22 '11 at 15:43
    
PHP and a lot of other scripting languages never had the advantage of Google, Mozilla, and Microsoft competing to make the fastest JIT compiler for it. –  Erik Reppen May 31 '13 at 21:27
add comment

Do not mistake Node.js for a web development framework. It can be used that way, but so can Ruby without Rails. That doesn't mean you should.

Node.js is simply an event-driven library, written in Javascript. That is, it runs a script in a single thread, but using a system of queues and callbacks to free up that thread for other processing whenever it is doing something which takes time but not resources.

This replaces thread-based libraries, which tend to move the processor from thread to thread when they are all trying to work. This kind of context switching is costly so, generally, event-driven will be faster.

There are a couple of caveats to that though. Event-driven paradigms do not run over multiple processors so, if the load is fairly low, a thread-driven paradigm can be faster by sharing its work across cores (this is not an assumption you can make for certain with all frameworks though).

[Edit, ref Raynos's comment] It appears that the above is easily resolved by running a load-balanced cluster of node.js servers -- one for each core.

And code written to use event-driven paradigms must free up the thread whenever it can, otherwise all other requests will queue up behind it, making it considerably slower than a thread-based paradigm. Luckily most of the work there has been done for you and there are plenty of web development frameworks which sit on top of Node.js to make your life easier.

Pick the right one of those for your needs and yes, you will be able to use Javascript throughout your development stack.

share|improve this answer
    
Node really isn't a "framework". it's a tool, library or environment. The "only one processor" problem is trivially addressed with node --cluster which spawns slaves and puts a single master node balancer in front of it. –  Raynos Nov 22 '11 at 15:46
    
@Raynos: I was looking for the word library. It wouldn't come. Will edit. Did not know about --cluster at all though. You learn something new, ay? –  pdr Nov 22 '11 at 16:07
    
--cluster is new in 0.6 :) –  Raynos Nov 22 '11 at 18:16
add comment

Can we develop a complete data-drivent web application utilizing just JavaScript

The answer is Yes. And it is starting already.

It is called FULL-STACK-JAVASCRIPT(FSJS).

Job openings are beginning to open for this position as one indicator.

share|improve this answer
add comment

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.