SlideShare a Scribd company logo
Let's Enjoy Node.js
    All in JavaScript




        Fred Chien
Enjoy Trip With 2 Rules

     旅程將啟,兩點規則
1
Buckle Up!
 請繫安全帶!
2
DO NOT KICK MY ASS!
  請你的朋友不要打我的頭!
說好不打臉的!
  說好喔!
WHO AM I ?

  我是誰?
Fred Chien
  錢逢祥
 永遠的大四生
Fred Chien
  錢逢祥
 永遠的大四生
Fred Chien
  錢逢祥
宅宅水電工
慾火焚身的男人
fred-zone.blogspot.com

  cfsghost @ gmail.com
JavaScript
   大調查
Web 開發者共同的迷思
 底層難!Porting 難!神人!大牛!
共同的夢想
JavaScript 成為海賊王!!!
JavaScript
Is NOT Browser-side Language Anymore

     是否不再只是瀏覽器端語言?
橡膠果實使一切成為可能
Run JavaScript without Browser

     不需要瀏覽器的 JavaScript
Old School JavaScript
Without Browser
With Node.js
More Third-party Modules
More Supports
換句話說
In other words
Enjoy JavaScript
      Enjoy It
Server-side Development
       開發後端應用
PHP/Perl/Python/JSP/ASP...
         開發後端應用
System Development
     開發系統程式
Services/Daemon/Syscall...etc

        控制作業系統的一切
更進一步
 Even More
All Development
   開發一切應用
About node.js
● Stable version is 0.6.15
● Support platforms:
  ○ MS Windows
  ○ Mac OS X
  ○ Linux
  ○ FreeBSD
node.js Features
● Based on V8 JavaScript Engine (With JIT)

● Stand-alone (Without Web Browser)

● Event-driven

● Non-blocking I/O model
More Good Things Come

● Extending with C/C++

● Support Multi-core Systems

● Provide Buffer Class
  ○ Solve 1.9GB heap limit of V8
  ○ Nice to binary data
Great Performance on Server
● Thousands of Concurrent Connections
● Minimal Overhead (CPU/Memory) on a
  singal process
Hello World
   快速試看看
Hello World! (helloworld.js)

var http = require('http');

http.createServer(function(req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello Worldn');
}).listen(10000);

console.log('Server running at http://localhost:10000/');
Run It!


$ node ./helloworld.js
Server running at http://localhost:10000/
Cluster Support (cluster.js)
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
  // Fork workers.
  for (var i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

  cluster.on('death', function(worker) {
    console.log('worker ' + worker.pid + ' died');
  });
} else {
  // Worker processes have a http server.
  http.Server(function(req, res) {
    res.writeHead(200);
    res.end("hello worldn");
  }).listen(8000);
}
Run It!


$ node ./cluster.js
Worker 18394 online
Worker 18393 online
MongoDB Support (mongodb.js)
var mongodb = require('mongodb');
var server = new mongodb.Server('localhost', 27017);
var db = new mongodb.Db('mydb', server);

/* open db */
db.open(function() {
  /* Select 'contact' collection */
      db.collection('contact', function(err, collection) {
        /* Querying (name == 'Fred Chien') */
            collection.find({ name: 'Fred Chien' }, function(err, data) {
                console.log('Name: ' + data.name + ', email: ' + data.email);
            });

      });

});
Run It!


$ node ./mongodb.js
name: Fred Chien, email: cfsghost@gmail.com
Write a XMPP Server (xmppsrv.js)
var xmpp = require('node-xmpp');

var c2s = new xmpp.C2S({
    port: 5222,
    domain: 'example.com'
});

c2s.on("authenticate", function(jid, password, client) {
    if (password == "12345678") {
        client.emit("auth-success", jid);
    } else {
        client.emit("auth-fail", jid);
    }
});

console.log('My XMPP Server was running at localhost:5222');
Run It!


$ node ./xmppsrv.js
My XMPP Server was running at localhost:5222
Node.js Modules
   你可以抓到更多的模組
NPM
Node Package Manager
Let s Enjoy Node.js
8844+
Large Amount of Module
Get Modules with NPM


$ npm install mongodb
$ npm install node-xmpp
References

● Node.js Official Website:
  http://nodejs.org/

● NPM Official Website:
  http://npmjs.org/
Community in Taiwan

 ● Node.js Taiwan
   http://nodejs.tw/

 ● Facebook Fans Page
   # NodeJS.tw

 ● Node.js Taiwan Party in Taipei
   Once Every other Thursday
總結來說...
  Anyway...
前端開發者走入後端
 一種語言前後都可玩
Web開發者
將實現夢想
寫系統程式啦
低階程式讓專業的來
用 Node.js C/C++ Addon 打通硬體和系統的任督二脈
JSer 只要專心惡搞
 仍然不需要管底層的事
大秘寶就是我們的!
  我是海賊王!
Question?
   提問?
Thanks
感謝您的耐心耹聽

More Related Content

PDF
Brig:Node.js + QML 華麗大冒險
PDF
Enjoy Writing Modern Desktop Application in JavaScript
PDF
Web technologies for desktop development
PPTX
Future of NodeJS
PDF
(C)NodeJS
PDF
Node js实践
PPTX
NodeJS
PDF
Continuous Integration for front-end JavaScript
Brig:Node.js + QML 華麗大冒險
Enjoy Writing Modern Desktop Application in JavaScript
Web technologies for desktop development
Future of NodeJS
(C)NodeJS
Node js实践
NodeJS
Continuous Integration for front-end JavaScript

What's hot (20)

KEY
Getting Started with MongoDB and Node.js
ODP
Presentation of JSConf.eu
PDF
GruntJS + Wordpress
PDF
Fundamental of Node.JS - Internship Presentation - Week7
PDF
Nodejs presentation
KEY
Server side scripting smack down - Node.js vs PHP
PDF
PPTX
Herramientas front
PDF
PPTX
Windows Azure loves OSS
PDF
Node.js and Ruby
KEY
Node workShop Basic
PDF
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
PPTX
Node js introduction
PDF
Java/Spring과 Node.js의 공존 시즌2
PDF
All aboard the NodeJS Express
PDF
Create a RESTful API with NodeJS, Express and MongoDB
PDF
Groovy a Scripting Language for Java
PDF
Use Node.js to create a REST API
Getting Started with MongoDB and Node.js
Presentation of JSConf.eu
GruntJS + Wordpress
Fundamental of Node.JS - Internship Presentation - Week7
Nodejs presentation
Server side scripting smack down - Node.js vs PHP
Herramientas front
Windows Azure loves OSS
Node.js and Ruby
Node workShop Basic
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node js introduction
Java/Spring과 Node.js의 공존 시즌2
All aboard the NodeJS Express
Create a RESTful API with NodeJS, Express and MongoDB
Groovy a Scripting Language for Java
Use Node.js to create a REST API
Ad

Viewers also liked (15)

PDF
用最潮的 Java script 盡情開發 kde qt 程式
PDF
How to Write Node.js Module
PDF
Node.js 進攻桌面開發
PDF
Koa 正在等一個人
PDF
OwaNEXT
PDF
Non-MVC Web Framework
PDF
Stem OS Proposal
PDF
App house
PDF
軟體人甘苦談
PDF
QML + Node.js
PDF
Java script 全面逆襲!使用 node.js 打造桌面環境!
PDF
MakerBoard: MT7688 Emulator
PDF
我編譯故我在:誰說 Node.js 程式不能編成 binary
PDF
超酷炫科幻 UI:QML 入門
PPTX
QML 與 C++ 的美麗邂逅
用最潮的 Java script 盡情開發 kde qt 程式
How to Write Node.js Module
Node.js 進攻桌面開發
Koa 正在等一個人
OwaNEXT
Non-MVC Web Framework
Stem OS Proposal
App house
軟體人甘苦談
QML + Node.js
Java script 全面逆襲!使用 node.js 打造桌面環境!
MakerBoard: MT7688 Emulator
我編譯故我在:誰說 Node.js 程式不能編成 binary
超酷炫科幻 UI:QML 入門
QML 與 C++ 的美麗邂逅
Ad

Similar to Let s Enjoy Node.js (20)

PDF
Nodejs - A-quick-tour-v3
PDF
Event driven programming -- Node.JS
PDF
Node.js
KEY
Writing robust Node.js applications
PDF
Артем Маркушев - JavaScript
PDF
Node.js - async for the rest of us.
PDF
Node.js - A Quick Tour
PDF
Nodejs - A quick tour (v5)
PDF
Node.js vs Play Framework
PDF
NodeJS for Beginner
PDF
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
PDF
Cape Cod Web Technology Meetup - 2
PDF
Facebook的缓存系统
PDF
soft-shake.ch - Hands on Node.js
PDF
Nodejs - A quick tour (v6)
PPT
Nodejs Intro Part One
PPTX
Real World Lessons on the Pain Points of Node.JS Application
KEY
Node.js - As a networking tool
PDF
2011-03 Developing Windows Exploits
PPTX
Run Node Run
Nodejs - A-quick-tour-v3
Event driven programming -- Node.JS
Node.js
Writing robust Node.js applications
Артем Маркушев - JavaScript
Node.js - async for the rest of us.
Node.js - A Quick Tour
Nodejs - A quick tour (v5)
Node.js vs Play Framework
NodeJS for Beginner
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
Cape Cod Web Technology Meetup - 2
Facebook的缓存系统
soft-shake.ch - Hands on Node.js
Nodejs - A quick tour (v6)
Nodejs Intro Part One
Real World Lessons on the Pain Points of Node.JS Application
Node.js - As a networking tool
2011-03 Developing Windows Exploits
Run Node Run

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The Rise and Fall of 3GPP – Time for a Sabbatical?
MIND Revenue Release Quarter 2 2025 Press Release
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Let s Enjoy Node.js