The first is performance. It feels like the performance of Node.js is not as good as imagined. The memory usage is almost at the same level as Ruby, and more than Python and PHP. In terms of computing performance (that is, CPU usage), pure computing does not have much advantage, but because it can control the asynchronous process well, the overall performance is much better than PHP. Personally, I feel that Node.js has great potential in terms of performance, because there are many large projects dedicated to improving the performance of JavaScript virtual machines - such as major browsers; at the same time, JavaScript is a language with simple syntax and a Open standards, unlike Python and PHP, are difficult to carry out major reconstruction to improve performance due to concerns about compatibility.
Then there are package managers and libraries. Node.js has npm built-in, because npm is a very easy-to-use package manager, because the threshold for writing JavaScript is low, and because JavaScript has many excellent front-end libraries that have been ported to the backend end, so the number of packages on NPM now exceeds that of PyPI and RubyGems, and far exceeds that of PEAR and Composer. One thing that is different from PHP in the development of Node.js is that no one is afraid of adding dependencies, and every small requirement is found on NPM. There are existing libraries to implement this - and they can often be found. Therefore, the development of Node.js is basically combining dependencies, and then tends to write even a small independent requirement into a library. This is more similar to the UNIX idea. On the other hand, the Node.js community is very friendly to open source. Friendly here means that most libraries are open and developed on Github, and they use very loose protocols, such as MIT, which are not as "open source" as GPL. Aggression".
In the community, most Node.js applications are still Web backends, and Web backend-related libraries are basically created by a few big guys, such as express, jshttp, jade, mocha and koa, led by TJ. It was developed by four or five people led by the leader. This is an interesting phenomenon. ——Although Master TJ finally decided to fade out of the Node.js community.
Tool chain, Node.js is relatively young, and many useful tools have just appeared in the past two years, such as precompiled dialects, unit tests and simulation tests, build tools, etc.; I can’t say how good it is, but it needs to be Much better than PHP. As for the reasons, first of all, it is largely because these libraries can be used for both front-end and back-end. Because of the hard requirements of the Web front-end, Node.js benefits by the way; and secondly, because of the flexible and simple syntax of JavaScript, these libraries Tools can do this in some very clever and elegant ways. As for IDEs, still benefiting from the web front end, there are still some IDEs available - although the JavaScript language itself is not very conducive to static analysis.
Grammar, I would like to emphasize again that the syntax of JavaScript is simple and flexible. The important point is JSON. JSON is almost the most common data format in the web field, and JavaScript has native support for JSON! All data structures in JavaScript are centered around Object, a superset of JSON, including arrays, functions, objects and classes. Of course, this also brings a trouble, that is, because there are few restrictions on writing, I don’t know how to write. When I first started learning, it was inevitable to refactor repeatedly in order to understand the advantages and disadvantages of various design patterns in different situations and find the suitable one. It can be said that it is easy to get started with Node.js, but it will still test the developer's skills to build large-scale projects. Due to historical issues, the syntax of JavaScript is not beautiful, but fortunately we have various precompiled dialects, such as Coffee Script, TypeScript, Dart, LiveScript and ClojureScript, there is always one suitable for you.
Usage scenarios, JavaScript is a general programming language, and there is no need to talk about the front and back ends of the Web. Let’s take a look at other aspects. Personally, I think Node.js is still very suitable for writing server tools, or operation and maintenance tools, because many situations in operation and maintenance can work asynchronously, and JavaScript has relatively good regular support, so it is not a big problem to replace bash and Python. ; Node.js only needs to install the interpreter, and you can use it casually without fear of introducing dependencies. For desktop and mobile device programming, Node.js has node-webkit and various other shells. Although the current user experience is not very good, it can significantly reduce development costs and easily cross platforms. The future must be bright.
Finally, let’s talk about learning Node.js. In my opinion, there are two points to learning Node.js. One is to clarify the “asynchronous IO based on event callbacks” of Node.js, which is the difference between Node.js and other mainstream programming. The most different thing about language. Then the second step is to take a look at all the top 100 libraries on NPM. You don’t need to read them in detail. Just be familiar with them and know what each library is for. After completing these two steps, congratulations, you are already a Node.js developer.