0
NODE.JS
HOW JAVASCRIT IS CHANGING SERVER PROGRAMMING
MAXIME LEMAITRE – 16/12/2013
Agenda
• Introduction
• What makes Node so ___ ?
• How to Node ….
– Hello world
– Tweeter Console
• NPM to the rescue
• … ...
Quick overview
•

Brief History
– Invented by Ryan Dahl of Joyent, spring 2009 (4 years)
• Solving the upload progress bar...
“I/O needs to be done differently”
Inspiration
•

Many web applications have code, like this:

•

What is the software doi...
Typical I/O latency
What makes Node so special ?
• Server-side JavaScript
– most widely used programing language of the web
– async by nature
...
Node.js Processing Model
What makes Node.js so popular ?
• It’s fast and scalable
• JavaScript all the way
– Minimal learning curve
– JS is now the...
What makes Node.js so difficult ?
Asynchronous code

Single Event Loop

if # entries = 10,000
doSomething() takes ~1ms
you...
Companies using node

https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
Finally, is it good for everything ?
• Good Use Case
–
–
–
–
–
–
–

JSON API
Streaming
Real-time Pub/Sub systems
Chatty ap...
Node.js at Paypal
Nov 2013, https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/
•

Node.js version Vs Java
– ...
Hello World
Tweeter Console
NPM : Node package manager
•

innovation through modularity
Set of publicly available, reusable components, available thro...
Interesting Modules
Express
Underscore
Commander
Async
Socket.IO
node_redis
Jade
Request
node-unit
winston
Forever
node-sq...
Grunt : The Javascript Task Runner
The Build Tool for JavaScript and Web Applications
“Grunt is a task-based command line ...
Redis Commander
Built with Node
IISNode
Host Node.js app in IIS
•

Native IIS module that allows hosting
of node.js applications in IIS on
Windows.
–
–
–
...
Node.js for Visual Studio Users
Node.js Tools for Visual Studio (Alpha)
Turns Visual Studio into a
Node.js IDE.
• Editing
...
Questions
References
•

Really good introduction
– http://www.nodebeginner.org/
– http://nodejs.developpez.com/tutoriels/javascript/...
Find out more
•

On https://techblog.betclicgroup.com/
About Betclic
•
•

•

Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio
comprising ...
Upcoming SlideShare
Loading in...5
×

Mini-Training: Node.js

3,109

Published on

A quick overview on Node.js to see how Javascript is changing server programming : brief history & motivations, what makes NodeJS so special/popular/difficult, typical use cases, and a few popular tools around the NodeJs world : npm, Grunt, IISNode, Tools for Visual Studio, …

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

No Downloads
Views
Total Views
3,109
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
58
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Transcript of "Mini-Training: Node.js"

  1. 1. NODE.JS HOW JAVASCRIT IS CHANGING SERVER PROGRAMMING MAXIME LEMAITRE – 16/12/2013
  2. 2. Agenda • Introduction • What makes Node so ___ ? • How to Node …. – Hello world – Tweeter Console • NPM to the rescue • … and not to Node – Grunt – Redis Commander • Node.js and Microsoft • Questions “Most languages were designed to solve computational problems, but Node.js is different “ “ Node.js was designed from the ground up to efficiently handle the communication that is at the heart of modern web applications “
  3. 3. Quick overview • Brief History – Invented by Ryan Dahl of Joyent, spring 2009 (4 years) • Solving the upload progress bar problem on Flickr – Jan. 2012 Dahl stepped aside, promoting coworker and NPM creator Isaac Schlueter – First Stable Build on Windows : v0.6.0 (November 2011) • With the Help of Microsoft Node's goal is to provide an easy way to build scalable network programs • Now – Development and maintenance is sponsored by Joyent (Cloud infrastructure) • But many contributors : StrongLoop, Voxer, Joyent, Microsoft, Mozilla, … – #3 repository on GitHub (500 contributors, 10 000 commits) – V0.10 (March 2013) : 35 000 downloads /day, 1 000 000 downloads in 3 months – Run on Linux, Mac, Windows, … and in the Cloud (Supported by major Cloud Platforms)
  4. 4. “I/O needs to be done differently” Inspiration • Many web applications have code, like this: • What is the software doing while it queries the database? In many cases, just waiting for the response. (blocks the thread) But a line of code like this allows the program to return to the event loop immediately. This is how I/O should be done.
  5. 5. Typical I/O latency
  6. 6. What makes Node so special ? • Server-side JavaScript – most widely used programing language of the web – async by nature • Non-blocking I/O – do not wait slow ressources to respond • Built using V8 JavaScript Engine (from Chrome) – very fast and getting faster after each release • « Event-based » or « Asynchronous » – all execution initiated by an event – « Everything runs in parallel except your code » • Single-threaded Event Loop, limited to one CPU – no threads – no locks or no execution concurrency – events are executed in order
  7. 7. Node.js Processing Model
  8. 8. What makes Node.js so popular ? • It’s fast and scalable • JavaScript all the way – Minimal learning curve – JS is now the ubiquitous language of the web – Allow code re-use between front-end and back-end. • Web centric – Being based on JS and V8, node.js naturally attracts mainly web developers • Minimalist Core API and efficient module system • Active development • Always asynchronous – All I/O done in Node is by design asynchronous • Non-fragmented community
  9. 9. What makes Node.js so difficult ? Asynchronous code Single Event Loop if # entries = 10,000 doSomething() takes ~1ms you block for 10 seconds! each node process is bound to one core everything you do blocks Easy to write code like this (async may help you)
  10. 10. Companies using node https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
  11. 11. Finally, is it good for everything ? • Good Use Case – – – – – – – JSON API Streaming Real-time Pub/Sub systems Chatty apps Dashboards Queues Proxy • Bad Use Case – CPU heavy apps – Memory intensive apps – Simple CRUD / HTML apps
  12. 12. Node.js at Paypal Nov 2013, https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/ • Node.js version Vs Java – Built almost twice as fast with fewer people – Written in 33% fewer lines of code – Constructed with 40% fewer files • Node.js performance Vs Java – Double the requests per second vs. the Java application – 35% decrease in the average response time 12
  13. 13. Hello World
  14. 14. Tweeter Console
  15. 15. NPM : Node package manager • innovation through modularity Set of publicly available, reusable components, available through easy installation via an online repository, with version and dependency management – Preinstalled with Node.js – Approx. 50 544 online packages (Dec 2013) – +150 packages per day (#1 of all packages managers) • Features – – – – publish, install, discover, and develop node programs open to all, and anyone can publish their own module puts modules in a place where node.js can find them Manage dependencies & modules with package.json “Node.js is successful because of npm” “don’t worry about multiple versions causing conflicts because npm will automatically partition them. In other words: it just works.”
  16. 16. Interesting Modules Express Underscore Commander Async Socket.IO node_redis Jade Request node-unit winston Forever node-sqlserver google-api azure-sdk Web application framework for node JavaScript's utility belt _ Complete solution for node.js command-line interfaces Higher-order functions and common patterns for asynchronous code Realtime framework, with WebSockets and cross-browser fallbacks support redis client for node Server-side templating engine Standard HTTP client Easy unit testing for node.js and the browser a multi-transport async logging library for node.js simple CLI tool for ensuring that a given script runs continuously Microsoft Driver for Node.js for SQL Server Official client library for accessing Google APIs Azure SDK for Node.js … also more than 50 000 packages
  17. 17. Grunt : The Javascript Task Runner The Build Tool for JavaScript and Web Applications “Grunt is a task-based command line build tool for JavaScript projects.” Use the Power of JavaScript/Node to Automating Repetitive Tasks • Common Build Tasks (configured in gruntfile.js) – – – – – – – – – • Concatenate Compress Minify Linting (JsLint, JsHint) Testing Optimize Image Monitor Files Publish YOUR TASK HERE grunt-contrib-concat grunt-contrib-compress grunt-contrib-htmlmin, grunt-contrib-cssmin grunt-contrib-jshint , grunt-contrib-csslint grunt-contrib-qunit, grunt-contrib-nodeunit grunt-contrib-imagemin grunt-contrib-watch grunt-contrib-copy Who uses Grunt ? – Twitter, Jquery, Bootstrap, WordPress, Adobe, Pinterest, Facebook, …
  18. 18. Redis Commander Built with Node
  19. 19. IISNode Host Node.js app in IIS • Native IIS module that allows hosting of node.js applications in IIS on Windows. – – – – – – – Node Process management Side by side with other content types. Scalability on multi-core servers Integrated debugging Auto-update Access to logs over HTTP Minimal changes to node.js application code – Integrated management experience – Other IIS benefits : Port sharing, security, URL rewriting, compression, caching, loggin g Important Node : Windows Azure Node.js hosting is powered by IISNode !
  20. 20. Node.js for Visual Studio Users Node.js Tools for Visual Studio (Alpha) Turns Visual Studio into a Node.js IDE. • Editing • Intellisense • Profiling • Npm integration • Debugging locally and remotely (Windows/Mac/Linux) • Azure Deployment • … You can also try
  21. 21. Questions
  22. 22. References • Really good introduction – http://www.nodebeginner.org/ – http://nodejs.developpez.com/tutoriels/javascript/node-js-livre-debutant/ - FRENCH- • • • • • • • • • • • http://nodejs.org/ (Official) http://nodejs.org/api/ (Official Api) http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js https://github.com/maxogden/art-of-node#the-art-of-node http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html http://package.json.nodejitsu.com/ https://blog.nodejitsu.com/npm-innovation-through-modularity https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/ http://www.youtube.com/watch?v=SAc0vQCC6UQ http://cgbystrom.com/articles/six-reasons-why-node-js-is-so-popular/ http://www.ebaytechblog.com/2013/05/17/how-we-built-ebays-first-node-jsapplication/
  23. 23. Find out more • On https://techblog.betclicgroup.com/
  24. 24. About Betclic • • • Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio comprising various complementary international brands: Betclic, Everest Gaming, bet-athome.com, Expekt… Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association). Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players.
  1. A particular slide catching your eye?

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

×