SlideShare a Scribd company logo
1 of 21
A brief intro to nodejs
Jay LJLU from Evenex team
• Built on Chrome’s JavaScript runtime
• Event-driven
• Non-blocking IO
• Easily building Fast, scalable network application
Built on Chrome’s JavaScript runtime
• Server side, V8 engine
• Fast
• ECMA 5 standards compliance
• “api bits that aren’t considered safe to use in a
web setting but are built in to node’s V8
engine.”
• Choosing JS over C,Lua,Haskell,Ruby
Event-driven
• EventEmitter
• Event loop in libev
• Functional programming in JS
– First-class functions
– Closure
• Used across all core modules
Non-blocking IO 1/2
• “I/O is expensive”
Non-blocking IO 2/2
• Long polling (chatroom/whiteboard), socket.io
• Streaming, (Byte)Buffer
• Blocking vs non-blocking
• Context switch is expensive
• C10K problem
• Share same architecture with nginx
Easily building fast, scalable network
application 1/2
• Easy
– “NodeJs is the new Java”
– Fancy core library
– No compile, fast iteration
Easily building fast, scalable network
application 2/2
• One language rule all. MEAN Stack.
• “web”=>“network”
• TJ Holowaychuk
Engineering
• NPM
• IDE
• Deployment
• Coding style
• Testing
• Debugging
• When to use nodejs
• Companies using NodeJs
Engineering
NPM
• Node packaged modules
– https://npmjs.org
– Now part of core node
– Easily manage dependencies
– package.json
Engineering
IDE
• WebStorm
– Commercial license
– Truly IDE , good for beginner
• Sublime text
– Free to use
– Syntax highlight
– Code template/completion
– Node plugin
Engineering
deployment
• Single thread, single process
– Utilize my 8 cores CPU ? (new cluster module)
• Integrate with legacy services, not replace
– Consumes JSON RESTful services
• Run behind Nginx
– Not stable enough to be a web server
• Hosting
Engineering
coding style
• Callback hell
– Async.js to rescue
• err as first argument
– Handle error first !
• Extending prototype
– Do not extend the prototypes of any objects, especially
native ones
Engineering
Testing
• Mocha
– Fancy reports
– BDD, TDD
– Timeout – good for asyc
– Runs in browser as well
• CI : grunt+jenkins
– Alt : Travis CI https://github.com/travis-ci
Engineering
debugging
• Chrome developer tool
– Eclipse based
• Node-inspector
– Browser based
Engineering
when to use nodejs
• When to use Node.js:
• Use Node.js to:
• Build a (soft) real-time social app like Twitter or a chat app.
• Build high-performance, high I/O, TCP apps like proxy servers, PaaS, databases, etc.
• Build backend logging and processing apps.
• Build great CLI apps similar to vmc-tool, and build tools such as ant or Make.
• Add a RESTful API-based web server in front of an application server.
• When NOT to use Node.js:
• Node.js is not suitable for every application:
• Mission-critical (hard) real-time apps like heart monitoring apps or those that
are CPU-intensive.
• For simple CRUD apps that don’t have any real-time or high-performance needs,
Node.js does not provide much of an advantage over other languages.
• Enterprise apps that might need some specific libraries for which there may not be
a Node.js library yet. (However, you could build a polyglot app that uses Java in
conjunction to Node.js to help with libraries.)
Companies using NodeJs
• LinkedIn, mobile webapp
• Ebay, data retrival gateway
• Github, for downloads
• Dow Jones & Company, for WJS social site
• PayPal (moving every product & every site)
Refs and links
• http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/
• http://www.slideshare.net/the_undefined/nodejs-best-practices-10428790
• http://www.slideshare.net/the_undefined/nodejs-a-practical-introduction-v2
• http://www.slideshare.net/oscarrenalias/nodejs-for-architects-openslava-2013
Getting started !!
• git checkout https://github.com/joyent/node
• ./configure && make && sudo make install
• vi example.js
• node example.js
Thanks !
• 刘立杰 Jay LJLU
More interesting…
• CoffeeScript
• Twitter Bower
• Yeoman/grunt
• phantomjs

More Related Content

What's hot

Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Ido Flatow
 
Fuse integration-services
Fuse integration-servicesFuse integration-services
Fuse integration-servicesChristian Posta
 
Docker With Asp.net Core
Docker With Asp.net CoreDocker With Asp.net Core
Docker With Asp.net CoreFatih Şimşek
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS LimitationsValeri Karpov
 
.Net platform .Net core fundamentals
.Net platform .Net core  fundamentals.Net platform .Net core  fundamentals
.Net platform .Net core fundamentalsHosein Mansouri
 
Front-End Tools and Workflows
Front-End Tools and WorkflowsFront-End Tools and Workflows
Front-End Tools and WorkflowsSara Vieira
 
Lessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMLessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMValeri Karpov
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBValeri Karpov
 
ASP.NET 5 - Microsoft's Web development platform reimagined
ASP.NET 5 - Microsoft's Web development platform reimaginedASP.NET 5 - Microsoft's Web development platform reimagined
ASP.NET 5 - Microsoft's Web development platform reimaginedAlex Thissen
 
Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!Alex Thissen
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelAlex Thissen
 
MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015Valeri Karpov
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5Steven Smith
 

What's hot (20)

Let's server your Data
Let's server your DataLet's server your Data
Let's server your Data
 
Net coreandsimplcommerce
Net coreandsimplcommerceNet coreandsimplcommerce
Net coreandsimplcommerce
 
Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015
 
Fuse integration-services
Fuse integration-servicesFuse integration-services
Fuse integration-services
 
Don't worry with bower
Don't worry with bowerDon't worry with bower
Don't worry with bower
 
Docker With Asp.net Core
Docker With Asp.net CoreDocker With Asp.net Core
Docker With Asp.net Core
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS Limitations
 
.Net platform .Net core fundamentals
.Net platform .Net core  fundamentals.Net platform .Net core  fundamentals
.Net platform .Net core fundamentals
 
Front-End Tools and Workflows
Front-End Tools and WorkflowsFront-End Tools and Workflows
Front-End Tools and Workflows
 
Lessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMLessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODM
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
 
ASP.NET 5 - Microsoft's Web development platform reimagined
ASP.NET 5 - Microsoft's Web development platform reimaginedASP.NET 5 - Microsoft's Web development platform reimagined
ASP.NET 5 - Microsoft's Web development platform reimagined
 
Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!Run your Dockerized ASP.NET application on Windows and Linux!
Run your Dockerized ASP.NET application on Windows and Linux!
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
The Three Musketeers
The Three MusketeersThe Three Musketeers
The Three Musketeers
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5
 

Similar to A brief intro to nodejs

Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
Breaking the eggshell: From .NET to Node.js
Breaking the eggshell: From .NET to Node.jsBreaking the eggshell: From .NET to Node.js
Breaking the eggshell: From .NET to Node.jsBarbara Fusinska
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node jsHabilelabs
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerWeb à Québec
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET DevelopersDavid Neal
 
Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJsAram Rafeq
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Conference
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdfBareen Shaikh
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNaveen S.R
 
Containers, Serverless and Functions in a nutshell
Containers, Serverless and Functions in a nutshellContainers, Serverless and Functions in a nutshell
Containers, Serverless and Functions in a nutshellEugene Fedorenko
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development PipelineGlobalLogic Ukraine
 
321 codeincontainer brewbox
321 codeincontainer brewbox321 codeincontainer brewbox
321 codeincontainer brewboxLino Telera
 
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...Gilad Garon
 
IoT Node-Red Presentation
IoT  Node-Red PresentationIoT  Node-Red Presentation
IoT Node-Red PresentationThe IOT Academy
 

Similar to A brief intro to nodejs (20)

Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Breaking the eggshell: From .NET to Node.js
Breaking the eggshell: From .NET to Node.jsBreaking the eggshell: From .NET to Node.js
Breaking the eggshell: From .NET to Node.js
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with Docker
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET Developers
 
Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJs
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdf
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
 
Containers, Serverless and Functions in a nutshell
Containers, Serverless and Functions in a nutshellContainers, Serverless and Functions in a nutshell
Containers, Serverless and Functions in a nutshell
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
 
Hello world - intro to node js
Hello world - intro to node jsHello world - intro to node js
Hello world - intro to node js
 
321 codeincontainer brewbox
321 codeincontainer brewbox321 codeincontainer brewbox
321 codeincontainer brewbox
 
Meanstack overview
Meanstack overviewMeanstack overview
Meanstack overview
 
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
 
Mean stack
Mean stackMean stack
Mean stack
 
Docker-Intro
Docker-IntroDocker-Intro
Docker-Intro
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
IoT Node-Red Presentation
IoT  Node-Red PresentationIoT  Node-Red Presentation
IoT Node-Red Presentation
 

Recently uploaded

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

A brief intro to nodejs

  • 1. A brief intro to nodejs Jay LJLU from Evenex team
  • 2. • Built on Chrome’s JavaScript runtime • Event-driven • Non-blocking IO • Easily building Fast, scalable network application
  • 3. Built on Chrome’s JavaScript runtime • Server side, V8 engine • Fast • ECMA 5 standards compliance • “api bits that aren’t considered safe to use in a web setting but are built in to node’s V8 engine.” • Choosing JS over C,Lua,Haskell,Ruby
  • 4. Event-driven • EventEmitter • Event loop in libev • Functional programming in JS – First-class functions – Closure • Used across all core modules
  • 5. Non-blocking IO 1/2 • “I/O is expensive”
  • 6. Non-blocking IO 2/2 • Long polling (chatroom/whiteboard), socket.io • Streaming, (Byte)Buffer • Blocking vs non-blocking • Context switch is expensive • C10K problem • Share same architecture with nginx
  • 7. Easily building fast, scalable network application 1/2 • Easy – “NodeJs is the new Java” – Fancy core library – No compile, fast iteration
  • 8. Easily building fast, scalable network application 2/2 • One language rule all. MEAN Stack. • “web”=>“network” • TJ Holowaychuk
  • 9. Engineering • NPM • IDE • Deployment • Coding style • Testing • Debugging • When to use nodejs • Companies using NodeJs
  • 10. Engineering NPM • Node packaged modules – https://npmjs.org – Now part of core node – Easily manage dependencies – package.json
  • 11. Engineering IDE • WebStorm – Commercial license – Truly IDE , good for beginner • Sublime text – Free to use – Syntax highlight – Code template/completion – Node plugin
  • 12. Engineering deployment • Single thread, single process – Utilize my 8 cores CPU ? (new cluster module) • Integrate with legacy services, not replace – Consumes JSON RESTful services • Run behind Nginx – Not stable enough to be a web server • Hosting
  • 13. Engineering coding style • Callback hell – Async.js to rescue • err as first argument – Handle error first ! • Extending prototype – Do not extend the prototypes of any objects, especially native ones
  • 14. Engineering Testing • Mocha – Fancy reports – BDD, TDD – Timeout – good for asyc – Runs in browser as well • CI : grunt+jenkins – Alt : Travis CI https://github.com/travis-ci
  • 15. Engineering debugging • Chrome developer tool – Eclipse based • Node-inspector – Browser based
  • 16. Engineering when to use nodejs • When to use Node.js: • Use Node.js to: • Build a (soft) real-time social app like Twitter or a chat app. • Build high-performance, high I/O, TCP apps like proxy servers, PaaS, databases, etc. • Build backend logging and processing apps. • Build great CLI apps similar to vmc-tool, and build tools such as ant or Make. • Add a RESTful API-based web server in front of an application server. • When NOT to use Node.js: • Node.js is not suitable for every application: • Mission-critical (hard) real-time apps like heart monitoring apps or those that are CPU-intensive. • For simple CRUD apps that don’t have any real-time or high-performance needs, Node.js does not provide much of an advantage over other languages. • Enterprise apps that might need some specific libraries for which there may not be a Node.js library yet. (However, you could build a polyglot app that uses Java in conjunction to Node.js to help with libraries.)
  • 17. Companies using NodeJs • LinkedIn, mobile webapp • Ebay, data retrival gateway • Github, for downloads • Dow Jones & Company, for WJS social site • PayPal (moving every product & every site)
  • 18. Refs and links • http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/ • http://www.slideshare.net/the_undefined/nodejs-best-practices-10428790 • http://www.slideshare.net/the_undefined/nodejs-a-practical-introduction-v2 • http://www.slideshare.net/oscarrenalias/nodejs-for-architects-openslava-2013
  • 19. Getting started !! • git checkout https://github.com/joyent/node • ./configure && make && sudo make install • vi example.js • node example.js
  • 21. More interesting… • CoffeeScript • Twitter Bower • Yeoman/grunt • phantomjs

Editor's Notes

  1. http://www.developerknowhow.com/why-the-v8-javascript-engine-is-so-good/https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8
  2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/EventLoop
  3. http://blog.cloudfoundry.com/2012/06/27/future-proofing-your-apps-cloud-foundry-and-node-js/
  4. http://stackoverflow.com/questions/1911015/how-to-debug-node-js-applications?rq=1
  5. http://www.jetbrains.com/webstorm/
  6. http://stackoverflow.com/questions/1884724/what-is-node-js/6782438#6782438
  7. http://stackoverflow.com/questions/1884724/what-is-node-js/6782438#6782438http://perfectionkills.com/whats-wrong-with-extending-the-dom/http://stackoverflow.com/questions/7310521/node-js-best-practice-exception-handling
  8. http://stackoverflow.com/questions/1884724/what-is-node-js/6782438#6782438
  9. https://github.com/node-inspector/node-inspectorhttp://stackoverflow.com/questions/1911015/how-to-debug-node-js-applications?rq=1
  10. http://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-nodejs?rq=1http://nodeguide.com/convincing_the_boss.html
  11. https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/
  12. https://github.com/joyent/node/wiki/Resources