18 Node - Js
18 Node - Js
18 Node - Js
js®
Jitendra Kumar Patel
● For beginner
● Multi-thread
Development for the Web….
• Traditional desktop applications have a user interface wired up with background logic
– user interfaces are based on Windows Forms, Jswing, WPF, Gtk, Qt, etc. and dependant on operating system
• On the web user interfaces are standardized
– HTML for markup
– CSS for style
– JavaScript for dynamic content
• In the past proprietary technologies existed on the web, e.g. Adobe Flash, ActiveX
– They are slowly dying
• Data is generated on the server, transferred to the client and displayed by the browser
• Server Side technologies include PHP, JSP, ASP.net, Rails, Djanog, and yes, also node.js
REST……
● Reduce latency
Ideal for applications that serve a lot of requests but dont use/need lots of computational power per
request
There are a couple of implications of this apparently very simple and basic model
• Avoid synchronous code at all costs because it blocks the event loop
• Which means: callbacks, callbacks, and more callbacks
Blocking vs Non-Blocking……
Example :: Read data from file and show data
Blocking…..
● Read data from file
● Show data
● Do other tasks
var data = fs.readFileSync( “test.txt” );
console.log( data );
console.log( “Do other tasks” );
Non-Blocking…… Callback
● Read data from file
When read data completed, show data
● Do other tasks