Introduction to NodeJS

12
Introduction to NodeJS Zahid Mahir

description

 

Transcript of Introduction to NodeJS

Page 1: Introduction to NodeJS

Introduction to NodeJS

Zahid Mahir

Page 2: Introduction to NodeJS

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

Page 3: Introduction to NodeJS

Callbacks

Page 4: Introduction to NodeJS

Events

Page 5: Introduction to NodeJS

Threads and Scheduling

• Smallest sequence of executable code

• Run multiple threads together via multithreading

• Threads block

• Threads are managed by a Scheduler

Page 6: Introduction to NodeJS

Tradition Webserver Example

• Request blog post

• Call to database for post

• Build HTML

• Send response

Page 7: Introduction to NodeJS

Event Loop

Taken from: http://misclassblog.com/

Page 8: Introduction to NodeJS

How to Code

• Change to only asynchronous programming

Taken from: Matt Perpick, “Writing Asynchronous JavaScript 101”

Page 9: Introduction to NodeJS

When to Node

• IO heavy applications

• NOT CPU heavy applications

Page 10: Introduction to NodeJS

NPM

• Node Package Manager• Actually stands for “npm is not an acronym”• Install dependencies• Install NodeJS applications• Package and distribute your code

Page 11: Introduction to NodeJS

Find Me

[email protected]

@zahidmahirgithub.com/zahidmahir

Page 12: Introduction to NodeJS

Thank You