Critical thinking in Node.js

25
Critical Thinking in Node.js Morgan Cheng

Transcript of Critical thinking in Node.js

Page 1: Critical thinking in Node.js

Critical Thinking in Node.js

Morgan Cheng

Page 2: Critical thinking in Node.js

What is Node.JS?

Page 3: Critical thinking in Node.js

History• 2009, Ryan Dahl published Node.js• Bla Bla Bla

• https://blog.risingstack.com/history-of-node-js/

Page 4: Critical thinking in Node.js

io.js & node.js

Page 5: Critical thinking in Node.js
Page 6: Critical thinking in Node.js

Why choose JavaScript?

Page 7: Critical thinking in Node.js

JavaScript is clean in I/O

Page 8: Critical thinking in Node.js
Page 9: Critical thinking in Node.js

Asynchronous Programming

Page 10: Critical thinking in Node.js

Scale Out? Scale Up?

Page 11: Critical thinking in Node.js

Single Thread?IT IS A JOKE

Page 12: Critical thinking in Node.js

Event Loop

Page 13: Critical thinking in Node.js

"Everything runs in parallel except your code"

Page 14: Critical thinking in Node.js

How about add Threading in JavaScript?

Page 15: Critical thinking in Node.js
Page 16: Critical thinking in Node.js

Promise vs CPS

Page 17: Critical thinking in Node.js

CPS• Easy to callback-hell• High Performant

Page 18: Critical thinking in Node.js

Promise• Seems winning

Page 19: Critical thinking in Node.js

Rocks for I/O intensive job

Sucks for CPU intensive job

Page 20: Critical thinking in Node.js

But, Node.js might still fail your Expectation

Page 21: Critical thinking in Node.js

Watch Out

• Sync API• Loop•Recursion•GC

Page 22: Critical thinking in Node.js

It Could Freeze You!

Page 23: Critical thinking in Node.js

Garbage Collection

Real Single Threading

Page 24: Critical thinking in Node.js

This is Node.js

Happy?

Page 25: Critical thinking in Node.js

Any Question?