In fact, it does not mean that you must learn node, but for better development in the workplace, especially to learn more advanced programming thinking, it is necessary to learn node.
The following is a detailed explanation of the necessity of learning node [Recommendation: node.js video tutorial]
1. The most fundamental ability of node.js is to enable js to run without the browser. Learning node well can make you no longer a "pure front-end" "
2. Learning nodejs is the basis for front-end engineering (NodeJS Stream)
3. Learn node well and be able to write server-side APIs and implement independent development projects.
4. As the middle layer (extended question: What is the middle layer?)
The middle layer (BFF) is also called the application layer. It is between the service layer (Java) and the client in the architecture. Its main function is to
Why do you say that the front-end often needs to write its own API?
1. Classic two-layer structure: front-end + server
2. Three-tier structure: front-end + back-end + server (the structure currently used in medium and large projects)
The server side of the three-tier structure is only responsible for operating the database, managing data, and returning data to the backend. It is basically pure data. The backend does not include data services and is the so-called middle layer. If the front-end is developed, nodejs is preferred. Because the learning cost is the lowest for the front end.
If your career position is to be a pure front-end for a lifetime, then you don’t need to learn nodejs. However, in fact, it is difficult to be a pure front-end for a lifetime. Generally, by the age of 35, your ability is only to “move bricks”, so in the workplace The value will become lower and lower.
CTO is often served by server-side engineers
for the following reasons:
1. The technical architecture of the entire company needs to be designed.
2. Problems need to be considered from a global perspective
3. Need to control the company's most important asset: data (whoever controls the data has the right to speak).
Learning node well does not mean that you can be a CTO, but at least it can greatly improve our front-end workplace status.
Technically speaking, it is a very fulfilling thing to use your own abilities to independently complete a project or product.
Even if all the previous reasons are eliminated, as a pure front-end, learning node has great benefits. It can cultivate our programming thinking and expand our perspective on thinking about problems.
Advantages, Disadvantages and Applicable Scenarios of NodeJs
Two major features of NodeJs: event-driven, non-blocking I/O
So the two biggest advantages of NodeJs
1. Handle high concurrency. Compared with other back-end languages, each connection emits an event (Event) running in the NodeJS engine process and puts it into the event queue, instead of generating a new one for each connection. OS thread (and allocate some companion memory to it)
2. I/O-intensive applications
Because of the single-threaded nature of JavaScript, NodeJs is not suitable for CPU-intensive applications. The main challenges that CPU-intensive applications bring to Node are: due to the single-threaded nature of JavaScript, if there are long-running calculations (such as a large loop) will cause the CPU time slice to be unable to be released, making subsequent I/O unable to be initiated;
Solution: Decompose large computing tasks into multiple small tasks so that the computing can be released in a timely manner without blocking the initiation of I/O calls;
Applicable scenarios for NodeJs :
RESTful API
This is the most ideal application scenario for NodeJS. It can handle tens of thousands of connections. It does not have much logic. It only needs to request the API and organize the data to return. It essentially just looks up some values from some database and composes them into a response. Since responses are small amounts of text and inbound requests are small amounts of text, the traffic is not high and a single machine can handle the API needs of even the busiest companies.
Unify the UI layer of Web applications The current MVC architecture, in a sense, Web development has two UI layers, one is what we finally see in the browser, and the other is on the server side, responsible for generating and splicing pages.
Applications with a large number of Ajax requests, such as personalized applications, each user will see a different page, the cache will be invalid, and Ajax requests need to be initiated when the page is loaded. NodeJS can respond to a large number of concurrent requests. In short, NodeJS is suitable for applications with high concurrency, Scenarios with intensive I/O and a small amount of business logic.
What is the purpose of learning Nodejs? For more details, please pay attention to other related articles on the php Chinese website!