This article is participating in node.js advanced technology essay, click to see details.

Node.js is a server technology. We all know that the client requests the service and the server handles the request and provides the service. For the Internet, JavaScript was a completely client-side technology before Node.js, used in browsers to animate, manipulate the DOM, and so on. The back-end, the server, is implemented by PHP, Python, Ruby, Java, and so on. With the emergence of Node.js, the dream of unified model can be realized by using the same language at the front and back ends.

I’ve been reading a lot of people explaining what Node.js is, a lot of explanations, and a lot of other people’s explanations, until I heard something like this: “Node.js is one of those things where the front end decides it has to wait for the back end to do something about it, and then they just do it themselves in javascript.” Suddenly feel simple and rough, hit the nail on the head, ha ha ha ha have this feeling!

I met TypeScript

I have been using typescript for more than half a year since I joined the new company. It is a back-end business management system developed by nodeJS in a start-up company. It has grown to a large scale, supporting the company’s business processing of 10 million RMB per month. Many people who doubt whether NodeJS can develop background management can use it at ease. However, nodeJS is unable to handle large data processing functions such as reports, which often brings down the system. Therefore, JAVA is used to replace these functions.

Use feeling

In fact, I initially rejected typescript nodejs development because the people who built the project had left, and the structure of the project was very complicated. It took a lot of effort to set up the environment in Windows, especially in order to use a bcrypt encryption package, you need to install Python and C++ to compile it. Nodejs0.12 is still not available, and most annoyingly, the compilation speed is very slow after every file change, which brings me back to the pain of developing JAVA. Moreover, the service startup method is to compile front-end files and back-end files at the same time by previous shell scripts. Nodemon, Supervisor is not used. Later, I found that I could directly compile TS files using VScode alone, and the compilation was generally completed in 12 seconds, which was still much slower than my previous project, which was modified and restarted in 1 second, but it was still acceptable. So I don’t like typescript because of these bad experiences. It’s so much hassle compared to JAVA development.

To recognize

Many people say that Node.js’s syntax is flexible, hard to maintain, lacks typing, and is hard to refactor, but Typescript has already solved these problems. Pure nodejs doesn’t write as well as typescript. The main reason is that pure nodejs has weaker syntax and error prompts on webstorm and vscode, whereas typescript does a better job of informing and finding low-level errors during development rather than at runtime. In particular, ES6 support is more complete, and you can even use async and await features in THE ES7 proposal. There was a period of time is also very want to practice, fumble for a long time finally put the demo project run.