Top Banner
Intro to Node.js (for .NET Developers) David Neal | reverentgeek.com | @reverentgeek var trustMe = { consumes: ["Bacon", "Caffeine"], hasBeard: true, knowsHowToComputer: true }
55

Intro to Node.js (for .NET Developers)

Jul 16, 2015

Download

Software

David Neal
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intro to Node.js (for .NET Developers)

Intro to Node.js (for .NET Developers)

David Neal | reverentgeek.com | @reverentgeek

var trustMe = { consumes: ["Bacon", "Caffeine"], hasBeard: true, knowsHowToComputer: true

}

Page 2: Intro to Node.js (for .NET Developers)

Y2K

Page 3: Intro to Node.js (for .NET Developers)
Page 4: Intro to Node.js (for .NET Developers)
Page 5: Intro to Node.js (for .NET Developers)

Up Ahead •  Why Node.js? •  Crash course •  Tools and frameworks •  Deployment

Page 6: Intro to Node.js (for .NET Developers)

JavaScript… …has won the Web.

– Scott Hanselman

Page 7: Intro to Node.js (for .NET Developers)

Anything that can be written in JavaScript…

…will eventually be written in JavaScript

– Somebody with incredible powers of observation

(e.g., search for “jslinux”)

Page 8: Intro to Node.js (for .NET Developers)

JavaScript… …is tragically important.

– Douglas Crockford, Author of “JavaScript: The Good Parts”

Page 9: Intro to Node.js (for .NET Developers)
Page 10: Intro to Node.js (for .NET Developers)
Page 11: Intro to Node.js (for .NET Developers)
Page 12: Intro to Node.js (for .NET Developers)
Page 13: Intro to Node.js (for .NET Developers)
Page 14: Intro to Node.js (for .NET Developers)
Page 15: Intro to Node.js (for .NET Developers)
Page 16: Intro to Node.js (for .NET Developers)

Node.js exemplifies…

Start with the simplest solution that works.

Do one thing, and do it well.

Page 17: Intro to Node.js (for .NET Developers)

Node.js is… •  blazing fast •  highly concurrent •  low-friction •  cross-platform •  modern web server

Page 18: Intro to Node.js (for .NET Developers)

Why Node.js? •  Rapid innovation & delivery •  Developer happiness •  Attract & retain talent •  Performance

“Why Node.js is Becoming the Go-To Technology in the Enterprise” – nearform.com

Page 19: Intro to Node.js (for .NET Developers)

•  2x faster development with fewer developers •  33% fewer lines of code •  40% fewer files •  2x improvement requests/sec •  35% decrease in avg response time

Page 20: Intro to Node.js (for .NET Developers)

“We are seeing big scale gains, performance boosts and big developer productivity.”

Page 21: Intro to Node.js (for .NET Developers)

•  Black Friday, 2013 •  Mobile platform •  < 1% CPU utilization •  200,000+ concurrent users

Page 22: Intro to Node.js (for .NET Developers)

NBC Universal

•  ASP.NET to Node.js •  300 million page views/month •  Start render time: 8.8 to 1.3 seconds •  Page speed: 100+ to <10 seconds

NBC News, Today.com, CNN…

Page 23: Intro to Node.js (for .NET Developers)

Who else is using Node.js? •  Dow Jones (WSJ) •  eBay •  Groupon •  LinkedIn •  Rdio

•  Shutterstock •  The New York Times •  Uber •  Yammer •  Zendesk

nodjs.org/industry

Page 24: Intro to Node.js (for .NET Developers)

Node.js Use Cases •  Single-page apps •  API server (REST, Hypermedia, etc.) •  Real-time, streaming, WebSockets •  Chat, IM, social media •  Dashboards •  Proxy service In other words… the INTERNET

Page 25: Intro to Node.js (for .NET Developers)

io.js •  Fork of node.js •  Latest Chrome V8, ES6 •  Open governance

Page 26: Intro to Node.js (for .NET Developers)

What’s our story? •  ASP.NET MVC, C# •  SQL Server + NHibernate •  JavaScript + JQuery

Page 27: Intro to Node.js (for .NET Developers)

What’s our story? •  JavaScript •  Recruiting •  Productive, less friction –  Testing – Microservices – RabbitMQ, riak, redis

•  Cross-platform

Page 28: Intro to Node.js (for .NET Developers)
Page 29: Intro to Node.js (for .NET Developers)

Ready to jump in?

Page 30: Intro to Node.js (for .NET Developers)

Installing Node.js 1.  http://nodejs.org 2.  Click big, green INSTALL 3.  Run installer – OR – Install using Chocolatey (http://chocolatey.org) C:\> choco install nodejs.install  

Page 31: Intro to Node.js (for .NET Developers)

Installing Node.js C:\> node –v v0.10.38 C:\> npm –v 1.4.28  

Page 32: Intro to Node.js (for .NET Developers)

Dependencies

– OR – Python 2.x (https://python.org/downloads/

C:\> choco install python2  

Page 33: Intro to Node.js (for .NET Developers)

Dependencies

– OR – Visual C++ 2010 Express

C:\> choco install VCExpress2010  

Page 34: Intro to Node.js (for .NET Developers)

Node.js Tools for Visual Studio Minimum requirements •  VS 2012 Pro

or VS 2013 Express •  Latest VS updates

http://nodejstools.codeplex.com

Page 35: Intro to Node.js (for .NET Developers)

Hey y’all watch this…

Page 36: Intro to Node.js (for .NET Developers)

Other editors •  Sublime Text 3 •  Atom •  WebStorm

Page 37: Intro to Node.js (for .NET Developers)

Debugging C:\> node debug hello.js  

Page 38: Intro to Node.js (for .NET Developers)

Debugging C:\> node debug hello.js  

Page 39: Intro to Node.js (for .NET Developers)

Debugging C:\> npm install –g node-inspector  

Page 40: Intro to Node.js (for .NET Developers)

Debugging C:\> node install –g node-inspector  

C:\> node-debug hello.js  

Page 41: Intro to Node.js (for .NET Developers)

Deploying •  Don’t include node_modules folder •  …unless you create builds for specific targets •  Azure is super-easy •  Windows – iisnode for web apps – winser for services

•  Linux – forever

Page 42: Intro to Node.js (for .NET Developers)
Page 43: Intro to Node.js (for .NET Developers)
Page 44: Intro to Node.js (for .NET Developers)
Page 45: Intro to Node.js (for .NET Developers)
Page 46: Intro to Node.js (for .NET Developers)
Page 47: Intro to Node.js (for .NET Developers)

Hosting Node.js on Azure reverentgeek.com/hosting-node-js-on-microsoft-azure/

Page 48: Intro to Node.js (for .NET Developers)

Recommended Toolbox Package What it do, yo lodash JavaScript utilities when JavaScript promise library async async/parallel execution request (or rest) http client gulp build engine, test runner socket.io sockets, real-time node-inspector Debugging mocha test framework chai TDD/BDD assertion library sinon spies, stubs, mocks

Page 49: Intro to Node.js (for .NET Developers)

Node frameworks MVC •  Express •  Meteor •  Sails •  Hapi

API •  Restify •  LoopBack •  Autohost

nodeframework.com nodewebmodules.com

Page 50: Intro to Node.js (for .NET Developers)
Page 51: Intro to Node.js (for .NET Developers)

Edge.js •  Run .NET in-process •  …including F#, ADO.NET, Python,

and Powershell •  Execute inline code, files, or

assemblies •  Alternative to writing native

modules in C •  .NET 4.5 or Mono 3.1

Page 52: Intro to Node.js (for .NET Developers)

What can Edge.js do? •  Leverage existing .NET investment •  SQL Server (or other DBs) •  TFS, SharePoint, Exchange, etc. •  Active Directory •  Hardware (e.g. camera, microphone,

printer, win32) •  Video encoding, or other CPU-intensive

work •  Powershell

Page 53: Intro to Node.js (for .NET Developers)

.NET + Node.js Integration •  Edge.js (possible migration strategy) •  request module to call .NET Web Services •  Messaging (e.g. RabbitMQ)

Page 54: Intro to Node.js (for .NET Developers)
Page 55: Intro to Node.js (for .NET Developers)

Thank you! David Neal

@ReverentGeek

[email protected]

reverentgeek.com

Demos + Resources bit.ly/node-demos Please rate me! h#p://spkr8.com/t/54801