Introduction to Node.js
Node.js is a JavaScript (JS) interpreter that doesn't depend on the browser, creating the possibility to execute js code in other environments. Most browsers have a javascript interpreter internally in their core which is why they're capable of interpreting it.
Talking about NodeJS is talking about Javascript. It revolutionized Javascript because it brought this language to do much more than create web frontends and visual effects.
Now we can create:
- Backend applications
- CLIs
- Desktop applications
- Artificial Intelligence
- Etc
V8 is Google's Javascript engine that's present in google chrome and is used by NodeJS. It's responsible for understanding the language.
Some libraries enhance the language's functionalities, such as libuv focused on asynchronous I/O communication that allows using nodejs to develop backends.
Node Advantages​
- Lightweight.
- Uses little memory.
- Good CPU utilization.
- Gigantic ecosystem of libraries, modules, and plugins and a very active community.
- Asynchronous and non-blocking performance being great for intense I/O like chats, games, streaming, etc., as it efficiently manages multiple connections.
- Great scalability due to having an event-based architecture.
- Ease in real-time development.
- Easy deployment.
- High demand for professionals in the market.
- Used in front and backend being able to maintain a full stack javascript application.
Disadvantages​
- Not a language with good performance for heavy computational operations involving many calculations. Very heavy calculations can block the event loop degrading the application's overall performance even more.
- In large-scale applications managing requires the code to be optimized to avoid memory leaks.
- Code standardization requires greater effort, as javascript offers a lot of flexibility.
- Not a strongly typed language increasing chances of errors, although typescript mitigates this.
- Wide range of libraries difficult to audit, possibly suffering from attacks. Careful selection of libraries is necessary.