What is Node.js?
As this was my first week delving into the world of Node.js I thought I’d do a quick blog post explaining what it actually is, what it does, and why it’s cool.
Another cool thing (but quite confusing) is that it’s asynchronous, which basically means it can handle a lot of connections at once and does simple tasks such as reading and writing to databases super fast, which is quite important when building web applications. The only problem is that when running tests, all tests run and complete simultaneously, which is a bit of a problem. Imagine you’re using databases and trying to test a form on a webpage, you’d want to load the form, populate that form with text, write it to the database and then read and display it on a new page. Simple enough, however the problem is that this is all being done at the same time, so you’re expecting a page with text that hasn’t been saved in the database yet. That’s where callbacks come in. Simply put, callbacks just delay things, so we’d want the page to load, then we’d want to fill that form that’s been loaded, once that’s done we’d want to write the text to the database and so on… It’s just organising the order in which we want things to happen.
NPM (node package manager) is also pretty cool and has a load of modules that you can download and use in your program. There’s a variety available for both back and front end and they’ve been designed by the community in order to make everyones life that little bit easier. You can have a look at the vast array of packages available here.