1. Node.js For an everyday .Netweb developer CristianPrieto Senior Developer at Readify @cprieto/ www.cprieto.com
2. Who am I? Senior Software developer in Readify Polyglot programmer Javascript junkie Very opionated A “web guy” Microsoft ASP.NET MVP Geek?
3. What’s Node.js? 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. Created by Ryan Dahl in 2009 ~ 2K lines of Javascript, > 20K lines of C/C++ It’s cancer (Ted Dziuba) No, it’s not (Node.js users)
13. A JavaScript Server? It’s not a new idea, there were a lot of failed attempts out there You are a web developer, so you are comfortable with it, right? Javascript is naturally asynchronous, closure/callback function lover language Javascript is a hack language jQuery? DOM hack
16. Node.js components Core or kernel Very small, compact, cross platform Modules User contributed, like packages NPM is your friend (sorry, no Windows!) Core is single threaded Modules spawn new process or threads But you should not care about that Core “automatically” load balance between cores/cpu’s
17. Some useful modules Network modules Http, Net, Dns, smtp, Socket.IO Web framework modules Express, Fab.js Testing Vows, jasmine-node, Cup of Tea Database connection modules File servers, payment, graphics
18. But I’m a Windows developer Microsoft loves JavaScript Microsoft loves Node.js Microsoft is going to deploy Node.js Bing is hiring Node.js devs Joyent is improving Node.js on Windows IIS loves Node.js IISNode IISNode Express Webmatrix loves Node.js Node.js templates for Webmatrix
20. Not everything is gold When to use Node.js I/O heavy processes Chatty protocols Execution pipes When not to use Node.js Computer intensive operations (but…) Memory intensive operations (1.2G stack) You still afraid of JavaScript
23. We can do it IO Completion Ports (IOCP), WinNT 3.5 IIS uses it since IIS5.0 IHttpAsyncHandler (since 2003!) IO threads are not Worker threads Eventing, declarative instead of imperative ASP.NET 4.5 supports AsyncHttpHandlers AsyncHttpModules Async MVC Controllers C# 5.0 async/await
24. Threads are not magic So “new Thread” it’s not a magical wand Context switching it’s not free Tasks != Threads
25. What should I do now? Go and learn JavaScript Go and “play” with Node.js Go and read a good async book Don’t use threads as your hammer Understand threading implications Realize there is not a single powerful language Buy me a coffee