node.js
introduction of server side javascript
Saturday, November 23, 13
Sira Sujjinanont
@hunt
Managing Director
Webiz Co.,Ltd.
CTO Jitta.com

15 years in
Web development

Saturday, November 23,...
Web Development Journey
•

Static HTML

•

PERL/CGI (2 years)

•

PHP (11 years)
•
•

•

CMS > Drupal, Wordpress, Joomla
F...
PHP bad parts
•

Consume a lot of memories

•

Cannot do Realtime Application

•

Cannot deal direct with protocol layer

...
What I need in the next?
•

Easy to learn (for me and for my team)

•

Fast / Scalability

•

Allow us to dig deep in engi...
And node.js came up!
(server-side javascript)
but we need to dig it deep!!

Saturday, November 23, 13
Why Javascript?
•

Easy to learn and understanding!

•

Front-end coder can do backend immediately!

•

Javascript Engine ...
Server-side javascript

•

Netscape LiveWrite 1996

•

Rhino 1997

•

and over 50 platforms!

Saturday, November 23, 13
Many problems!

•

Slow engines

•

Lag of interest in Javascript language
(until 2005… ajax trend!)

•

Great competitors...
•

Created by Ryan Dahl in 2009
easily building fast, scalable network applications

•

Google V8 Javascript Engine
(Same ...
When do we need a web?

•

Download web server and install

•

Install PHP and maybe database

•

Configuration….

•

And n...
See Node.js way!
(create a web server, just in 6 lines of code)
1

Download and click install
apt-get install nodejs

2
va...
It just works!
Web server and ready for
a huge traffic :)

even 10,000/reqs
var http = require('http');
http.createServer(f...
Blocking I/O
var a = db.query(“SELECT * FROM users”);
console.log(‘Result a:’, a);

var b = db.query(“SELECT * FROM docume...
Blocking I/O
var a = db.query(“SELECT * FROM users”);
console.log(‘Result a:’, a);

wait

var b = db.query(“SELECT * FROM ...
Blocking I/O
var a = db.query(“SELECT * FROM users”);
console.log(‘Result a:’, a);

wait

var b = db.query(“SELECT * FROM ...
Non Blocking I/O
var a = db.query(“SELECT * FROM users”,
function(result){
console.log(‘Result a:’, a);
}
);

var b = db.q...
Non Blocking I/O
var a = db.query(“SELECT * FROM users”,
function(result){
console.log(‘Result a:’, a);
}
);

run parallel...
Benchmark

nginx (non blocking i/o)

Saturday, November 23, 13

apache (blocking i/o)
Suitable Applications
•

Single page app

•

Full web app

•

Realtime app
chat, notification, games

•

Crawler, Bot

•

S...
Who using now?

and thousand thousand more…
including me... Molome ....

Saturday, November 23, 13
You should try!
•

It’s not hard to start if you familiar with Javascript

•

If you looking for another language

•

It’l...
Start now!
http://github.com/hunt/seventies
template for node.js web application
by me!
https://github.com/jlleblanc/nodej...
Q&A

Free to ask!

Saturday, November 23, 13
Upcoming SlideShare
Loading in...5
×

Node.js Introduction

7,378

Published on

in Joomladay 2013 Bangkok

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,378
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
32
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Node.js Introduction

  1. 1. node.js introduction of server side javascript Saturday, November 23, 13
  2. 2. Sira Sujjinanont @hunt Managing Director Webiz Co.,Ltd. CTO Jitta.com 15 years in Web development Saturday, November 23, 13
  3. 3. Web Development Journey • Static HTML • PERL/CGI (2 years) • PHP (11 years) • • • CMS > Drupal, Wordpress, Joomla Framework > Yii, Zend, CodeIgniter, … What’s next?!? Saturday, November 23, 13
  4. 4. PHP bad parts • Consume a lot of memories • Cannot do Realtime Application • Cannot deal direct with protocol layer • No parallel processing Saturday, November 23, 13
  5. 5. What I need in the next? • Easy to learn (for me and for my team) • Fast / Scalability • Allow us to dig deep in engineering • New technology! New boundary! • Open source with great community Saturday, November 23, 13
  6. 6. And node.js came up! (server-side javascript) but we need to dig it deep!! Saturday, November 23, 13
  7. 7. Why Javascript? • Easy to learn and understanding! • Front-end coder can do backend immediately! • Javascript Engine war! (huge changed on web industry) • Non-blocking I/O • One language on both front and back!!! Saturday, November 23, 13
  8. 8. Server-side javascript • Netscape LiveWrite 1996 • Rhino 1997 • and over 50 platforms! Saturday, November 23, 13
  9. 9. Many problems! • Slow engines • Lag of interest in Javascript language (until 2005… ajax trend!) • Great competitors platform and language Saturday, November 23, 13
  10. 10. • Created by Ryan Dahl in 2009 easily building fast, scalable network applications • Google V8 Javascript Engine (Same technology in Google Chrome) • NPM Package Manager (Come by default great as it should be: 48,362 modules) • Realtime, Command line, Many tools Saturday, November 23, 13
  11. 11. When do we need a web? • Download web server and install • Install PHP and maybe database • Configuration…. • And now we can put our code on it! Saturday, November 23, 13
  12. 12. See Node.js way! (create a web server, just in 6 lines of code) 1 Download and click install apt-get install nodejs 2 var http = require('http'); http.createServer(function (req, res) { res.writeHead(200); res.end("Hello World!n"); }).listen(3000); console.log('Server running at http://localhost:3000/'); Saturday, November 23, 13
  13. 13. It just works! Web server and ready for a huge traffic :) even 10,000/reqs var http = require('http'); http.createServer(function (req, res) { res.writeHead(200); res.end("Hello World!n"); }).listen(3000); console.log('Server running at http://localhost:3000/'); Saturday, November 23, 13
  14. 14. Blocking I/O var a = db.query(“SELECT * FROM users”); console.log(‘Result a:’, a); var b = db.query(“SELECT * FROM documents”); console.log(‘Result B:’, b); Saturday, November 23, 13
  15. 15. Blocking I/O var a = db.query(“SELECT * FROM users”); console.log(‘Result a:’, a); wait var b = db.query(“SELECT * FROM documents”); console.log(‘Result B:’, b); Waste cpu cycles from waiting… other part of code, they need to wait too! Saturday, November 23, 13 wait
  16. 16. Blocking I/O var a = db.query(“SELECT * FROM users”); console.log(‘Result a:’, a); wait var b = db.query(“SELECT * FROM documents”); console.log(‘Result B:’, b); sum ( a + b) Saturday, November 23, 13 wait
  17. 17. Non Blocking I/O var a = db.query(“SELECT * FROM users”, function(result){ console.log(‘Result a:’, a); } ); var b = db.query(“SELECT * FROM documents”, function(result){ console.log(‘Result b:’, ab); } ); Saturday, November 23, 13
  18. 18. Non Blocking I/O var a = db.query(“SELECT * FROM users”, function(result){ console.log(‘Result a:’, a); } ); run parallel var b = db.query(“SELECT * FROM documents”, function(result){ console.log(‘Result b:’, ab); } ); max ( a, b ) Saturday, November 23, 13 run parallel
  19. 19. Benchmark nginx (non blocking i/o) Saturday, November 23, 13 apache (blocking i/o)
  20. 20. Suitable Applications • Single page app • Full web app • Realtime app chat, notification, games • Crawler, Bot • Streaming • File uploading Saturday, November 23, 13
  21. 21. Who using now? and thousand thousand more… including me... Molome .... Saturday, November 23, 13
  22. 22. You should try! • It’s not hard to start if you familiar with Javascript • If you looking for another language • It’ll change the way you do a web • And it’s FUN!! Saturday, November 23, 13
  23. 23. Start now! http://github.com/hunt/seventies template for node.js web application by me! https://github.com/jlleblanc/nodejs-joomla module for Joomla Saturday, November 23, 13
  24. 24. Q&A Free to ask! Saturday, November 23, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×