We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Node.js Crash Course (for .NET Developers)

00:00

Formal Metadata

Title
Node.js Crash Course (for .NET Developers)
Title of Series
Number of Parts
133
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Node.js is a compelling platform that is quickly spreading from startups to the enterprise. Node.js strategically unites developers of all backgrounds through the common language of JavaScript. Why should you learn Node.js and where do you start? You will come away from this talk with the evidence to support Node.js, and tools you need to be productive. We will walk through a typical workflow of creating and debugging a web application. You will learn how easy it is to deploy, including Microsoft Azure. We'll also look at popular frameworks and modules, and other learning resources to give you the best start.
Crash (computing)Software developerCASE <Informatik>BlogTwitterComa BerenicesDifferent (Kate Ryan album)2 (number)QuicksortComputer animation
Software developerScripting languageJava appletVertex (graph theory)Crash (computing)DisintegrationSoftware frameworkScripting languageCASE <Informatik>Stack (abstract data type)Web 2.0INTEGRALSoftware frameworkCartesian coordinate systemCrash (computing)Java appletPhysical lawMereologyProcess (computing)Web browserPhysical system2 (number)Strategy gamePoint (geometry)AuthorizationWeightEntire functionOperating systemComputer animation
Software developerFormal languageClient (computing)Java appletWeb 2.0Server (computing)Single-precision floating-point formatScripting languageCartesian coordinate systemGraphical user interfaceProcess (computing)Right angleDifferent (Kate Ryan album)Multiplication signEndliche ModelltheorieIdeal (ethics)Run time (program lifecycle phase)Machine codeInformationDynamical systemScaling (geometry)Exterior algebraMereologyComputing platformWeb-DesignerTerm (mathematics)WeightScalabilityGoodness of fitVirtual machine
Software developerRun time (program lifecycle phase)Scaling (geometry)Module (mathematics)Endliche ModelltheorieMultiplication signFormal languageConnected spaceMobile appEvent horizonCartesian coordinate systemServer (computing)Pattern languageRadio-frequency identificationWindowWeb 2.0Different (Kate Ryan album)Concurrency (computer science)10 (number)Computing platformComputing platformWeightRandom matrixLoop (music)Context awarenessThread (computing)40 (number)Form (programming)Process (computing)Perspective (visual)PlanningData storage deviceWeb-DesignerState of matterScripting languageJava appletSingle-precision floating-point format
Software developerQuery languageSQL ServerWeightApplication service providerJava appletScripting languageWindowCartesian coordinate systemSocial classComputing platformApplication service providerWeb 2.0BitScripting languageSoftware development kitCore dumpServer (computing)Type theoryProcess (computing)Web applicationArm
WeightSoftware developerApplication service providerSQL ServerJava appletScripting languageClient (computing)Cartesian coordinate systemFrustrationProduct (business)Multiplication signFormal languageWeb 2.0Scripting languageProcess (computing)Computer animation
Java appletScripting languageSoftware developerMultiplication signRepeating decimalComputing platformLimit setWeb-DesignerWeightExpert systemComputing platformProcess (computing)Integrated development environmentComputer animation
Software developerJava appletScripting languageSoftware testingService (economics)FrictionComputing platformIntegrated development environmentSoftware developerClient (computing)Projective planeUniqueness quantificationImage resolutionFriction.NET FrameworkServer (computing)Queue (abstract data type)Service (economics)Computing platformComputer animation
Software developerJava appletScripting languageFrictionSoftware testingService (economics)Vertex (graph theory)Integrated development environmentProcess (computing)Dependent and independent variablesForm (programming)SummierbarkeitSoftware developerRoutingComputer animation
Vertex (graph theory)Software developerEndliche ModelltheorieProxy serverWeb pagePersonal digital assistantServer (computing)HypermediaSocket-SchnittstelleSocial softwareCore dumpFunctional (mathematics)Endliche ModelltheorieCartesian coordinate systemModule (mathematics)Web pageReal-time operating systemCASE <Informatik>Single-precision floating-point formatOnline chatMobile appWeb applicationServer (computing)Software frameworkComputer animation
Software developerWeb pagePersonal digital assistantServer (computing)HypermediaSocket-SchnittstelleSocial softwareProxy serverInternetworkingArchitectureCodeInternetworkingCASE <Informatik>Goodness of fitLine (geometry)Vertex (graph theory)Service (economics)Real-time operating systemModule (mathematics)Web 2.0Web applicationObservational studyTable (information)Self-organizationComputer animation
Software developerComputer fileLine (geometry)CodeDependent and independent variablesMultiplication signCodeIntegrated development environmentBuildingProcess (computing)Computer fileForm (programming)Java appletSoftware developerObservational studyCartesian coordinate systemExecution unitCASE <Informatik>Computer animation
Line (geometry)Computer fileSoftware developerDependent and independent variablesCodeBefehlsprozessorComputing platformMobile WebCASE <Informatik>ResultantServer (computing)Chaos (cosmogony)Java appletExpert systemComputing platformObservational studyTotal S.A.Multiplication signBefehlsprozessorReal-time operating systemUtility softwareLogic gateDreizehnFilm editingComputer animation
BefehlsprozessorSoftware developerComputing platformMobile WebLocal GroupMultiplication signLinker (computing)Event horizonOperations support systemService (economics)Cross-platformCartesian coordinate systemElectronic mailing listReal-time operating systemComputer animation
Operations support systemEvent horizonSoftware developerInstallation artVertex (graph theory)Traffic reportingPerspective (visual)Process (computing)Computing platformWindowSelf-organizationComputer animation
Installation artVertex (graph theory)Software developerComputing platformMultiplication signInstallation artMobile appRight angleCartesian coordinate systemWindowScripting languageVirtual machineSeries (mathematics)Moving averageLine (geometry)Visualization (computer graphics)Computer animation
Vertex (graph theory)Software developerInstallation artScripting languageMereologyWindowEndliche ModelltheorieModule (mathematics)Type theoryVertex (graph theory)Data managementLibrary (computing)SpacetimeInstallation artProcess (computing)Cartesian coordinate systemComputer file
Installation artSoftware developerExpressionLibrary (computing)Cross-platformOnline gameComputer architectureRevision controlDot productWindowVideo gameBitCompilerPoint (geometry)ExpressionComputer animation
ExpressionInstallation artSoftware developerVisual systemVertex (graph theory)Maxima and minimaModule (mathematics)Revision controlVisualization (computer graphics)CodeEndliche ModelltheorieFlagMultiplication signFrustrationInstance (computer science)Projective planeExterior algebraText editor
Maxima and minimaVisual systemVertex (graph theory)Software developerExpressionDemo (music)Integrated development environmentLibrary (computing)Visualization (computer graphics)Template (C++)Projective planeSet (mathematics)Computer animation
Software developerCache (computing)Event horizonFunction (mathematics)Router (computing)Default (computer science)Configuration spaceMiddlewareException handlingWindowWeb 2.0ExpressionWeb applicationCartesian coordinate systemRevision controlTemplate (C++)Right angleVisualization (computer graphics)Application service providerMultiplication signBitModule (mathematics)Real numberDifferent (Kate Ryan album)Plug-in (computing)Similarity (geometry)CodeDemo (music)SoftwareLibrary (computing)Local ringObject (grammar)Point (geometry)Software frameworkStack (abstract data type)outputSet (mathematics)Category of beingControl flowType theoryVariable (mathematics)MathematicsWindowLevel (video gaming)Endliche ModelltheorieVertex (graph theory)WeightComputer fileGraphical user interfaceNumberService (economics)Computer animation
ExpressionSoftware developerInteractive televisionData typeWindowVertex (graph theory)Visual systemCodeService (economics)Function (mathematics)ParsingModule (mathematics)Cone penetration testDirected graphFunctional (mathematics)Service (economics)Online gameCASE <Informatik>Concurrency (computer science)Pattern languageStatement (computer science)Cartesian coordinate systemProduct (business)Computing platformMobile appParameter (computer programming)BitEndliche ModelltheorieObject (grammar)Instance (computer science)Multiplication signModule (mathematics)Game controllerNumberServer (computing)Loop (music)Electronic mailing listTelecommunicationCodeProcess (computing)AuthorizationCategory of beingConstructor (object-oriented programming)InformationRevision controlNormal (geometry)Goodness of fitPersonal digital assistantExpressionVisualization (computer graphics)Library (computing)Client (computing)Structural loadPoint (geometry)Utility softwareSoftware bugControl flowDescriptive statisticsSet (mathematics)DataflowText editorInteractive televisionConfiguration spaceVariable (mathematics)FreezingInstallation artWindowOpen sourceDynamical systemScripting languageLocal ringDebuggerSocial classProjective planeData managementMessage passingError messageFormal languageException handlingReading (process)Different (Kate Ryan album)Web 2.0System callResultantComputer fileDeclarative programmingCross-platformWeightWeb applicationForm (programming)Event horizonRight angleBuildingFile systemComputer animation
Module (mathematics)Function (mathematics)Software developerEmailQuery languageSanitary sewerPasswordDatabaseBitBookmark (World Wide Web)Module (mathematics)NumberRelational databaseServer (computing)Endliche ModelltheorieFunctional (mathematics)SequelDatabasePersonal identification numberComputer animation
EmailQuery languageSoftware developerSanitary sewerPasswordDatabaseServer (computing)Configuration spaceInformationComputer fileIntegrated development environmentVariable (mathematics)WeightBitCartesian coordinate systemComputer animation
EmailQuery languageSoftware developerSanitary sewerPasswordDatabaseVideo game consoleDefault (computer science)Integrated development environmentSequeloutputParameter (computer programming)Line (geometry)Procedural programmingData storage deviceQuery languageFunction (mathematics)Computer fileModul <Datentyp>System callCartesian coordinate systemFunctional (mathematics)Statement (computer science)ResultantComputer animation
EmailQuery languageVideo game consoleDatabaseSoftware developerCodeStatement (computer science)ChainSet (mathematics)Cartesian coordinate systemResultantGoodness of fitEndliche ModelltheorieModule (mathematics)Computer animation
Software developerVertex (graph theory)Endliche Modelltheorie32-bitIntegrated development environmentComputer architectureServer (computing)WindowCodeComputing platformProduct (business)Installation artComputer fileModule (mathematics)BitParameter (computer programming)Computing platformCartesian coordinate systemComputer animation
Software developerInheritance (object-oriented programming)Service (economics)Mobile appBuildingWindowTemplate (C++)Vertex (graph theory)NumberSocial classPoint (geometry)Service (economics)Cartesian coordinate systemServer (computing)Computer hardwareArithmetic meanCuboidSingle-precision floating-point formatInstance (computer science)Roundness (object)Distribution (mathematics)Queue (abstract data type)Computer architectureWeb applicationComputer configurationElectronic meeting systemCore dump2 (number)Web 2.0Computer animation
Mobile appService (economics)Software developerInheritance (object-oriented programming)WebsiteRepository (publishing)Cartesian coordinate systemBlogWebsiteMultiplication signRepository (publishing)Revision controlMathematicsComputer configurationService (economics)NumberVisualization (computer graphics)Computer animation
WebsiteSoftware developerRepository (publishing)Vertex (graph theory)Utility softwareComputer configurationModule (mathematics)CuboidPattern languageSystem callLibrary (computing)Task (computing)Directed graphComputer animation
Software developerTask (computing)Web serviceSerial portLibrary (computing)Parallel portWeightMashup <Internet>Goodness of fitCartesian coordinate systemThermal conductivityClient (computing)Integrated development environmentWeb 2.0Computer animation
Software developerNumberBuildingSoftware testingPhysical systemReal-time operating systemSocket-SchnittstelleNetwork socketDisk read-and-write headIntegrated development environmentPoint (geometry)Control flowText editorVariable (mathematics)Cartesian coordinate systemSoftware developerSet (mathematics)Graphical user interfaceVisualization (computer graphics)CodeSoftware bugMultiplication signCASE <Informatik>Computer animation
Software developerExpressionNatural numberBinary decision diagramGoodness of fitServer (computing)Web 2.0Software testingNumberGraphical user interfaceCartesian coordinate systemMultiplication signSoftware frameworkOpen sourceSign (mathematics)HypermediaFrictionFreewareBit rateComputer animation
Software developerExpressionSoftware frameworkMereology1 (number)Software frameworkCuboidBuildingModule (mathematics)Mobile appLoop (music)Link (knot theory)HypermediaHypercubeClient (computing)Endliche ModelltheorieWeightWeb applicationCodeCartesian coordinate systemElectronic mailing listMobile WebLibrary (computing)Process (computing)Computing platformPower (physics)Coma BerenicesBridging (networking)Gastropod shellSoftware developerComputer animation
WeightSoftware developerProcess (computing)CodeComputer fileAssembly languageModul <Datentyp>WeightLine (geometry)Assembly languageMixture modelScripting languageExterior algebraEndliche ModelltheorieJava appletDirected graphPoint (geometry)MultiplicationComputer animation
Software developerAssembly languageModul <Datentyp>WeightComputer fileCodePoint (geometry)Cartesian coordinate systemThread (computing)Computer programmingEndliche ModelltheorieEvent horizonWeightLoop (music)Open sourceFunctional (mathematics)Module (mathematics)Shared memoryNumberComputer animationLecture/Conference
WeightPoint (geometry)Software developerActive DirectoryComputer hardwareVideoconferencingNumberModule (mathematics)Alpha (investment)Product (business)Local ringDirectory serviceEndliche ModelltheorieSequelEvent horizonCartesian coordinate systemComputer hardwareLoop (music)Computer animationLecture/Conference
Point (geometry)Active DirectoryVideoconferencingSoftware developerWeightComputer hardwareDisintegrationProxy serverModule (mathematics)Perspective (visual)INTEGRALStrategy gameProxy serverWeightService (economics)Self-organizationGastropod shellNumberIntelligent NetworkProcess (computing)Java appletPhysical systemCodeEndliche ModelltheorieComputer animation
Proxy serverWeightService (economics)DisintegrationSoftware developerVisual systemCodeModule (mathematics)WeightCodeNumberTelecommunicationClient (computing)Gastropod shellMessage passingStructural loadCartesian coordinate systemVisualization (computer graphics)NeuroinformatikComputer architectureService (economics)Endliche ModelltheorieComputer animation
Software developerVisual systemCodeCartesian coordinate systemOpen sourceCross-platformClient (computing)TelecommunicationWeb applicationWeb 2.0WeightNumberSocial classWindowSoftware developerAndroid (robot)Mobile appRevision controlIntegrated development environmentoutputUniqueness quantificationSet (mathematics)Position operatorOrder (biology)Computer animation
Software developerSlide ruleElectronic mailing listDemo (music)InformationEquivalence relationSystem callDigital photographyRow (database)TelecommunicationSoftware repositoryMobile WebVertex (graph theory).NET FrameworkWeb applicationWindow2 (number)Exterior algebraLink (knot theory)Right angleRevision controlMechanism designCartesian coordinate systemFormal languageType theoryMobile appProduct (business)CodeExpressionMultilaterationVideo gameComputing platformView (database)NumberDescriptive statisticsProcess (computing)Point (geometry)Computer animation
Transcript: English(auto-generated)
I'm excited to be here. And in case you didn't recognize, I am from the U.S. I'm from the deep south of the U.S. I speak fluent redneck. So I hope that you can understand my southern
drawl. My name is David Neal. I blog at reverentgeek.com and you can follow me on the Twitters at reverent geek. I'm pretty active on Twitter and that's probably one of the best ways to get in contact with me after the talk. So if I don't get to answer
some of your questions or there's other things that come up after the talk that you think about, Twitter is probably the best way to get ahold of me. And you can trust me because I do have a beard and I like to ride motorcycles and I consume copious amounts
of bacon and caffeine. And the bacon here is a little bit different than what I'm used to. I've been told that it's called streaky bacon is what I'm used to eating. Maybe it's just not enough and some of the bigger, thicker bacon here is better. I'm also
finding other strange things about differences between the U.S. and the U.K. I'm wearing my lucky camouflage suspenders which I've been told is I'm not supposed to call them suspenders. I'm supposed to call them something else. I just don't get it. Bracers or braces.
That's what kids put on their teeth, right? It's braces. So, we're talking about Node.js and JavaScript. JavaScript, as you may have heard, I'm not sure if Scott Hanselman said this earlier today or not, but JavaScript has won the web. And there's also this thing
called the Atwood's law. It's a very genuine law. Any application that can be written in JavaScript will eventually be written in JavaScript. Case in point, if you searched for JS Linux, you can find an entire Linux operating system running in the browser all
written in JavaScript. Crazy stuff. And Douglas Crockford, a well-known author and one of the main guys in JavaScript community was on a panel a few years ago at another conference
and someone asked him the question about how important JavaScript was, and he said that JavaScript is tragically important. You may know Douglas Crockford from his book, JavaScript, the good parts, which is suspiciously smaller than most other books on the subject of
JavaScript. And so, up ahead, what we're talking about is why Node.js, why do we have a quick crash course on how to get started? We will look at some of the popular tools and frameworks, and we will look at some integration strategies, perhaps from a .NET
perspective, and I will try to map some .NET information over to Node.js as we go. So you're here because Node.js has just exploded in popularity over the last few years,
and it's in due part to the fact that it is JavaScript. Node.js is a JavaScript host execution engine that runs on the server, so that it's an alternative to writing server-side applications so that you can, as a web developer, it's kind of a nice thing to have
is being able to focus on a single language of JavaScript, so we're already writing JavaScript on the web for the client side, you know, it's very nice to be able to use JavaScript on the server as well. How many would consider themselves web developers? Right? Good. So you all understand the importance of JavaScript and how convenient it might be
to use JavaScript on the server. Another thing about Node.js, it uses the Chrome V8 engine. You might think that JavaScript being an interpretive language would not be very fast or efficient, and you may have heard some of the claims of scalability and
performance. How can you do that with something like a dynamic language like JavaScript? The Chrome V8 engine compiles JavaScript at runtime to machine code, so whatever platform it's running on, similar to .NET. .NET is not a binary language. It uses IL and compiles
that at runtime to run on whatever platform it's running on. So it's very similar in that regard. So, once it's compiled at runtime, it's cached in all those kind of benefits, so you get real good performance on from your JavaScript at runtime.
Now, JavaScript is, has a different runtime model than most other platforms. JavaScript and Node.js is an asynchronous single-threaded asynchronous event loop, and it seems counter-intuitive that a single-thread application would be able to perform very well, but because it's
not having to do like thread context switching and so forth, from an IO perspective, Node.js on that single-threaded event loop model can handle thousands, tens of thousands of concurrent connections and scale very well because of the asynchronous event model
that you're kind of forced into to fall into the pit of success. The patterns that you write your JavaScript with callbacks or promises and so forth, those things allow your application to scale as far as concurrency goes. The community for Node.js has also embraced this whole idea of JavaScript on the server,
so JavaScript being kind of a ubiquitous language for the web has attracted folks from all different platforms, from PHP.net, Java, just everything, so if you're a web developer,
regardless of what platform you come from, it makes sense to also focus in JavaScript. And the packages and modules that are available for Node.js, I think last time I checked, were well over 200,000 modules available, so it's like the app store. Whatever you
can think of, there's probably a module for that. The downside is there may be five or six modules for whatever you want to solve, so choosing which one is right for your solution might be a challenge. Compare that to, say, NuGet on the .NET platform, somewhere around
40,000 to 50,000 packages, I think. Another reason that Node.js is interesting is that Microsoft themselves have recognised the importance of JavaScript on the server. When Node.js
was first launched, it only ran on Linux. Microsoft in 2011 invested the time and resources into making Node.js available on the Windows platform, and Node.js is a first-class citizen in Azure. You can spin up Node.js applications in Azure as easily as you can in .NET, and
Microsoft also has recently made roads into using the Chakra JavaScript engine from Edge, being able to shim that into Node.js to replace V8. The reason they're doing that
work is so that you can run Node.js on ARM-based IoT and the Windows core-type devices. It opens up some interesting scenarios there. So, let me tell you a little bit about my
story. I work for this company called Linkit. You can see it on my shirt. We have traditionally been a Microsoft shop. We do ASP.net MVC and C Sharp, SQL Server, and Hibernate, and a whole lot of JavaScript and jQuery. We're a web application, so we have a lot of client-side work that we do. We've been around for many years, and we've gone from, we've got
a lot of, I guess you would call it technical debt, and a lot of, you know, we've grown as a company, and we were scaling our applications, and we found that scaling the solutions that
we've built over the last few years has led to a lot of frustration around, you know, can we even do what we're doing with our current stack of technologies? So we've started to look at what are the best solutions to solve some of the problems that we're having. And, because we have a web-based product and we spend a lot of time in the
JavaScript world, we've decided that JavaScript is a strategically important language for us. It makes sense for us to continue to invest our time in JavaScript. From a
recruiting standpoint, Node.js makes sense to us because now we're not fighting over a limited set of .NET resources in our community. We can expand our recruiting
efforts to any platform, any web developer who has JavaScript experience, who is an expert in JavaScript, we can leverage their skills, and it's a benefit to us that we bring in those kinds of folks from other platforms because now we have a polyglot environment where we're bringing in fresh ideas from those other platforms that help us to solve
problems in unique ways. And we found in our experimentation and the projects that we've done in Node.js that we have become much more productive. There seems to be so much less friction from the standpoint of doing a TDD or BDD-style approach of development.
We're moving towards things like microservices, and the clients in Node.js for technologies like RabbitMQ and React and Redis, those are, you know, those kinds of things get a lot more love in Node.js than they do, say, on the .NET platform. And the fact that
Node.js is cross-platform, we can target Linux servers for deployment and save on the cost of just production environments. And there's been a whole lot more of this now that we've started doing Node.js. I was on a team that was one of the first teams
to create some solutions in Node.js at my company, and a few weeks into the process, you know, I kept asking our guys, how do you feel about what we're doing so far? And
a lot of excitement and fun into adopting Node.js. There's a great article out on Nearform why Node.js is becoming the go-to technology in the enterprise, and the highlights from that article are rapid innovation and delivery, developer happiness, those kinds of things.
These are the same things that we have discovered in our company, as well as other companies that we've talked to that have gone the route of moving towards Node.js. To me, Node.js exemplifies the idea of start with the simplest solution that works,
and do one thing, and do it well. Node.js, at its core, is just JavaScript execution engine. It's very, very, very simple to get started, and it's so easy to pull in those modules that add additional functionality. So you start with a really simple application
framework and then you can build on top of that. And it does, it is focused at doing web applications. So the use cases are things like single-page apps, and API, and real-time, the ubiquitous hello world application for Node.js is a real-time chat server. Node.js makes
it really, really simple to set up an HTTP service and be able to communicate between different nodes in just a few lines of code. It's very easy to do. Otherwise known as the internet. So if there's anything that you're doing that's involving the internet,
Node.js is probably a good use case for it. Where Node.js seems to shine, in my opinion, is around the real-time streaming and the WebSockets technology, so if you're doing push notifications or any kind of real-time web applications, Node.js has been doing this
for much, much longer, and the tooling and the modules that are available for doing streaming is much more mature. There are lots of great use case studies for companies who have adopted Node.js. Fandango is a movie ticket organisation, and these are some of
the benefits that they have found in moving to Node.js. Another great article out on NearForm, and PayPal is another great case study. They ran an experiment. They wanted
to see how Node.js compares with their current environment. They were traditionally a Java application shop, and they wanted to build a new feature, a new application, one team building it in Java and one team building it in Node.js to see how it would compare.
What they found was the Node.js team was able to build the solution two times faster with fewer developers, and they ended up with less code and less files, and they also saw some significant performance improvements over the Java application. I think what's
really interesting about this case study is that they had been doing Java for years. These guys were the quote-unquote Java experts on their team, and yet the Node.js team, who, you know, right out of the gate, first time trying Node.js, they were able
to get these kinds of benefits and outperform the Java team. Walmart is another interesting case study. They ran an experiment on Black Friday in 2013. If you're not familiar with Black Friday, it's the Friday after Thanksgiving in the US where it's
like total chaos meltdown on the amount of retail traffic that happens, and so it's like the busiest, most critical day of the year for a retailer, and Walmart chose to launch their new mobile platform on that Black Friday in 2013, and this is the kind of
things that they saw, 200 million concurrent users, the servers that they were running Node.js on, and the results were they never saw more than 1 per cent CPU utilisation across their servers, and they were able to deploy updates in real time without any hiccups or
downtime, and they've since moved a lot of their services over to Node.js, and they're having great success with it. Who else is using Node.js? A lot of well-known companies
that you may have heard of. If you go to Node.js.org slash industry, you will see a much, much larger list of companies that are now using Node.js. DevOps loves some Node.js. DevOps, as you probably know, is really hot right now, and these are some
of the reasons why DevOps would, in our experience, they love being able to easily deploy these small footprint applications cross-platform. It fits right in with Docker
or containerised applications. The fact that it's event-driven and there are OSS tools around like telemetry and logging and so forth for Node.js, there are a lot of benefits from a DevOps perspective as well. I don't know if you can read this chart, but it
is how long have you worked with Node.js and do you like your job? And that's really exciting to me, looking at the future of my career, that it seems like the longer you work with Node.js, the happier you are. That comes from what Node.js is used
for, the 2015 Node.js overview report from Rising Stack. It looks very promising. Let's switch gears now and take a look at how we can get started with Node.js. Installing it is really, really easy. You can go to Node.js.org and click the big fat
green install button. If you're on Mac or Windows, whatever platform you're on, it will give you the appropriate download. How many here are on Windows? Have you seen how many have used Chocolaty? I see more and more hands every time I give my talk, which is good. This is worth the price of this talk right here, is getting introduced to
Chocolaty. Chocolaty is kind of like an app get for Windows. It makes it really easy to download and install dependencies or applications on your PC. You go to Chocolaty.org
and it is literally a one-line that you can copy and paste into your command window to install it. After that, you can do things like Choco install Node.js. I'm on a Mac but I still use a lot of VMs for a lot of Windows things that I maintain in Visual Studio,
and every time I stand up a new VM on my Mac, I just have a series of Chocolaty install scripts that I can run through and have my Windows machine set up in a matter of minutes. After you install Node.js, this is what you get. You get two command-line
executables. One is Node, and that is the execution engine for launching your JavaScript, and you literally just type Node space and then some JavaScript file to launch it, and
the other is MPM which is the package manager. This makes it really easy to download and install packages or modules for your Node.js applications. So nothing too exciting there. It is just two command-line executables. Just so that you're aware, on Windows, there
may be a couple of other dependencies that you need. For the most part, the vast majority of Node.js modules are written purely in JavaScript. However, there are a few that rely on C libraries. These are cross-platform C libraries that when they come down from the
MPM, they need to be compiled for your local architecture, and when you're on Windows, there's a couple of things you need. You need Python 2 which you can install from chocolates, or you can go to Python.org and download. It needs to be version 2. There
is a version 3, 2.7 something is probably what you need. The other thing you need is a C++ compiler. You may already have that if you have Visual Studio, but just to make your life a little bit easier, you may want to get specifically the 2010 express
version of Visual C++. The reason is the modules that are available, or the modules that have C code in them, typically have build targets in for this particular version
of 2010. So just to, you know, it is pretty simple to install. There are ways to instruct your instance of Node.js to use whatever version of Visual Studio you may have. There are flags you can use at the command line. Just to save time and frustration, this is probably what you will want to do. There are also Node.js tools for Visual
Studio. If you're already familiar with Visual Studio and that's your preferred editor, you can download this and be off and away editing and creating Node.js projects from within Visual Studio. You will need 2012 Pro or the latest versions of 2013, 2015 community
editions. If you're running 2012 Pro or 2013, you will want to make sure that you have the latest Visual Studio updates. And another alternative is that if you don't
want to install the Node.js tools, or for some reason you can't install the Node.js tools, if you're an MSDN subscriber, you already have access to a lot of Azure credits, you can go to Azure and create a VM from their library that already has Visual Studio and the Node.js tools installed so you can play around with that before you do anything
with your local environment. And with that, I want to show you a quick demo of using the Visual Studio and the Node.js tools. So I have Visual Studio 2015 in a VM here,
and I have the Node.js tools already installed, so when I click on new project, one of the things that the Node.js tools give me is a set of project templates for Node.js. So I can do things like start from a blank Node.js web application, or an express, or some
version of Azure. So I've got a lot of templates to choose from. I'm going to choose the basic Node.js express 4 application. Express is arguably the most popular MVC-style framework
for Node.js. Node.js, like I said, is very, very simple. It has some libraries built in for doing networking and file IO and HTTP services, so it's like real low-level stuff, so you'll want to use something like express as like a starting point for building a web
application. So you might say this is kind of like ASP.net for Node.js. I'm just going to click okay here. And one of the reasons why it's taking a little bit longer
than usual is that there's a number of dependencies for express and the other modules
that it's depending on. It's going out and fetching those things, so a little bit of this time is probably due to Wi-Fi access. So now we have a Node.js application, specifically express, and if you want to play around with this, you will probably,
if you've seen some of the demos for the ASP.net, you will see a lot of ideas, similar ideas and things that ASP.net has borrowed from Node.js as far as the composability
and plugins and so forth of building up an application. I'm not going to really go into the code very much, but I do want to show you just what the Node.js tools give you in Visual Studio. I can set breakpoints, like I will set a breakpoint right here, and I can launch this in Chrome, and I've already hit my breakpoint, and if I mouse over, I
can see things like I can see all the properties and methods that are on that object. I can see things like my locals down here. I can set watch and breakpoints, and I also
have a call stack. So all the debugging features that you would be familiar with from Visual Studio, you can build your Node.js applications the same way, and you can play around with the, you know, in the immediate window, you can set, change, play around with different
values for your variables, and do things like that. If I continue on, then it launches my application, and I've got express, welcome to express. Microsoft went to a lot of trouble to make sure that it looks like a really awesome starting template, right? The other
thing that the Node.js tools will give you is under tools, Node.js tools, there is a Node.js interactive window, so control K N, and what this gives you is a bit of a
REPL, an interactive window where you can play around with the modules that you have installed and be able to do expressions and things like X equals one, Y equals three,
X plus Y, and you can play around the JavaScript language, and, you know, it's a good way to learn the tools and learn how to, you know, maybe you're going through a Node.js tutorial online, or reading through a book, or something like that, this is a way to make it really easy to play around with Node.js. I want to show you some other things.
You may have heard of Visual Studio Code, right? So Microsoft's done a good job of advertising
that they have this new editor called Visual Studio Code, and it makes it really easy to build web-based applications, and Node.js is a first-class citizen for Visual Studio Code. It's a really nice editor. My first reaction was, well, it's cross-platform.
It runs on Linux, Mac, and Windows. How did they accomplish that? My assumption was they probably use Xamarin. Xamarin is supposed to be cross-platform and Microsoft has a good relationship with the Xamarin team. Turns out this is actually a Node.js application. Visual Studio Code is now open source, and you can go and look at it. It's an Electron
application similar to GitHub's Atom editor, and so Microsoft, again, showing that they are embracing, you know, the larger open source community, and using tools that are outside of the Microsoft normal ecosystem. Very interesting. So they are calling it a
code assistance, but it does have really good debugging tools, so the kind of debugging experience I just showed you in Visual Studio, you can set break points, and you can have the locals, and you can set watches, and you can step through your code, and you can inspect variables. You can do all those same kind of things. You can
do it in this really lightweight editor that makes it really easy to create. Now, I talked to you about, let's talk about a typical workflow of building a Node.js application. The two command lines you get is Node and npm, npm being the package manager. So if you're creating a brand-new Node.js project outside of Visual Studio,
you will probably want to start with the command line and use npm init to initialize this special file called a package.json. The package.json is a manifest for your application. It lists things like the author, and the version number of the
application, and any dependencies that your application has. So it's kind of both your manifest and your package, NuGet package list, if you will. So, after you do npm init and initialize your package.json file, then you will start
installing dependencies that you have, like npm install low-dash, low-dash being a very popular functional utility library that may have been using in your client-side applications. There's a lot of client-side libraries that you can
also use on the server side. And the dash-dash save is important because that's what it instructs npm to save that entry into your package.json file. So that when you go to distribute your application, install it on another platform for, you know, in production, it can read that package.json file and
know what dependencies it needs to download and install. A typical Node.js application looks like this. You will see at the top of the file some things like require statements, and these are similar in .NET to the using
statements. So, this is how you import in your modules and reference those in your Node.js application. So there's two forms of require. One is require that just is the name of the module, and that's for built-in Node.js modules
like fs is the file system module for doing file IO, and express would be something that you would pull down from npm. In your own application, as you create your own modules, then you reference those by a relative path like slash app slash my service. And, in some cases, you may need
those. Most of the time, when you reference a package or a module in Node.js, it's not only creating a reference to it, but you're creating an instance of it, and you can use it right away. There are some modules that require you to initialise kind of like using a constructor
function. So, in this case, my service is a constructor function that takes in a number of parameters to initialise that module, an instance of that module. And then the typical callback pattern that you will see in Node.js is this. You will have some method, and you will pass either
one or more parameters or zero parameters as far as like arguments to that method, and then the next thing is a callback function. A callback function is a callback. It means when you're done executing this method, let me know the results of that, and send it to this
function. So the callback is like an async and await pattern. This is how it's able to do a lot of concurrency on that single-threaded event loop. You're not blocking on that method. You're saying, go
do this work, and, when you're done, let me know, and the typical pattern is the first parameter returned on a callback is always the error object. You want to inspect that error object to see if that method did raise any errors. It can throw exceptions as well, so you
need to watch for those kinds of things, but, typically, instead of throwing errors, it's just going to pass error information through that error object, and then your results, and there may be other parameters that are returned back from the method that you're calling. Creating your own modules, there's a couple of
different ways when you're creating your own modules that you want to do this. Here's an example of a module I'm creating that has some utility functions in it. One is convert to Celsius and convert to Fahrenheit, and then I've got some values. In
objects, it's a dynamic language, and you can create your own objects on the fly just by saying like this plain old JSON here. I'm just saying it's got these properties, freezing Celsius, freezing Fahrenheit, boiling, those are just properties on that object.
The interesting thing is this guy down here, module.exports. Whoops. That's the secret sauce right there. So, when you're declaring your own modules, you're exposing whatever properties and methods you want to the rest of the world through
that module.exports. I can control, I'm exporting this object, and this object has properties and a couple of methods, so, when I require this module in somewhere else, I'm going to have the ability to call these two methods and to
access these properties. Another typical module pattern that you will see is a constructor function. So, in here, I've got a config module that I'm declaring. I'm also requiring in the file system, and I'm reading some config data, and I've got some properties on getting and
setting configuration information. The interesting thing is the return statement. These are my methods that I have, and I have this one here called internal function. When I return from that constructor, that JavaScript constructor function, I'm only returning get, set, and save.
I'm not returning internal function, so that's kind of like a private member of that module. I can still use it inside that module, but it won't be exposed to the rest of the world. Of course, I've got module.exports and that function. I get asked a lot about SQL databases,
about how do you access SQL Server or some other relational database from Node.js. There are a number of modules that are available. MS SQL is the most popular.
My favourite is called Seriate. It's actually a module that sits a little bit higher than MS SQL. It has MS SQL as a dependency, but it provides a lot of nice features that are a little bit opinionated, but I think it
turns it into more of a micro-ORM. If you're familiar with something like dapper as being a really, really lightweight micro-ORM, you might think of this as an equivalent. So, Seriate allows you to, once you install it and require it in, you can set your config information.
Your config information typically comes from environment variables, so, instead of having like a config file like you have in .net, you will have environment variables, and that way, when you go to deploy your application, like in Azure, there are places
to set those environment variables, and you can do it that way. But here we are just passing those values in on the default config, and then I can do things like execute a query, and this can be not only just inline SQL, but it can be a stored procedure, it can be a
reference to a SQL file that has all the SQL in it. It supports parameters, and input-output parameters, all things you would expect. And then this is an example of promises. So, instead of a callback function, you're saying go execute this application, or this method,
and, when you're done, then call this promise, this then module function. The interesting thing about Seriate is that you can chain, because it's promises, you can chain these together. You can say execute
this SQL, then pass the results of that statement to this next SQL statement, and you can chain SQL statements together, which is a typical workflow for building a data-centric application. You're not always, you're typically having to go and retrieve
results here, and based on those results, go retrieve another set of results, that kind of thing. So, any questions about the code that we've seen so far? All right. Good. So, deploying Node.js. It's really,
really easy. Typically, you don't include the node modules folder. What I'm talking about there is when you install an npm package, you do npm install, then something like Lodash, those things get added to a special folder named node underscore modules, and,
like I said before, those can be compiled sometimes if they include C code to your particular architecture. So, if you're developing on one platform, if you're developing on a Mac or a Windows, some Windows 32-bit architecture, and you're
deploying to a 64-bit architecture kind of thing, then you don't need to include this node modules folder. Everything you need to run in production is going to be listed in your package JSON file, and so, when you deploy your application, you're just going to run npm install without any parameters, and
it's going to read your package JSON and install all those dependencies for you. Alternatively, if you do know your specific build targets or your platforms that you're deploying to, you could set up a CI server that is the exact same architecture as your
production servers, and do your builds there, and then package everything up into a zip file or something to move to your production environment. Building for Azure, deploying to Azure is really easy. As I mentioned before, Node.js is a first-class
citizen in Azure, and they have a number of templates available for you to get started, some either starter web application or VMs. If you're deploying to Windows, regardless if it's Azure or your own VMs or own hardware, there's a couple of options you need
to be aware of. One is IIS node. This is a way of hosting. If you're just deploying a web application, you probably want to use IIS node. This allows you to run a Node.js application through IIS, and IIS makes it efficiently, it can, depending on, like,
say your server has four cores, it can spin up four copies of Node.js so that you're taking advantage of the cores that are on that server. And it handles hands-off each request to kind of in a round-robin fashion to whichever instance of
Node.js is available. But it allows you to scale easily on a single box. Windsor, if you're developing, like, a microservices architecture or you're creating just a service, maybe it's a worker service that's listening to a queue that's doing
some commands or doing some work for a distributed application, then Windsor is probably something you want to use, because Windsor makes your Node.js application look like a native window service that you can pause and start, restart, stop, those kinds of things, and it will make sure that your
application remains running, so if it does crash, it will automatically restart your application, typical window service behaviour. On Linux, if you're deploying to Linux, you probably want to use something like Forever, which does the same kind of thing. It ensures that your application is always running. If it crashes, it will restart it, so forth. I already mentioned on Azure, you
can create an empty Node.js website. You can do things like connect to a repository. This is what I do for my own blog. My blog is a Node.js application, and it's hosted on GitHub, and any time I make a push a change to my Node.js
repository, Azure instantly gets that notification and will download the latest version from the repository and redeploy it, so I can get a fresh new version of my blog pushed in less than a
minute, and there's a lot of folks that do this same kind of deployment, either it doesn't have to be GitHub, it can be Visual Studio Online or what they're calling it now, Visual Studio Team Services, and a number of other repositories that you can connect to. I've got an article out on my website, Reverend Geek,
hosting Node.js on Microsoft Azure, and I go through some of the steps of both doing a repository-based approach or setting up your own VM and using something like Windsor, or hosting using IIS nodes. I go through all those options in detail, and it's really easy to do.
Recommended toolbox. So, in my experience, and with the guys that I've worked with, this is what we found to be some really useful modules, Lodash being just general functional utilities that you're probably already aware of, similar to Underscore. Win is a promise library,
and makes it really easy to callbacks can get, you know, start to get really hairy with callbacks that have callbacks that have callbacks, so promises is a much more cleaner way of having that kind of asynchronous pattern
and just having, you know, chainable calls of then, then, then, and then when you're finished. Async for a parallel asynchronous and parallel execution, so maybe you have five tasks that you need to run, and then let me know when all five of those are finished. You can
think of it as kind of like the task parallel library in .net where you can do things like execute lots of things either in parallel or serial and be notified when those things are finished. Request, or rest, those are really
good HTTP clients, so if you're depending on other web services in your application, you're creating a mash-up and you want to be able to call into other web services, or maybe you have web services already in your environment that you have dependencies on, this makes it really easy. Gulp, and there are a number of
others, you've probably heard of Grunt and lots of other build systems, but we use Gulp, it's a great as a build engine and test runner. Socket.io for sockets in real-time. Node Inspector, so if you want to dive head first
into the world of Node.js, you may want to use something like Atom, or Sublime Text, or even Visual Studio Code, and break ties with big IDEs. It's really an awesome development
experience just having lightweight editors for JavaScript. Node Inspector allows you to launch your Node applications with the Chrome debug tools, so you get a great, if you're already familiar with the Chrome debug experience of being able to set break points and step through your code and look at all
your variables and so forth, you can do the same thing with your Node.js applications using Node Inspector. This is what I use all the time. I develop my applications in Sublime Text, and I launch them with Node Debug, and I'm able to use Chrome as my debugging tool,
and it's really awesome. Mocha, Chai, and really good testing frameworks, so if you want to see what is all about in the TDD or BDD world for Node.js, those are the tools to use, and really, really less friction, as
I mentioned before. It's so much easier to build and maintain a TDD or BDD-first approach in Node.js because of the nature of JavaScript. There are a number of popular frameworks. We talked about Express. There are
things like Happy, Meteor, and Sales. Happy is the web server open-source community around Walmart. Walmart originally called this under Walmart Labs. Happy has grown. They've got tons and tons of other modules and support features that you can bolt on, and
it's a really, really impressive framework. There are a couple of books out on Happy now. If you're building just straight APIs, Happy is great too, but there are also ones that are some frameworks that are specific to APIs. Restify, Loopback, which is from
Strong Loop, which is now part of IBM. Loopback does things out of the box like push notifications for mobile applications, so it's a great platform for doing mobile apps. Autohost and Hyped, those are good clients
if you want to do a hypermedia approach to APIs, so if you want to support the hypermedia documents with links and so forth, that platform makes it really easy. A couple of other resources, if you go to nodeframework.com or nodewebmodules.com, that's kind of a curated list of the
most popular frameworks for doing web applications and MVC-style applications. Another thing I want to tell you about is Edge.js. If you are a .NET developer, this may be of interest to you. Edge.js is a bridge between .NET and Node.js. It allows
you to run .NET code in process with your Node.js application, so you can create a Node.js application and reference your .NET code and take advantage of those libraries that you may already have. And it's not
just C-sharp code, you can take advantage of F-sharp, Python, PowerShell, anything that you can execute in a .NET world. You can reference, you can do inline code, or you can reference CS files, or
assemblies. And it's a great alternative, as I mentioned before, you know, the typical, typically you find either pure JavaScript or a mixture of JavaScript and C modules, and if you're needing to create something that's outside of what
you may want to do with JavaScript, or you really need to do some CPU-intensive work that requires multi-threading, .NET Edge.js may allow you to build that kind of solution instead of having to write it in C. It does require .NET 4.5 or
mono 3.1 and above. The reason for that dependency is you need to have async and await support. If you don't have async and await, then you're going to be blocking that main thread, and you need to be able to play well in the single-threaded event loop model
that Node.js has. Edge.js can work both ways. You can also use Edge.js inside your .NET application to call into Node.js. If there's something in Node.js that's really awesome that you want to add that functionality into your .NET programme, you can do that.
What can you do with it? You can leverage existing .NET investment. There are modules available in Node.js for things like TFS and SharePoint Exchange, but, typically, they are half-baked. Maybe they're not
well-supported. The Microsoft stack doesn't get quite as much love in the Node.js community as most other open source tools do. Open source is always the number one thing that the Node.js community wants to focus on. If you do find a module for some
Microsoft technology in Node.js, it's typically not fully featured. Even the SQL module that Microsoft created never got out of alpha and would not use that in production. Active Directory, maybe you want to access local hardware from
Node.js, maybe you want to automate some things, use a 3D printer from your Node.js application. I can't really think of a scenario why you would want to do that, but it does open up those kinds of possibilities. Again, if you're doing really CPU-intensive work that is not well-suited for JavaScript
and the single-threaded event loop model, you could offload some of that work to a .NET module. And PowerShell. That opens up some interesting scenarios from a DevOps perspective. Let's talk about some Node.js integration strategies. You could use Node.js as a proxy.
This is how a lot of companies have introduced Node.js in their organization. PayPal, Walmart, and my company, a number of other companies, we've introduced Node.js as a proxy service that is just a middleware layer. Incoming requests come in, they hit Node.js first. Node.js in that proxy
scenario can decide, is this something we want to handle? Can we handle this request natively using Node.js or do we need to hand that off to some other back-end service in .NET or Java or whatever system we were using before? You could use something like SJS to access .NET
code. You could use the request module or REST module to be able to call into other APIs in your architecture, in your infrastructure. Then there are things like messaging. The clients that are available in Node.js for RabbitMQ and Azure and a number of other message
buses are really, really powerful, really great. This is the approach that we are taking with being able to distribute the load of computing across our different, you know, .NET or Node.js modules or applications and services, and
it works really well. One more thing I want to tell you about is this awesome thing called Electron. I've given a talk on this at a number of other conferences. Electron is the desktop shell that Adam and Visual Studio Code and even applications like Slack, so if
you use Slack desktop client, you've probably used, you're using a Node.js HTML and CSS application, and you wouldn't even know it. It's a web application, and Electron is open source and you can use it to build your own cross-platform desktop
applications. I've created a number of tools for our customers that now I don't have to worry about, you know, I'm a .NET developer, so I was kind of forced to use the .NET, you know, I was building solutions that I would hand off to clients, and my clients would say,
well, we don't even use Windows here. Well, let me see what I can do. I went back and tried to use Xamarin Mac to create a Mac version of my tools, and, to be honest, the Xamarin Mac is not nearly, doesn't get nearly the amount of
love that the iOS and Android tools get, so it's much harder to create a desktop app using .NET than it is to use something like Node.js and Electron. The last thing I want to tell you is you don't need permission to be awesome. So we as
developers, we are, I truly believe we are in a unique position, a unique set of skills, and we have opportunities that we can change our environment and our world in significant ways. And so the things that you're learning here at this conference, please
take those back and change your world. With that, I would like to thank you again for coming to my talk. These are some contact information and
resources that you can get on my GitHub repo. I've got some Node.js demos and a list of everything that's in the, I've got these slides as well as a list of all kinds of resources, and if there are any questions, we've got a microphone here, I'd be glad to answer for the next few minutes. Well, for the
recording purposes... Electron is cross-platform, does that cover mobile or just desktop applications? It's just for desktop, so you can think of it as the phone gap Cordova
equivalent. So Electron does allow you to leverage a lot of your existing JavaScript and HTML code that you may have created already for your web app or for a mobile app. So if you're doing a hybrid mobile application, you could probably use the same, a
lot of the same JavaScript and HTML that you've used in those cases and be able to create a desktop version. But as of now, Electron is just for Mac, Windows and Linux desktops. Now, I think there are some interesting scenarios that will probably happen
down the road. I mentioned Microsoft has done work to enable Chakra as an alternative JavaScript engine, and that opens up a lot of possibilities. That may open up some possibilities of going mobile with Node.js. It's a possibility. Yep.
Is there any package that's like link that you can use to include? Like link? Like language integrated query? Right. I am not aware
of any, but I would be really surprised or shocked to find that there weren't some type of expression language like that for Node.js. So I am sorry I don't have a direct answer for you, but I would, you know, if we, I can search NPM later.
And we can find that answer. Yes? It's a question about IIS node and Edge. They seem like good ideas, but are they ready for production? Have you used them in your deployments, and how has the experience been?
So we have never used EdgeJS in production at my company, but I know that EdgeJS has been used in production at a number of other companies. If you're targeting the Windows platform, deployment is pretty easy, because you already have the .NET framework available for EdgeJS,
and there's not really any additional work to be done. Yes. Yeah, it's really easy to get IIS node. And if you deploy to Azure, IIS node is the mechanism for which
you are deploying your Node.js applications. Microsoft uses IIS node to host your Node.js application and to make it available as a web application. Anyone else? All right. Thank you very much. Don't forget the giveaway stuff up here.