Welcome to the NodeJS crash course!
This course has been designed for you to learn NodeJS in the context of quick development without worrying too much about complex CS topics.
However, it is important for you to have at least some understanding of some programming language, so that you can easily transition and transfer that learning experience into the context of JavaScript.
The majority of the topics covered in this course are mainly based on the needs of the lab. That includes file-system manipulation, data transferring, data parsers, interaction with relational and non-relational databases, and cybersecurity. In this course, I will be explaining all of the topics following best coding practices, security guidelines and also some fundamental tricks so that the application that you will develop can be safely deployed to the internet. We will also be covering some front-end development, but that is not the main goal of this course.
During a course of 7 weeks, you will learn some really valuable concepts that will make you feel more comfortable and will provide a great basic understanding of the web-technologies that today drive the whole internet.
What is NodeJS?
NodeJS is a mixture between a framework, a platform, and a runtime environment. Moreover, this is a technology that has expanded over the past few years the backend capabilities of JavaScript. Traditionally, JavaScript is a language that has been used as the main technology to make websites interactive. Back in the 90's when all the web technologies started, the majority of the websites where static, which means that 99% of them we purely used to convey a snippet of information. When JavaScript arrived to the WWW, many developers where amazed by the different capabilities that this technology enabled such as constant communication with the backend server, animations, data processing in the browser, and some more...
Coming back to the definition of NodeJS... Being rigorous, a framework (in the software industry) is a structure and a defined technological aid that commonly contains some artifacts and concrete modules that are the foundation to create new software applications. On the other hand, a platform is basis for a certain piece of code to make it run, and obtain some specific output from it. It is normally defined by some rules, architectures and standards that govern it. A runtime environment is a virtual machine system that provides services and supplies to make possible the execution of a software program that is being executed. That might sound really obscure, since that is the technically definition of it. So, to make it easier to digest, let's explain the execution process.
How a program or a piece of code gets executed under the hood?
There are two (2) main ways in which a piece of code is executed and that is entirely inherent to the language chosen. Nevertheless, currently some languages like Python have both implementations in place.
Compiled vs Interpreted languages
So, imagine that there are 2 people that are part of a small restaurant: the cook(CPU) and the waitress. Now, there is a small issue between these two guys, the cook only knows a language that only the cooks understand (let's call it machine code). On the other hand, the waitress only knows English, and does not speak nor understand 'machine code'. Now, when the waitress has a new order (a piece of code), he has to find a way on how to make the recipe understandable for the cook. There are two (2) ways to achieve this goal. One is to use a printer that has a built-in function that transforms English into 'machine code' (AKA compiler), or the other way is to find a certain individual that knows both languages so that this person can do the translation 'on-the-fly' (AKA interpreter).
As you might infer from this analogy, there is a huge difference between having an interpreter versus using the printer that has the built-in function. In the case of the printer (compiler), it prints immediately the recipe in 'machine code'. In contrast, the interpreter might have some delay while understanding English and translating it into 'machine code'. And that is fairly what is happening under the hood. Of course, this is a level abstraction that encompasses more complex processes such as hardware interaction like memory and CPU. That delay can have an enormous impact on the execution of the order.
What is the point?
JavaScript is an interpreted language, which means that every single instruction that you write in a file called script is going to be read and translated by a certain interpreter program. And that is exactly what happens when there is a JS file being executed in your browser. The same is true for NodeJS, but with some additional complex nuances. Now, JS is a language that has a lot of restrictions such as file I/O, and it needs and interpreter that is embedded in the browser to run. Therefore, NodeJS has an interpreter and a compiler (among other components) that make possible for any JS script to run in the computer, and also interact with the filesystem. Now you can see the matrix in there!
Finally...
As you can see, it is not easy to have a concrete definition of what NodeJS is, but it is important to know what is behind the scenes. Up to a certain degree, this will help you to troubleshoot some of the issues that you might experience at some point during the journey!
Author:
Hugo Angulo