SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
Introduction to Node.js
                         Please rate this talk: http://spkr8.com/t/19141




Monday, January 14, 13
Our Goals
                    •    What Node Isn't and Is   •   A Website

                    •    How to Install           •   A RESTful Web Service

                    •    Hello World - Node       •   Why Node
                         Style
                                                  •   Resources
                    •    Node Workflow
                                                  •   Summary
                    •    Three Key Ideas

                    •    Introducing NPM


Monday, January 14, 13
Disclaimer
  The opinions expressed in this talk are my own and don’t
  represent those of my employer, my friends, my family, or
  even me.




Monday, January 14, 13
Who am I?
  I am a Microsoft Certified Solution Developer and I’ve
  been developing software since 1979. Since 2009, I have
  been focused on developing mobile applications, for 
  iPhone, Android, the mobile web, and Windows Phone 7.




Monday, January 14, 13
Who Are You? (I hope)
                    • Experienced with JavaScript
                    • Experience with some other server
                         framework
                    • Familiar with the Unix Tool Chain
                    • Familiar with Git


Monday, January 14, 13
What Node
                             Isn't and Is?
                    • What Node Isn't?
                    • What Node Is?
                    • How to Spell It?




Monday, January 14, 13
What Node Isn't?




Monday, January 14, 13
What Node Is?
                    • The Official Answer
                    • It is built on Google's V8
                    • The Server and the App Are One




Monday, January 14, 13
The Official Answer
                    • Node.js is a platform built on Chrome's
                         JavaScript runtime for easily building fast,
                         scalable network applications. Node.js uses an
                         event-driven, non-blocking I/O model that
                         makes it lightweight and efficient, perfect for
                         data-intensive real-time applications that run
                         across distributed devices.




Monday, January 14, 13
It is built on Google's
                                     V8
                    • Google’s Open Source JavaScript Engine
                    • V8 is really fast
                    • It is compiled, sort of




Monday, January 14, 13
The Server and The
                           App Are One
                    • Unlike Other Technologies
                     • IIS and ASP.NET ( aspnet_wp.exe)
                     • Apache HTTP and PHP
                    • Complete Control of the HTTP Request



Monday, January 14, 13
How to Spell It?
                    • Node.js
                    • Node.JS
                    • Node (my preferred spelling)




Monday, January 14, 13
How to Install
                    • http://nodejs.org/downloads
                     • Mac/PC/Linux/SunOS
                    • Azure
                     • http://www.windowsazure.com/en-us/
                         develop/nodejs/




Monday, January 14, 13
Hello World Node
                               Style
                var http=require('http');
                http.createServer(function (req, res) {
                     res.writeHead(200, { 'Content-Type': 'text/plain});
                     res.end('Hello Worldn');
                }).listen(3000);
                console.log('Server running at http://localhost:3000/');




Monday, January 14, 13
A Slightly Better Hello
                             World
                var http=require('http');

                var server = http.createServer();

                server.on(function (req, res) {

                     res.writeHead(200, { 'Content-Type': 'text/plain});

                     res.end('Hello Worldn');

                }).listen(3000);

                console.log('Server running at http://localhost:3000/');




Monday, January 14, 13
Node Workflow
                    • The REPL
                    • Developing
                    • Publishing




Monday, January 14, 13
The REPL
                    • Read - Eval - Print Loop
                    • Brings JavaScript to the command line
                    • Allows all JavaScript commands
                    • Isn’t Really too useful



Monday, January 14, 13
Developing
                    • Text Editor / Terminal
                    • VIM
                    • WebStorm




Monday, January 14, 13
Publishing with Git
                    • Git
                    • Microsoft Azure
                    • Heroku




Monday, January 14, 13
Three Key Ideas
                    • Callbacks
                    • Events
                    • Modules




Monday, January 14, 13
Callbacks
                    • Callbacks are the key to Asynchronous
                         Programming
                    • Avoid thinking in Java or C# with callbacks
                query(“SELECT * from db”, function(result) {

                     /* do something with result */

                });




Monday, January 14, 13
Events
                    • Events are Core to Node’s Architecture
                    • Events are defined in the Module, Events
                    • Events are hooked using .on
                    • Events are triggered using .emit
                    • Your code can define and emit events also


Monday, January 14, 13
Modules
                    • Based on CommonJS
                    • Solves the Issue of the JavaScript Global
                         Object
                    • Modules are wrapped in anonymous
                         functions




Monday, January 14, 13
Modules
                (function() {
                         /* contents of module file */
                })();




Monday, January 14, 13
Introducing NPM
                    • Node Package Manager
                    • http://npmjs.org
                    • Core
                    • Userland
                    • Types of Installs
                    • Don’t Re-invent the Wheel

Monday, January 14, 13
Core
                    • Packages that are internal to Node
                    • Defined in Node's source in the lib/ folder
                    • Modules like: http, util, fs, etc.




Monday, January 14, 13
Userland
                    • Modules loaded from NPM or other
                    • npm install <module name>
                    • npm install -g <module name>




Monday, January 14, 13
Types of Installs
                    • Global - Accessible to all Node Apps
                    • Local - Accessible only to the current App
                    • Prefer Local
                     • App has all components when published
                     • No need to sudo


Monday, January 14, 13
Don’t Re-invent the
                               Wheel
                    • There are over 20k Packages already
                         defined
                    • Most of your problems have already been
                         solved




Monday, January 14, 13
Top Ten Packages
                    • #10 connect
                         Connect is an extensible HTTP server
                         framework for node, providing high
                         performance "plugins" known as
                         middleware. Connect is bundled with over
                         20 commonly used middleware, including a
                         logger, session support, cookie parser, and
                         more.



Monday, January 14, 13
Top Ten Packages
                    • #9 coffee-script
                         CoffeeScript is a little language that
                         compiles into JavaScript.




Monday, January 14, 13
Top Ten Packages
                    • #8 underscore
                         Underscore.js is a utility-belt library for
                         JavaScript that provides support for the
                         usual functional suspects (each, map,
                         reduce, filter...) without extending any core
                         JavaScript objects.




Monday, January 14, 13
Top Ten Packages
                    • #7 jade
                         Jade is a high performance template engine
                         heavily influenced by Haml and
                         implemented with JavaScript for node.




Monday, January 14, 13
Top Ten Packages
                    • #6 redis
                         This is a complete Redis client for node.js.
                         It supports all Redis commands, including
                         many recently added commands like EVAL
                         from experimental Redis server branches.




Monday, January 14, 13
Top Ten Packages
                    • #5 mocha
                         Mocha is a simple, flexible, fun JavaScript
                         test framework for node.js and the
                         browser.




Monday, January 14, 13
Top Ten Packages
                    • #4 socket.io
                         Socket.IO is a Node.JS project that makes
                         WebSockets and realtime possible in all
                         browsers. It also enhances WebSockets by
                         providing built-in multiplexing, horizontal
                         scalability, automatic JSON encoding/
                         decoding, and more.




Monday, January 14, 13
Top Ten Packages
                    • #3 async
                         Async is a utility module which provides
                         straight-forward, powerful functions for
                         working with asynchronous JavaScript.
                         Although originally designed for use with
                         node.js, it can also be used directly in the
                         browser.




Monday, January 14, 13
Top Ten Packages
                    • #2 request
                         Simplified HTTP request client.




Monday, January 14, 13
Top Ten Packages
                    • #1 Express
                         Fast, unopinionated, minimalist web
                         framework for node.




Monday, January 14, 13
A Website




Monday, January 14, 13
A RESTful Web Service




Monday, January 14, 13
Why Node?
                    • Avoids the Web Dev Context Switch
                    • Gives You Full Control of the Server
                    • Makes Asynchronous Coding Easy
                    • Node is Fun



Monday, January 14, 13
Resources
                    • http://nodejs.org
                    • http://npmjs.org
                    • http://nodetuts.com
                    • http://howtonode.org
                    • http://package.json.nodejitsu.com


Monday, January 14, 13
Summary
                    •    What Node Isn't and Is   •   A Website Using
                                                      Packages
                    •    How to Install
                                                  •   A RESTful Web Service
                    •    Hello World - Node
                         Style                    •   Why Node

                    •    Node Workflow             •   Resources

                    •    Three Key Ideas          •   Summary

                    •    Introducing NPM


Monday, January 14, 13

Mais conteúdo relacionado

Semelhante a Introduction to Node.js

Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitRan Mizrahi
 
Android meetup
Android meetupAndroid meetup
Android meetupTy Smith
 
Node.js Getting Started &amd Best Practices
Node.js Getting Started &amd Best PracticesNode.js Getting Started &amd Best Practices
Node.js Getting Started &amd Best Practicesbotsplash.com
 
Empowering the Social Web with Apache Shindig
Empowering the Social Web with Apache ShindigEmpowering the Social Web with Apache Shindig
Empowering the Social Web with Apache Shindigplindner
 
Node.js Patterns and Opinions
Node.js Patterns and OpinionsNode.js Patterns and Opinions
Node.js Patterns and OpinionsIsaacSchlueter
 
node.js in action
node.js in actionnode.js in action
node.js in actionKaran Misra
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.jsvaluebound
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and GruntPeter deHaan
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby ConferenceJohn Woodell
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platformSreenivas Kappala
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsMandi Walls
 
QEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It TooQEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It TooRob Tweed
 
Show an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CIShow an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CIJoel Byler
 
How fast can you onboard a new team member with VAGRANT ?
How fast can you onboard a new team member with VAGRANT ?How fast can you onboard a new team member with VAGRANT ?
How fast can you onboard a new team member with VAGRANT ?Vivek Parihar
 
JavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJohan Nilsson
 
Developing locally with virtual machines
Developing locally with virtual machinesDeveloping locally with virtual machines
Developing locally with virtual machineswhurleyf1
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for startersBruce Li
 
Frontend Engineer Toolbox
Frontend Engineer ToolboxFrontend Engineer Toolbox
Frontend Engineer ToolboxYnon Perek
 

Semelhante a Introduction to Node.js (20)

Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
 
Android meetup
Android meetupAndroid meetup
Android meetup
 
Node.js Getting Started &amd Best Practices
Node.js Getting Started &amd Best PracticesNode.js Getting Started &amd Best Practices
Node.js Getting Started &amd Best Practices
 
Empowering the Social Web with Apache Shindig
Empowering the Social Web with Apache ShindigEmpowering the Social Web with Apache Shindig
Empowering the Social Web with Apache Shindig
 
Node.js Patterns and Opinions
Node.js Patterns and OpinionsNode.js Patterns and Opinions
Node.js Patterns and Opinions
 
node.js in action
node.js in actionnode.js in action
node.js in action
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.js
 
Node and SocketIO
Node and SocketIONode and SocketIO
Node and SocketIO
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and Grunt
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platform
 
At Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in OperationsAt Your Service: Using Jenkins in Operations
At Your Service: Using Jenkins in Operations
 
QEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It TooQEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It Too
 
Show an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CIShow an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CI
 
How fast can you onboard a new team member with VAGRANT ?
How fast can you onboard a new team member with VAGRANT ?How fast can you onboard a new team member with VAGRANT ?
How fast can you onboard a new team member with VAGRANT ?
 
JavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & Browserify
 
Developing locally with virtual machines
Developing locally with virtual machinesDeveloping locally with virtual machines
Developing locally with virtual machines
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
 
Frontend Engineer Toolbox
Frontend Engineer ToolboxFrontend Engineer Toolbox
Frontend Engineer Toolbox
 

Mais de Troy Miles

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web ServersTroy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with KotlinTroy Miles
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Intro to React
Intro to ReactIntro to React
Intro to ReactTroy Miles
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?Troy Miles
 
Angular Weekend
Angular WeekendAngular Weekend
Angular WeekendTroy Miles
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScriptTroy Miles
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in ClojureTroy Miles
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You KnewTroy Miles
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Troy Miles
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutesTroy Miles
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEANTroy Miles
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveXTroy Miles
 

Mais de Troy Miles (20)

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Introduction to Node.js

  • 1. Introduction to Node.js Please rate this talk: http://spkr8.com/t/19141 Monday, January 14, 13
  • 2. Our Goals • What Node Isn't and Is • A Website • How to Install • A RESTful Web Service • Hello World - Node • Why Node Style • Resources • Node Workflow • Summary • Three Key Ideas • Introducing NPM Monday, January 14, 13
  • 3. Disclaimer The opinions expressed in this talk are my own and don’t represent those of my employer, my friends, my family, or even me. Monday, January 14, 13
  • 4. Who am I? I am a Microsoft Certified Solution Developer and I’ve been developing software since 1979. Since 2009, I have been focused on developing mobile applications, for  iPhone, Android, the mobile web, and Windows Phone 7. Monday, January 14, 13
  • 5. Who Are You? (I hope) • Experienced with JavaScript • Experience with some other server framework • Familiar with the Unix Tool Chain • Familiar with Git Monday, January 14, 13
  • 6. What Node Isn't and Is? • What Node Isn't? • What Node Is? • How to Spell It? Monday, January 14, 13
  • 7. What Node Isn't? Monday, January 14, 13
  • 8. What Node Is? • The Official Answer • It is built on Google's V8 • The Server and the App Are One Monday, January 14, 13
  • 9. The Official Answer • Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Monday, January 14, 13
  • 10. It is built on Google's V8 • Google’s Open Source JavaScript Engine • V8 is really fast • It is compiled, sort of Monday, January 14, 13
  • 11. The Server and The App Are One • Unlike Other Technologies • IIS and ASP.NET ( aspnet_wp.exe) • Apache HTTP and PHP • Complete Control of the HTTP Request Monday, January 14, 13
  • 12. How to Spell It? • Node.js • Node.JS • Node (my preferred spelling) Monday, January 14, 13
  • 13. How to Install • http://nodejs.org/downloads • Mac/PC/Linux/SunOS • Azure • http://www.windowsazure.com/en-us/ develop/nodejs/ Monday, January 14, 13
  • 14. Hello World Node Style var http=require('http'); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain}); res.end('Hello Worldn'); }).listen(3000); console.log('Server running at http://localhost:3000/'); Monday, January 14, 13
  • 15. A Slightly Better Hello World var http=require('http'); var server = http.createServer(); server.on(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain}); res.end('Hello Worldn'); }).listen(3000); console.log('Server running at http://localhost:3000/'); Monday, January 14, 13
  • 16. Node Workflow • The REPL • Developing • Publishing Monday, January 14, 13
  • 17. The REPL • Read - Eval - Print Loop • Brings JavaScript to the command line • Allows all JavaScript commands • Isn’t Really too useful Monday, January 14, 13
  • 18. Developing • Text Editor / Terminal • VIM • WebStorm Monday, January 14, 13
  • 19. Publishing with Git • Git • Microsoft Azure • Heroku Monday, January 14, 13
  • 20. Three Key Ideas • Callbacks • Events • Modules Monday, January 14, 13
  • 21. Callbacks • Callbacks are the key to Asynchronous Programming • Avoid thinking in Java or C# with callbacks query(“SELECT * from db”, function(result) { /* do something with result */ }); Monday, January 14, 13
  • 22. Events • Events are Core to Node’s Architecture • Events are defined in the Module, Events • Events are hooked using .on • Events are triggered using .emit • Your code can define and emit events also Monday, January 14, 13
  • 23. Modules • Based on CommonJS • Solves the Issue of the JavaScript Global Object • Modules are wrapped in anonymous functions Monday, January 14, 13
  • 24. Modules (function() { /* contents of module file */ })(); Monday, January 14, 13
  • 25. Introducing NPM • Node Package Manager • http://npmjs.org • Core • Userland • Types of Installs • Don’t Re-invent the Wheel Monday, January 14, 13
  • 26. Core • Packages that are internal to Node • Defined in Node's source in the lib/ folder • Modules like: http, util, fs, etc. Monday, January 14, 13
  • 27. Userland • Modules loaded from NPM or other • npm install <module name> • npm install -g <module name> Monday, January 14, 13
  • 28. Types of Installs • Global - Accessible to all Node Apps • Local - Accessible only to the current App • Prefer Local • App has all components when published • No need to sudo Monday, January 14, 13
  • 29. Don’t Re-invent the Wheel • There are over 20k Packages already defined • Most of your problems have already been solved Monday, January 14, 13
  • 30. Top Ten Packages • #10 connect Connect is an extensible HTTP server framework for node, providing high performance "plugins" known as middleware. Connect is bundled with over 20 commonly used middleware, including a logger, session support, cookie parser, and more. Monday, January 14, 13
  • 31. Top Ten Packages • #9 coffee-script CoffeeScript is a little language that compiles into JavaScript. Monday, January 14, 13
  • 32. Top Ten Packages • #8 underscore Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects. Monday, January 14, 13
  • 33. Top Ten Packages • #7 jade Jade is a high performance template engine heavily influenced by Haml and implemented with JavaScript for node. Monday, January 14, 13
  • 34. Top Ten Packages • #6 redis This is a complete Redis client for node.js. It supports all Redis commands, including many recently added commands like EVAL from experimental Redis server branches. Monday, January 14, 13
  • 35. Top Ten Packages • #5 mocha Mocha is a simple, flexible, fun JavaScript test framework for node.js and the browser. Monday, January 14, 13
  • 36. Top Ten Packages • #4 socket.io Socket.IO is a Node.JS project that makes WebSockets and realtime possible in all browsers. It also enhances WebSockets by providing built-in multiplexing, horizontal scalability, automatic JSON encoding/ decoding, and more. Monday, January 14, 13
  • 37. Top Ten Packages • #3 async Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with node.js, it can also be used directly in the browser. Monday, January 14, 13
  • 38. Top Ten Packages • #2 request Simplified HTTP request client. Monday, January 14, 13
  • 39. Top Ten Packages • #1 Express Fast, unopinionated, minimalist web framework for node. Monday, January 14, 13
  • 41. A RESTful Web Service Monday, January 14, 13
  • 42. Why Node? • Avoids the Web Dev Context Switch • Gives You Full Control of the Server • Makes Asynchronous Coding Easy • Node is Fun Monday, January 14, 13
  • 43. Resources • http://nodejs.org • http://npmjs.org • http://nodetuts.com • http://howtonode.org • http://package.json.nodejitsu.com Monday, January 14, 13
  • 44. Summary • What Node Isn't and Is • A Website Using Packages • How to Install • A RESTful Web Service • Hello World - Node Style • Why Node • Node Workflow • Resources • Three Key Ideas • Summary • Introducing NPM Monday, January 14, 13