Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Node.js for .net developers

8,553 views

Published on

Published in: Technology
  • Login to see the comments

  • Be the first to like this

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 />

×