NODE FOR NOVICES
BRINGING JAVASCRIPT TO THE SERVER
An original presentation by David Wesst / @davidwesst

PRESENTED AT THE...
DAVID WESST

FROM WINNIPEG, MANITOBA
SYSTEMS ANALYST, UNIVERSITY OF MANITOBA (FACULTY OF
MEDICINE)
MICROSOFT MVP, INTERNET...
DAVID WESST

@DAVIDWESST ON TWITTER
DAVIDWESST.COM ON THE WEB
DAVIDWESST.COM/BLOG ON THE BLOGOSPHERE
DW [AT] DAVIDWESST.CO...
FOLLOW ALONG

HTTP://DAVIDWESST.GITHUB.IO/DW-PRESENTATIONS
SLIDES AND DEMOS WILL
BE MADE AVAILABLE
AFTERWARDS
THE POINT

TO ANSWER ONE OF THE FOLLOWING QUESTIONS:
What is Node (a.k.a. NodeJS)?
What do I need to get started?
What mak...
THE POINT

THEME FOR THIS PRESENTATION

UNDERSTAND WHAT YOU
CAN DO WITH NODEJS
THE PLAN (A.K.A. THE AGENDA)
How are we going to do this?
What is NodeJS?
Getting Yourself Setup
Your NodeJS Toolbox
Getti...
THE PLAN

SETTING YOUR EXPECTATIONS
This presentation is...
An introduction to NodeJS
A dialogue about NodeJS
Comparing No...
WHAT IS NODEJS?
WHAT IS NODEJS?

"NODE" = "NODEJS"
WHAT IS NODEJS?
Node is...
Node.js is a platform built on Chrome's
JavaScript runtime for easily building fast,
scalable n...
WHAT IS NODEJS?
Node is...
...Server-Side JavaScript
...100% Multi-Platform
...Open Source
...Sponsored by Joyent
WHAT IS NODEJS?
Node is...
...Powered by Google's V8 JavaScript Engine
...Provides request-level control
...bundled with a...
ASYNCHRONOUS I/O?
I/O THAT DOESN'T BLOCK YOUR APPLICATION
YOU: I DON'T
UNDERSTAND HOW THAT
IS POSSIBLE. TELL ME
MORE!
I WILL.
EXAMPLE: CLIENT-SIDE JAVASCRIPT
/ fn t o w t pr mt r
/ u ci n ih a ae e
f nt o mC in Fn to ( es g, cl bc ) {
u ci n yl et ...
EXAMPLE: SERVER-SIDE (NODEJS)
JAVASCRIPT
/ fn t o w t pr mt r
/ u ci n ih a ae e
f nt o mS re Fn to ( es g, cl bc ) {
u ci...
THE SECRET IS...

CALLBACKS
CALLBACKS

CALLBACK ARE THE SECRET TO NON-BLOCKING OPERATIONS
On the client, UI is kept unblocked
On the server, Requests ...
OPTIONAL DEMO:
CALLBACKS
WHERE IS NODE BEING USED IN
PRODUCTION?
REAL EXAMPLES

Nodejitsu, Cloud Platform
LinkedIn
Ebay
LET'S TALK NODEJS AND
JAVASCRIPT
FRAMEWORKS (LIKE
BACKBONEJS)
GETTING YOURSELF
SETUP
WHAT ARE YOU GOING TO NEED?
Your development machine (Windows, Linux, or Mac)
An Internet Connection
(OPTIONAL) A bit of c...
HOW ARE YOU GOING TO DO IT?
WINDOWS AND MAC
1.
2.
3.
4.

Go to NodeJS.org
Download the installer
Follow the install wizard...
YOUR NODEJS TOOLBOX
CORE TOOLBOX: TEXT EDITOR + TERMINAL
THIS IS PRETTY GOOD TO GET YOU GOING
Vi
Notepad
GEdit
TextMate
NODEJS TOOLS: NODECLIPSE / NODE IDE
HTTP://WWW.NODECLIPSE.ORG/

Eclipse Plugin(s)
Free and Open Source
Adds NodeJS running...
NODEJS TOOLS: CLOUD9
HTTP://C9.IO

Hosted IDE
Free and Paid Options
Open Source
Provides support for major web platforms
I...
NODEJS TOOLS: WEBMATRIX

HTTP://WWW.MICROSOFT.COM/WEB/WEBMATRIX/
Windows Application from Microsoft
Free
Environment for p...
NODEJS TOOLS
WebStorm IDE by JetBrainsLink
Netbeans Plugin Link
Visual Node (Private Beta) by RedgateLink
GETTING YOUR NODE ON
WARMING UP TO NODE

NODE PROJECTS ARE MADE UP OF THE FOLLOWING:
"App.js" - Your Main Executable File
"Package.json" (OPTIO...
DEMO

INTRODUCING NODEJS
USING THE NPM

NODE PACKAGED MODULES
NPM is bundled with Node base install as of v0.6.3
Packages can be browsed at NPMjs.o...
PACKAGE.JSON: REVISITED
THE KEYS TO USING THE NPM

You can...
Define dependencies for running your application
Define depe...
DEMO: USING NPM
COMMAND LINE
PRO TIP
GITHUB IS YOUR FRIEND
CODING WITH CALLBACKS

USING THE REAL POWER OF NODEJS
Keys to remember:
Functions are first-class citizens in JavaScript
F...
CODING WITH CALLBACKS
DEMO

CODING WITH CALLBACKS
MAKING YOUR OWN MODULES
MODULARITY FOR THE WIN

Keys to remember:
Modules provide a way to easily organize your code
Can b...
DEMO

MAKING YOUR OWN MODULES
THINGS TO REMEMBER
Private and Public variables exist
Think Modular
NPM is your friend
...and so is Github
LET'S TALK NODEJS AND
MICROSOFT STUFF
NODEJS AND MICROSOFT
Websites and Cloud Services support in Windows Azure
IDE built into WebMatrix
IIS and IIS Support thr...
ASP.NET VS NODEJS
Serves up JavaScript and HTML
Natively Synchronous
Requires IIS
Provides multiple structured ways of doi...
ASP.NET VS NODEJS
Serves up JavaScript and HTML
Natively Asynchronous
Does not require web server (e.g. IIS)
Provides mult...
PRO TIP
EXPRESSJS: YOUR NEW FAVOURITE NODE
MODULE
POPULAR MVC FRAMEWORK FOR NODE

Provides MVC Pattern for Web Applications
Suppor...
DEMO

INTRODUCTION EXPRESSJS
THE PLAN (A.K.A. THE AGENDA)
How are we going to do this?
What is NodeJS?
Getting Yourself Setup
Your NodeJS Toolbox
Getti...
THE POINT

TO ANSWER ONE OF THE FOLLOWING QUESTIONS:
What is Node (a.k.a. NodeJS)?
What do I need to get started?
What mak...
THE POINT

THEME FOR THIS PRESENTATION

UNDERSTAND WHAT YOU
CAN DO WITH NODEJS
NEXT STEPS
Where do we go from here?
NEXT STEPS
Install NodeJS
Create a NodeJS Application with or without ExpressJS
Explore the npm
Publish a package to the n...
NEXT STEPS

CHECK OUT A RESOURCE
http://package.json.nodejitsu.com/
http://blog.nodejitsu.com/npm-cheatsheet
http://npmjs....
DAVID WESST

FROM WINNIPEG, MANITOBA
SYSTEMS ANALYST, UNIVERSITY OF MANITOBA (FACULTY OF
MEDICINE)
MICROSOFT MVP, INTERNET...
DAVID WESST

@DAVIDWESST ON TWITTER
DAVIDWESST.COM ON THE WEB
DAVIDWESST.COM/BLOG ON THE BLOGOSPHERE
DW [AT] DAVIDWESST.CO...
Upcoming SlideShare
Loading in …5
×

NodeJS for Novices - 28/Oct/13 - Winnipeg, MB

801 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
801
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

NodeJS for Novices - 28/Oct/13 - Winnipeg, MB

  1. 1. NODE FOR NOVICES BRINGING JAVASCRIPT TO THE SERVER An original presentation by David Wesst / @davidwesst PRESENTED AT THE WINNIPEG .NET USER GROUP - OCTOBER 28, 2013 http://www.winnipegdotnet.org
  2. 2. DAVID WESST FROM WINNIPEG, MANITOBA SYSTEMS ANALYST, UNIVERSITY OF MANITOBA (FACULTY OF MEDICINE) MICROSOFT MVP, INTERNET EXPLORER IE USER AGENT USERAGENTS.IE PRODUCER, BREWPUB STUDIOS
  3. 3. DAVID WESST @DAVIDWESST ON TWITTER DAVIDWESST.COM ON THE WEB DAVIDWESST.COM/BLOG ON THE BLOGOSPHERE DW [AT] DAVIDWESST.COM ON EMAIL
  4. 4. FOLLOW ALONG HTTP://DAVIDWESST.GITHUB.IO/DW-PRESENTATIONS
  5. 5. SLIDES AND DEMOS WILL BE MADE AVAILABLE AFTERWARDS
  6. 6. THE POINT TO ANSWER ONE OF THE FOLLOWING QUESTIONS: What is Node (a.k.a. NodeJS)? What do I need to get started? What makes NodeJS different to ASP.NET? Why aren't my JS frameworks working in NodeJS?
  7. 7. THE POINT THEME FOR THIS PRESENTATION UNDERSTAND WHAT YOU CAN DO WITH NODEJS
  8. 8. THE PLAN (A.K.A. THE AGENDA) How are we going to do this? What is NodeJS? Getting Yourself Setup Your NodeJS Toolbox Getting Your Node On
  9. 9. THE PLAN SETTING YOUR EXPECTATIONS This presentation is... An introduction to NodeJS A dialogue about NodeJS Comparing NodeJS to ASP.NET A review of NodeJS development tools A "core sample" of NodeJS fundamentals
  10. 10. WHAT IS NODEJS?
  11. 11. WHAT IS NODEJS? "NODE" = "NODEJS"
  12. 12. WHAT IS NODEJS? Node is... 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.
  13. 13. WHAT IS NODEJS? Node is... ...Server-Side JavaScript ...100% Multi-Platform ...Open Source ...Sponsored by Joyent
  14. 14. WHAT IS NODEJS? Node is... ...Powered by Google's V8 JavaScript Engine ...Provides request-level control ...bundled with a package manager (a.k.a npm, node packaged modules) ...Built on the idea of Asynchronous I/O [or Non-Blocking I/O]
  15. 15. ASYNCHRONOUS I/O? I/O THAT DOESN'T BLOCK YOUR APPLICATION
  16. 16. YOU: I DON'T UNDERSTAND HOW THAT IS POSSIBLE. TELL ME MORE! I WILL.
  17. 17. EXAMPLE: CLIENT-SIDE JAVASCRIPT / fn t o w t pr mt r / u ci n ih a ae e f nt o mC in Fn to ( es g, cl bc ) { u ci n yl et u ci nm sa e a la k / v ra l / a i be v rm g =m sa e a s e sg ; / o jc s / bet v rr n oA ry =n wA r y) a ad mr a e ra (; / f nt o cl / u c in al ae tm g; lr ( s) / c l te cl bc / a l h al a k cl bc (; al a k) } ; v rt ea la k= f nt o( { a h C lb c u ci n ) / .. o sm ti g /. d oe hn } m Ci nF nt o( e sg ,t ea l ak ; y le t uc in ms ae hC lb c)
  18. 18. EXAMPLE: SERVER-SIDE (NODEJS) JAVASCRIPT / fn t o w t pr mt r / u ci n ih a ae e f nt o mS re Fn to ( es g, cl bc ) { u ci n ye vr u ci nm sa e a la k / v ra l / a i be v rm g =m sa e a s e sg ; / o jc s / bet v rr n oA ry =n wA r y) a ad mr a e ra (; / f nt o cl / u c in al cn oe lg mg ; os l .o (s ) / c l te cl bc / a l h al a k cl bc (; al a k) } ; v rt ea la k= f nt o( { a h C lb c u ci n ) / .. o sm ti g /. d oe hn } m Sr eF nt o( e sg ,t ea l ak ; y ev r uc in ms ae hC lb c)
  19. 19. THE SECRET IS... CALLBACKS
  20. 20. CALLBACKS CALLBACK ARE THE SECRET TO NON-BLOCKING OPERATIONS On the client, UI is kept unblocked On the server, Requests are unblocked
  21. 21. OPTIONAL DEMO: CALLBACKS
  22. 22. WHERE IS NODE BEING USED IN PRODUCTION? REAL EXAMPLES Nodejitsu, Cloud Platform LinkedIn Ebay
  23. 23. LET'S TALK NODEJS AND JAVASCRIPT FRAMEWORKS (LIKE BACKBONEJS)
  24. 24. GETTING YOURSELF SETUP
  25. 25. WHAT ARE YOU GOING TO NEED? Your development machine (Windows, Linux, or Mac) An Internet Connection (OPTIONAL) A bit of comfort with a command line
  26. 26. HOW ARE YOU GOING TO DO IT? WINDOWS AND MAC 1. 2. 3. 4. Go to NodeJS.org Download the installer Follow the install wizard Test it in the CLI (command line interface)
  27. 27. YOUR NODEJS TOOLBOX
  28. 28. CORE TOOLBOX: TEXT EDITOR + TERMINAL THIS IS PRETTY GOOD TO GET YOU GOING Vi Notepad GEdit TextMate
  29. 29. NODEJS TOOLS: NODECLIPSE / NODE IDE HTTP://WWW.NODECLIPSE.ORG/ Eclipse Plugin(s) Free and Open Source Adds NodeJS running and debugging support in Eclipse Very young project, but provides what you need
  30. 30. NODEJS TOOLS: CLOUD9 HTTP://C9.IO Hosted IDE Free and Paid Options Open Source Provides support for major web platforms Includes other common development features, like MySQL and Terminal
  31. 31. NODEJS TOOLS: WEBMATRIX HTTP://WWW.MICROSOFT.COM/WEB/WEBMATRIX/ Windows Application from Microsoft Free Environment for popular web platforms (Node, Rails, PHP, HTML5, ASP.NET) Meant for development of Web Sites over Web Apps
  32. 32. NODEJS TOOLS WebStorm IDE by JetBrainsLink Netbeans Plugin Link Visual Node (Private Beta) by RedgateLink
  33. 33. GETTING YOUR NODE ON
  34. 34. WARMING UP TO NODE NODE PROJECTS ARE MADE UP OF THE FOLLOWING: "App.js" - Your Main Executable File "Package.json" (OPTIONAL) - Describes details of your application "node_modules/" (OPTIONAL) - Contains project dependencies
  35. 35. DEMO INTRODUCING NODEJS
  36. 36. USING THE NPM NODE PACKAGED MODULES NPM is bundled with Node base install as of v0.6.3 Packages can be browsed at NPMjs.org Installs packages either locally n mi sa lu dr c r p n t l ne so e ...or globally n mi sa l- t ps rp p n t l g y e ci t
  37. 37. PACKAGE.JSON: REVISITED THE KEYS TO USING THE NPM You can... Define dependencies for running your application Define dependencies for developing your application Set the name, version, and main for your own apps and packages Publish your own packages to the npm
  38. 38. DEMO: USING NPM COMMAND LINE
  39. 39. PRO TIP
  40. 40. GITHUB IS YOUR FRIEND
  41. 41. CODING WITH CALLBACKS USING THE REAL POWER OF NODEJS Keys to remember: Functions are first-class citizens in JavaScript Functions can be passed as arguments Defining functions inside of functions makes them "private" Non-blocking means user waits less, which is good!
  42. 42. CODING WITH CALLBACKS
  43. 43. DEMO CODING WITH CALLBACKS
  44. 44. MAKING YOUR OWN MODULES MODULARITY FOR THE WIN Keys to remember: Modules provide a way to easily organize your code Can be shared amongst other projects Published through npm or git repository Version is defined in package.json
  45. 45. DEMO MAKING YOUR OWN MODULES
  46. 46. THINGS TO REMEMBER Private and Public variables exist Think Modular NPM is your friend ...and so is Github
  47. 47. LET'S TALK NODEJS AND MICROSOFT STUFF
  48. 48. NODEJS AND MICROSOFT Websites and Cloud Services support in Windows Azure IDE built into WebMatrix IIS and IIS Support through IISNode
  49. 49. ASP.NET VS NODEJS Serves up JavaScript and HTML Natively Synchronous Requires IIS Provides multiple structured ways of doing web (Web Forms, MVC, Websites, WebAPI)
  50. 50. ASP.NET VS NODEJS Serves up JavaScript and HTML Natively Asynchronous Does not require web server (e.g. IIS) Provides multiple unstructured ways of doing web Open Source
  51. 51. PRO TIP
  52. 52. EXPRESSJS: YOUR NEW FAVOURITE NODE MODULE POPULAR MVC FRAMEWORK FOR NODE Provides MVC Pattern for Web Applications Supports Popular Middle Modules Command-Line Setup Supports popular UI tools (e.g. LESS, SASS, Jade Templates)
  53. 53. DEMO INTRODUCTION EXPRESSJS
  54. 54. THE PLAN (A.K.A. THE AGENDA) How are we going to do this? What is NodeJS? Getting Yourself Setup Your NodeJS Toolbox Getting Your Node On
  55. 55. THE POINT TO ANSWER ONE OF THE FOLLOWING QUESTIONS: What is Node (a.k.a. NodeJS)? What do I need to get started? What makes NodeJS different to ASP.NET? Why aren't my JS frameworks working in NodeJS?
  56. 56. THE POINT THEME FOR THIS PRESENTATION UNDERSTAND WHAT YOU CAN DO WITH NODEJS
  57. 57. NEXT STEPS Where do we go from here?
  58. 58. NEXT STEPS Install NodeJS Create a NodeJS Application with or without ExpressJS Explore the npm Publish a package to the npm
  59. 59. NEXT STEPS CHECK OUT A RESOURCE http://package.json.nodejitsu.com/ http://blog.nodejitsu.com/npm-cheatsheet http://npmjs.org
  60. 60. DAVID WESST FROM WINNIPEG, MANITOBA SYSTEMS ANALYST, UNIVERSITY OF MANITOBA (FACULTY OF MEDICINE) MICROSOFT MVP, INTERNET EXPLORER IE USER AGENT USERAGENTS.IE PRODUCER, BREWPUB STUDIOS
  61. 61. DAVID WESST @DAVIDWESST ON TWITTER DAVIDWESST.COM ON THE WEB DAVIDWESST.COM/BLOG ON THE BLOGOSPHERE DW [AT] DAVIDWESST.COM ON EMAIL

×