Introduction to NodeJS Zahid Mahir
Introduction to NodeJS
Zahid Mahir
What is NodeJS?
• Event Driven platform for JavaScript• First released in 2009
• Good for real-time interaction with a website– Chat applications– Location tracking
• Bad for CPU intensive tasks– Predicting the weather
Callbacks
Events
Threads and Scheduling
• Smallest sequence of executable code
• Run multiple threads together via multithreading
• Threads block
• Threads are managed by a Scheduler
Tradition Webserver Example
• Request blog post
• Call to database for post
• Build HTML
• Send response
Event Loop
Taken from: http://misclassblog.com/
How to Code
• Change to only asynchronous programming
Taken from: Matt Perpick, “Writing Asynchronous JavaScript 101”
When to Node
• IO heavy applications
• NOT CPU heavy applications
NPM
• Node Package Manager• Actually stands for “npm is not an acronym”• Install dependencies• Install NodeJS applications• Package and distribute your code
Thank You