Job Recruitment Website - Job information - How to specify inline in node server.js

How to specify inline in node server.js

In the field of software development, front-end engineers used to be a very tangled profession. For a long time before the real development of Web technology, the front-end engineer industry has always been a sham because of its low technical threshold.

The mixed state of dragons. Many of them claim to be web developers, but they don't have any professional front-end skills. Some of the work is just simple manual work done by artists. At that time, many people were very

I don't think that one day there will be such a group of people living on these three technologies-HTML, CSS and JavaScript-and they think, how is this possible-these technologies all seem so simple, with them.

Just mix it casually. It's a joke to take doing these jobs as a serious business.

With the development of technology, people's views on front-end work began to change, and some people really changed from art designers to professional front-end engineers. JavaScript, used to be thought by many engineers.

Toys and dismissive scripting languages have quietly evolved into the core driving force to promote the development of the Internet. With the emergence of more and more browsers, it becomes more and more difficult to be compatible with various browsers with HTML and CSS, so

Pages compatible with various browsers have become the golden signboard of front-end engineers, and front-end careers have become hot.

Two independent user interface layers

Even after Ajax became popular all over the world, the main work of front-end engineers was once limited to browser windows. HTML, CSS and JavaScript are necessary for front-end engineers.

Among the three core technologies mastered, the only intersection between the front-end and the back-end is that the front-end needs to ensure that the back-end data can be output to the browser in a correct and appropriate format. In a sense, there are two UIS in Web development.

Layer, one is what we finally see in the browser, and the other is on the server side, responsible for generating and splicing pages. Because the traditional front-end basically has no way to decide how the server handles data spelling.

Then generate a page, because how the data is organized is often influenced by the technical framework chosen by the back-end engineers. The back-end does not understand some requirements of the front-end, and it is rarely convenient for them to choose from the front-end.

From the point of view of.

In the structure shown above, the UI layer in the browser is completely managed by the front-end engineer. The UI layer on the server side is the part that both the front and back end care about, and the rest is the bottom layer on the server side, such as the data office.

Core modules such as management, caching and access control are managed by the back end. Let's go back and look at the server-side UI layer we care about. What this layer usually does is to spell out the page template and place it.

Manage specific business interaction logic.

So the traditional front-end division of labor is that the front-end is responsible for the browser, and everything except other browsers is responsible for the back-end. The UI layer of the intersection server between the front and back ends is also dominated by the back end. This is the most mainstream front-end division of labor.

Let Node.js change all this.

As soon as Node.js was released, it immediately caused an uproar among front-end engineers, who almost immediately showed considerable enthusiasm and expectation for this technology. The last technology can be used by the whole front line.

It was a few years ago that the concept of Ajax was just put forward. It's a good idea to let JavaScript run on the server. Now we don't have to go again.

Learning PHP, Ruby, Java, Scala or other strange languages for the front end can also easily extend our field to the server side. Well done!

The prospect of!

I have never been a fan of PHP, but when I work at Yahoo, I have to use PHP. For this job, I have to put up with spending a lot of extra time to fix the stupidity caused by PHP.

Pit caused by mechanical characteristics. For me, who has been using Java as the server language, it is really difficult to adapt to PHP. I believe and have always insisted that statically typed languages are more suitable for building your.

The core of business logic. So, although I like JavaScript very much, I won't do everything with it. For example, I will never use JavaScript to implement a complete.

Shopping cart system.

For me, Node.js is not a silver bullet to solve all problems, and I will not use it to replace all other language modules on the server side. In fact, Node.js can also be used as other backend.

I have done almost everything that language can do, but I can't do it. I think it is more appropriate to use Node.js to solve the problem of server-side UI layer, so that I can put this layer

Stripped from the rest of the back end.

Nowadays, more and more companies tend to adopt service-oriented architecture, and the back end provides the front-end RESTful interface, in order to do better before.

Dependency separation at the back end. If all the key business logic is encapsulated as REST calls, it means that the upper layer only needs to consider how to build concrete applications with these REST interfaces. Those back-end programmers don't even

They don't care how the specific data is passed from one page to another, and they don't care whether the user's data update is obtained asynchronously through Ajax or refreshing the page. Of course, they don't care if you are using it.

JQuery or yui-it has nothing to do with them. Shouldn't back-end programmers really care about how to store data, how to be fault-tolerant and how to ensure security?

Now let's take a look at the benefits brought by Node.js. After the back-end programmers provide REST services, now our front-end programmers can use Node.js to deal with the server side.

In the UI layer, we can handle the data obtained through REST calls at will, whether it is rendering templates or directly providing them to Ajax. Now we only use JavaScript as a language.

Words can easily achieve this. As for the back-end programmers, they just need to ensure the correctness of the data. No matter what language they use to encapsulate REST calls, it will not affect the front end, such as the front end and the back end.

Wouldn't it be better to divide responsibilities? After such a division of labor, the front-end domain has expanded from the browser box to the UI layer of the server, and the back-end is not easy to do.

Works.

Don't! This is sensational!

It is not easy for the front-end engineer to take over the UI layer of the server, because this part of the work was originally the responsibility of the back-end engineer. Especially now there are many back-end workers.

Shi Cheng thinks JavaScript is a very simple "toy language", and they will think, how can such an important server-side work be handed over to these seemingly unreliable people in such an "indecent" language?

Play? In my experience, this conceptual conflict is the biggest disagreement between front-end and back-end engineers on whether to introduce Node.js The UI layer on the server side is the middle zone between front-end and back-end, while the previous one.

Back-end programmers often dominate this aspect, so once they enter this field that originally belongs to the back-end, controversy is inevitable.

In fact, under the large-scale Web architecture, it is meaningful to give up the traditional role positioning and assign the UI layer of the server to the front end. Otherwise, sometimes the front end wants to get the correct data from the back end.

I also have to care about what language the backend is implemented in. In the past division of labor, things that were originally considered at the bottom of the core business were exposed at the UI layer of the server, and these problems were often inadvertently affected.

Go to the front. There is no need for the front end to pay attention to these issues, because the front end and the back end care about completely different aspects. If you understand single function, separation of responsibilities and modularity, you will understand what I said and even feel it.

It was really stupid not to give the UI layer of the server to the front end before.

Unfortunately, there was no such thing as Node.js before, so there was no suitable technology for front-end engineers to handle the UI layer of the server themselves. So the students at the back end use PHP.

People can easily use PHP templates to realize UI, and back-end students who use Java naturally use JSP to solve this problem. It's not that the front-end students don't want to be the UI of the server, but

Because before, there was no familiar technology that could solve these things, but now it is different. We have Node.js

conclusion

I like Node.js very much, and I like the greater development potential that this technology brings to the front-end world. I don't think it's a good solution to completely implement the whole backend with Node.js, although

Node.js can do all this. I think the greatest value of Node.js at present is that it can make the front end completely control the whole UI layer, whether it is the browser or the server.

Point, our work efficiency can be greatly improved. Our front-end is better at deciding how to present data to give users a better experience, while the back-end knows how to handle data better. Under this new mode of division of labor

In this way, the back end only needs to provide appropriate data operation interfaces, and the front end can build beautiful, efficient and highly available interfaces by itself, thus realizing various interactions that users like.

Using Node.js to deal with the UI layer of the server also frees back-end engineers from areas where they are not good at it. Therefore, we get the panacea for Web development: only between the front end and the back end.

Need to interact through data, this mode makes the two sides independent of each other, and each can develop quickly and for a long time, and as long as the data interface remains unchanged, the front and back ends will not have any influence on each other.