What is Node.js
Introduction
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It is one of the most popular platform for building web server applications.
I use Node.js at work, and find it is very powerful. The Nodejs community is vibrant and growing. JavaScript, despite its oddities can be a great language to code in. And you will daily rethink your own understanding of "best practice" and the patterns of well-structured code.
There's an enormous energy of ideas flowing into Node.js right now
Advantages of Node.js
Here are some advantages about Node.js:
- Web development in a dynamic language (JavaScript) on a VM that is incredibly fast (V8). It is faster than Ruby, Python, or Perl.
- Ability to handle thousands of concurrent connections with minimal overhead on a single process.
- JavaScript is perfect for event loops with first class function objects and closures. People already know how to use it this way having used it in the browser to respond to user initiated events.
- A lot of people already know JavaScript, even people who do not claim to be programmers. It is arguably the most popular programming language.
- Using JavaScript on a web server as well as the browser reduces the impedance mismatch between the two programming environments which can communicate data structures via JSON that work the same on both sides of the equation. Duplicate form validation code can be shared between server and client, etc.
Disadvantages of Node.js
Here are some disadvantages about Node.js:
- Callback Hell: Everything is asynchronous by default. This means you are likely to end up using tons of nested callbacks. Nevertheless, there are a number of solutions to this problem, e.g. caolan/async or Understanding promises in node.js . This problem is specific to JavaScript, not Node.JS.
- Single-threaded: Node.js is single-threaded. You can take advantage of multiple CPUs, but in general everything is designed to use the Event-Loop in order to achieve extraordinary performance. This can also be an advantage, since e.g write conflicts on files aren’t that relevant.
- JavaScript: I really like JS, but there are some obvious drawbacks (But every programming language sucks, just read YourLanguageSucks - Theory.org Wiki).
- Event Loop: The Event Loop is the core of Node.js and it’s a genius idea. But, Don’t use Node.js for blocking, CPU-intensive tasks. Node.js is not suited for stuff like that. Node.js is suited for I/O stuff (like web servers).
TL;DR
- Don’t use Node.js for CPU-intensive tasks.
- Node.js rocks for servers.
- JavaScript partly sucks. Use CoffeeScript in order to solve this problem.
References & Resources
Latest Post
- Dependency injection
- Directives and Pipes
- Data binding
- HTTP Get vs. Post
- Node.js is everywhere
- MongoDB root user
- Combine JavaScript and CSS
- Inline Small JavaScript and CSS
- Minify JavaScript and CSS
- Defer Parsing of JavaScript
- Prefer Async Script Loading
- Components, Bootstrap and DOM
- What is HEAD in git?
- Show the changes in Git.
- What is AngularJS 2?
- Confidence Interval for a Population Mean
- Accuracy vs. Precision
- Sampling Distribution
- Working with the Normal Distribution
- Standardized score - Z score
- Percentile
- Evaluating the Normal Distribution
- What is Nodejs? Advantages and disadvantage?
- How do I debug Nodejs applications?
- Sync directory search using fs.readdirSync