What the frak is Node JS?                                                  NodeJS - © Claudio CicaliTuesday, December 4, 2...
Claudio Cicali                                 @caludio                            Front-end engineer at                  ...
Installing NodeJS        Download, unpack, make, make install                             ... or use homebrew             ...
JavaScript is an interpreted language            which means that you need an JavaScript               interpreter to run ...
Every browser has its own VM                             Firefox? Spidermonkey                            Internet Explore...
2009: this guy had an idea                            (he is Ryan Dahl, btw)                                              ...
Make no mistake                        NodeJS is NOT a “one man project”        It is backed by Joyent, which is a big pla...
If you already can write JavaScript            in the browser why can’t you write           JavaScript on the server then?...
js VMs are getting better and better                 Get one of them, include some                additional libraries and...
After the idea, the design:                            Google V8 would have been the VM                            (Tried ...
What is the “Node Standard Library”?                      A set of ready-to-use tools which gives you- a powerful HTTP(S) ...
Those tools can JavaScript only        or mixed with some C or C++            for performances reason                     ...
Now we have a platform to write REAL programs                   (i.e.: no sandboxing) in JavaScript         The JavaScript...
... except for Node JS itself                      With every new major version, you might                         loose c...
Node JS is fast, in theoryLow maintencance (small impact on resources)                    Programs must not stress the CPU...
The Node JS standard library                     can be EXTENDED by the use of                               modules      ...
MODULES in NodeJS use a well known            pattern/paradigm/standard: CommonJS            (which is well known thanks t...
Take a look:                    https://github.com/joyent/node/wiki/modules                                               ...
Module management is EASY with                                   https://npmjs.org/                No need to install it: ...
Need to access MySQL from your program?                             npm install mysql                                     ...
Publishing your module to the world                                    is freacking easy too                              ...
Modules can be of any complexity              Connect is a big “middleware” module              which gives you cookies, s...
What “using modules” means        //  The  “fs”  module  is  ready  to  use        var  fs  =  require(“fs”);        fs.op...
claudioc$  npm  install  sqlite        //  Once  installed  the  “sqlite”  module  is        //  ready  to  use        var...
There are libraries which run in the browser                   AND in NodeJS as modules (transparently)                   ...
What can NodeJS be used for then?                    Network servers (HTTP, Proxies, messaging)                           ...
NodeJS - © Claudio CicaliTuesday, December 4, 2012
Let me introduce you a couple         of things I’ve done with NodeJS                                NodeJS - © Claudio Ci...
antipad.com                             Real time collaborative code editor                                Built on the gi...
jecho                    “Poor man” command line remote debugger                               for mobile devices         ...
I want moar!                     http://www.nodebeginner.org/                        (highly recommended)                 ...
Follow me! @caludio                                              NodeJS - © Claudio CicaliTuesday, December 4, 2012
One more thing                      “The guys that are getting paid the big bucks                      to deliver scalable...
Upcoming SlideShare
Loading in …5
×

Introduction to NodeJS

3,182 views

Published on

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

No Downloads
Views
Total views
3,182
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
67
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Introduction to NodeJS

  1. 1. What the frak is Node JS? NodeJS - © Claudio CicaliTuesday, December 4, 2012
  2. 2. Claudio Cicali @caludio Front-end engineer at SponsorPay NodeJS - © Claudio CicaliTuesday, December 4, 2012
  3. 3. Installing NodeJS Download, unpack, make, make install ... or use homebrew (and yes! It works on Windows too) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  4. 4. JavaScript is an interpreted language which means that you need an JavaScript interpreter to run your programs We often refer to these beasts as JavaScript Engines or JavaScript Virtual Machine NodeJS - © Claudio CicaliTuesday, December 4, 2012
  5. 5. Every browser has its own VM Firefox? Spidermonkey Internet Explorer? Chakra Chrome? V8 Safari? JavaScriptCore Opera? Carakan Also Rhino, stand alone NodeJS - © Claudio CicaliTuesday, December 4, 2012
  6. 6. 2009: this guy had an idea (he is Ryan Dahl, btw) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  7. 7. Make no mistake NodeJS is NOT a “one man project” It is backed by Joyent, which is a big player in the cloud computing business (has money and people) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  8. 8. If you already can write JavaScript in the browser why can’t you write JavaScript on the server then? NodeJS - © Claudio CicaliTuesday, December 4, 2012
  9. 9. js VMs are getting better and better Get one of them, include some additional libraries and wrap it up into a powerful, directly executable JavaScript platform NodeJS - © Claudio CicaliTuesday, December 4, 2012
  10. 10. After the idea, the design: Google V8 would have been the VM (Tried using Spidermonkey, no luck) Monoprocess, no threads Completely event driven (asynchronous, non-blocking) Focus on NETWORKING NodeJS - © Claudio CicaliTuesday, December 4, 2012
  11. 11. What is the “Node Standard Library”? A set of ready-to-use tools which gives you- a powerful HTTP(S) library (client and server in no time)- DNS name resolution- Crypto- access to the file system- URL manipulation- ZLIB- UDP datagrams http://nodejs.org/docs/latest/api/ NodeJS - © Claudio CicaliTuesday, December 4, 2012
  12. 12. Those tools can JavaScript only or mixed with some C or C++ for performances reason NodeJS - © Claudio CicaliTuesday, December 4, 2012
  13. 13. Now we have a platform to write REAL programs (i.e.: no sandboxing) in JavaScript The JavaScript itself - oh, joy - it’s the latest stable V8 AND NO COMPATIBILITY LAYER! (cries) except ... NodeJS - © Claudio CicaliTuesday, December 4, 2012
  14. 14. ... except for Node JS itself With every new major version, you might loose compatibility at the API level (the Node standard library) (this is really more of a youth problem, anyway) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  15. 15. Node JS is fast, in theoryLow maintencance (small impact on resources) Programs must not stress the CPU Programming is not THAT easy API are well documented NodeJS - © Claudio CicaliTuesday, December 4, 2012
  16. 16. The Node JS standard library can be EXTENDED by the use of modules This is serious business: the number of available modules is HUGE (and the quality? Well...) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  17. 17. MODULES in NodeJS use a well known pattern/paradigm/standard: CommonJS (which is well known thanks to... NodeJS) Writing a module is easy Maybe too much :) (oh, and you’d write “addons” in C/C++ as well) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  18. 18. Take a look: https://github.com/joyent/node/wiki/modules NodeJS - © Claudio CicaliTuesday, December 4, 2012
  19. 19. Module management is EASY with https://npmjs.org/ No need to install it: comes with Node! (Node >= 0.6) With brew you need to run npmjs.org/install.sh NodeJS - © Claudio CicaliTuesday, December 4, 2012
  20. 20. Need to access MySQL from your program? npm install mysql NodeJS - © Claudio CicaliTuesday, December 4, 2012
  21. 21. Publishing your module to the world is freacking easy too (no moderation, no approval...) npm publish NodeJS - © Claudio CicaliTuesday, December 4, 2012
  22. 22. Modules can be of any complexity Connect is a big “middleware” module which gives you cookies, sessions, logging, caching... Express is a web framework built on top of Connect NodeJS - © Claudio CicaliTuesday, December 4, 2012
  23. 23. What “using modules” means //  The  “fs”  module  is  ready  to  use var  fs  =  require(“fs”); fs.open(“somefile”,  “r”,  function(error)  { //  Do  something  with  the  file }); NodeJS - © Claudio CicaliTuesday, December 4, 2012
  24. 24. claudioc$  npm  install  sqlite //  Once  installed  the  “sqlite”  module  is //  ready  to  use var  sqlite  =  require(“sqlite”); var  db  =  new  sqlite.Database(); db.open(“my_db”,  function(error)  { //  Do  something  with  the  database }); NodeJS - © Claudio CicaliTuesday, December 4, 2012
  25. 25. There are libraries which run in the browser AND in NodeJS as modules (transparently) “As of 3.5.0, YUI runs natively on Node.js and comes with an official npm package for easy installation.” NodeJS - © Claudio CicaliTuesday, December 4, 2012
  26. 26. What can NodeJS be used for then? Network servers (HTTP, Proxies, messaging) API backends Real time applications Streaming data “One page” web sites Command line tools Bots NodeJS - © Claudio CicaliTuesday, December 4, 2012
  27. 27. NodeJS - © Claudio CicaliTuesday, December 4, 2012
  28. 28. Let me introduce you a couple of things I’ve done with NodeJS NodeJS - © Claudio CicaliTuesday, December 4, 2012
  29. 29. antipad.com Real time collaborative code editor Built on the giants’ shoulders: The ACE editor (awesome) The ShareJS library (super awesome) NodeJS (lovely) NodeJS - © Claudio CicaliTuesday, December 4, 2012
  30. 30. jecho “Poor man” command line remote debugger for mobile devices https://github.com/claudioc/jecho NodeJS - © Claudio CicaliTuesday, December 4, 2012
  31. 31. I want moar! http://www.nodebeginner.org/ (highly recommended) http://nodetoolbox.com http://nodeguide.com NodeJS - © Claudio CicaliTuesday, December 4, 2012
  32. 32. Follow me! @caludio NodeJS - © Claudio CicaliTuesday, December 4, 2012
  33. 33. One more thing “The guys that are getting paid the big bucks to deliver scalable solutions aren’t up at night feverishly rewriting their systems in Node. They’re doing what they’ve always done: measuring, testing, benchmarking, thinking hard, keeping up with the academic literature that pertains to their problems.” -- Alex Payne http://al3x.net/2010/07/27/node.html NodeJS - © Claudio CicaliTuesday, December 4, 2012

×