2. What is Node
A Platform to write JavasScript applications
outside web browsers.
No DOM
No bowser capability
Act as a web server
Care about HTTP headers
3. About Node
No thread (run single-threaded)
Event-driven architecture (publish/subscribe)
Google V8 JavaScript engine
Non-block I/O event loop (Asynchronous I/O)
File and network I/O libraries (use multiple
threads)
4. History
Ryan Dahl created in 2009[1]
chose JavaScript because of the lack of an existing I/O API
Build high performance and scalable network applications
Sponsored by Joyent[2]
Inspired By seeing a file upload progress bar on Flickr
npm created by Isaac Schlueter, a package manager was introduced
in 2011
Microsoft partnered to create a native Windows version in July 2011
9. JavaScript vs Java
Java
Non-dynamic language
Static typed
The compiler catch programming mistakes
JavaScript
Dynamic language
Loosely typed
Global Object
Global Object cause an unruly chaos!!
12. Asynchronous I/O
A single-thread event loop without thread context switch
Callback function to handle result
result = query('SELECT * from db');
// operate on the result
query('SELECT * from db', function (err, result) {
if (err) throw err; // handle errors
// operate on result
});
15. Conclusion
Node is a great platform for I/O-bound
applications
No good for computationally expensive
calculations
Finbonacci sequence calcuation
More performance, fewer servers, lower cost
and lower environment impact
16. Debate
Node.js favours performance over usability and robustness
Difficult to debug, refactor and develop
no synchronous code
duplicate callback
emitters may get multiple “error” events
missing “error” events sends everything to hell
“error” handlers are very verbose