Node.js<br />For an everyday .Netweb developer<br />CristianPrieto<br />Senior Developer at Readify<br />@cprieto/ www.cpr...
Who am I?<br />Senior Software developer in Readify<br />Polyglot programmer<br />Javascript junkie<br />Very opionated<br...
What’s Node.js?<br />Asynchronous event-driven I/O server-side JavaScript server supporting CommonJS and based in an event...
So that’s all…<br />Questions?<br />
“Piece by piece”<br />Jack the Ripper<br />
I/O Event-loop based server<br />A tale about bunnies, hamsters and Squids…<br />
A hamster visiting your site<br />(a happy bunny)<br />Your web server<br />Single threaded bunny<br />
Impatient hamsters<br />(a busy bunny!)<br />Your web server<br />Single threaded bunny<br />
Fetching database (2s)<br />Consuming Service (3s)<br />Writing to a file (3s)<br />Your web server<br />Multi-threaded bu...
Constantly check who is idle doing nothing or waiting<br />Hyperactive squid<br />Event-loop based server<br />
Well, That’s Node.js<br />
Yes… JavaScript…<br />
A JavaScript Server?<br />It’s not a new idea, there were a lot of failed attempts out there<br />You are a web developer,...
Bad code<br />
Good code<br />
Node.js components<br />Core or kernel<br />Very small, compact, cross platform<br />Modules<br />User contributed, like p...
Some useful modules<br />Network modules<br />Http, Net, Dns, smtp, Socket.IO<br />Web framework modules<br />Express, Fab...
But I’m a Windows developer <br />Microsoft loves JavaScript<br />Microsoft loves Node.js<br />Microsoft is going to deplo...
Warning… JavaScript ahead!<br />demo<br />
Not everything is gold<br />When to use Node.js<br />I/O heavy processes<br />Chatty protocols<br />Execution pipes<br />W...
Ok, nice, I got it…<br />But I’m a .Net developer<br />
Surprising Fact<br />Most Unix developers don’t do Windows<br />
We can do it<br />IO Completion Ports (IOCP), WinNT 3.5<br />IIS uses it since IIS5.0<br />IHttpAsyncHandler (since 2003!)...
Threads are not magic<br />So “new Thread” it’s not a magical wand<br />Context switching it’s not free<br />Tasks != Thre...
What should I do now?<br />Go and learn JavaScript<br />Go and “play” with Node.js<br />Go and read a good async book<br /...
Thanks!<br />Questions?<br />
Upcoming SlideShare
Loading in …5
×

Node.js for .net developers

8,487 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
8,487
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
63
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Node.js for .net developers

  1. 1. Node.js<br />For an everyday .Netweb developer<br />CristianPrieto<br />Senior Developer at Readify<br />@cprieto/ www.cprieto.com<br />
  2. 2. Who am I?<br />Senior Software developer in Readify<br />Polyglot programmer<br />Javascript junkie<br />Very opionated<br />A “web guy”<br />Microsoft ASP.NET MVP<br />Geek?<br />
  3. 3. What’s Node.js?<br />Asynchronous event-driven I/O server-side JavaScript server supporting CommonJS and based in an event-loop engine using the Chrome’s V8 engine and libevent (and now libuv) libraries.<br />Created by Ryan Dahl in 2009<br />~ 2K lines of Javascript, > 20K lines of C/C++<br />It’s cancer (Ted Dziuba)<br />No, it’s not (Node.js users)<br />
  4. 4. So that’s all…<br />Questions?<br />
  5. 5. “Piece by piece”<br />Jack the Ripper<br />
  6. 6. I/O Event-loop based server<br />A tale about bunnies, hamsters and Squids…<br />
  7. 7. A hamster visiting your site<br />(a happy bunny)<br />Your web server<br />Single threaded bunny<br />
  8. 8. Impatient hamsters<br />(a busy bunny!)<br />Your web server<br />Single threaded bunny<br />
  9. 9. Fetching database (2s)<br />Consuming Service (3s)<br />Writing to a file (3s)<br />Your web server<br />Multi-threaded bunny<br />
  10. 10. Constantly check who is idle doing nothing or waiting<br />Hyperactive squid<br />Event-loop based server<br />
  11. 11. Well, That’s Node.js<br />
  12. 12. Yes… JavaScript…<br />
  13. 13. A JavaScript Server?<br />It’s not a new idea, there were a lot of failed attempts out there<br />You are a web developer, so you are comfortable with it, right?<br />Javascript is naturally asynchronous, closure/callback function lover language<br />Javascript is a hack language<br />jQuery? DOM hack<br />
  14. 14. Bad code<br />
  15. 15. Good code<br />
  16. 16. Node.js components<br />Core or kernel<br />Very small, compact, cross platform<br />Modules<br />User contributed, like packages<br />NPM is your friend (sorry, no Windows!)<br />Core is single threaded<br />Modules spawn new process or threads<br />But you should not care about that<br />Core “automatically” load balance between cores/cpu’s<br />
  17. 17. Some useful modules<br />Network modules<br />Http, Net, Dns, smtp, Socket.IO<br />Web framework modules<br />Express, Fab.js<br />Testing<br />Vows, jasmine-node, Cup of Tea<br />Database connection modules<br />File servers, payment, graphics<br />
  18. 18. But I’m a Windows developer <br />Microsoft loves JavaScript<br />Microsoft loves Node.js<br />Microsoft is going to deploy Node.js<br />Bing is hiring Node.js devs<br />Joyent is improving Node.js on Windows<br />IIS loves Node.js<br />IISNode<br />IISNode Express<br />Webmatrix loves Node.js<br />Node.js templates for Webmatrix<br />
  19. 19. Warning… JavaScript ahead!<br />demo<br />
  20. 20. Not everything is gold<br />When to use Node.js<br />I/O heavy processes<br />Chatty protocols<br />Execution pipes<br />When not to use Node.js<br />Computer intensive operations (but…)<br />Memory intensive operations (1.2G stack)<br />You still afraid of JavaScript<br />
  21. 21. Ok, nice, I got it…<br />But I’m a .Net developer<br />
  22. 22. Surprising Fact<br />Most Unix developers don’t do Windows<br />
  23. 23. We can do it<br />IO Completion Ports (IOCP), WinNT 3.5<br />IIS uses it since IIS5.0<br />IHttpAsyncHandler (since 2003!)<br />IO threads are not Worker threads<br />Eventing, declarative instead of imperative<br />ASP.NET 4.5 supports<br />AsyncHttpHandlers<br />AsyncHttpModules<br />Async MVC Controllers<br />C# 5.0 async/await<br />
  24. 24. Threads are not magic<br />So “new Thread” it’s not a magical wand<br />Context switching it’s not free<br />Tasks != Threads<br />
  25. 25. What should I do now?<br />Go and learn JavaScript<br />Go and “play” with Node.js<br />Go and read a good async book<br />Don’t use threads as your hammer<br />Understand threading implications<br />Realize there is not a single powerful language<br />Buy me a coffee<br />
  26. 26. Thanks!<br />Questions?<br />

×