Vue's Nodejs Introduction

Source: Internet
Author: User

Nodejs English Web:

Chinese Web:

We will find this sentence:

Translate into Chinese as follows:

node. JS is a JAVASCRIPT runtime environment based on the Chrome V8 engine.
node. JS uses an event-driven, non-blocking I/O model to make it lightweight and efficient.
node. JS's Package Manager, NPM, is the world's largest open source library ecosystem.

Good. So before we introduce Nodejs, do we have a definition of javascript?

1.1 What is JavaScript?

Before learning the front end, we know that JavaScript is a scripting language that runs on the browser side and is used to interact with client pages.

What about the 1.2 javascript operating environment? As the name implies, his operating environment is the browser, but is this really the case? In fact, his real operating environment is actually running in the browser kernel of the JS engine. Why is that so? Because the function of the browser is to browse the Web, we can do other things in the browser in addition to JS, such as we enter an address in the browser hit enter to send the request and receive the response of the server. So the first function of the browser is to request an HTTP address, that is, you can encapsulate a request message, the address of a URL is encapsulated into a request message, the message to the server, and then give us a response message, and then the response is parsed out, which is the biggest role of the browser. Of course, the content of the server response may be different, for example, the server returned an HTML file, CSS files, img files, used to render, we call the rendering engine, in addition, can also execute JS, by the JS engine to complete, So it can be said that JavaScript is the operating environment of the browser JS engine, not the browser. The browser is a big concept. What can browsers do with JavaScript? 1.3 What JavaScript in the browser can do before it is mentioned, Javascrip is used to do interaction, but generally speaking the interaction is a little unclear, the specific point can be divided into:
(1) manipulating the DOM (that is, adding additions and deletions to the DOM, registering events, etc.)
(2) Sending AJAX requests/cross-domain
(3) BOM Interaction if you provide us with page jumps, history, console print logs
(4) ECMAScript (JS core language, such as used to define variables, functions, etc.) 1.4, browser-side Javasscript What can not do?

Through the previous understanding, seemingly javascrip to our daily interaction can be completed, seemingly anything can be done, but he also has not to do. Such as:

1) When it comes to end-to-end applications, we need to manipulate the files, and JavaScript in the browser is not able to manipulate the files, although HTML5 provides a file-related API, but most of these APIs are limited to read-only levels, not like traditional languages such as Java, By passing a path and then reading the corresponding file, it is not possible to curd the files and folders.

2), browser-side JavaScript also has no way to operate the operating system, such as to obtain the operating system version and so on.

So why not do these two kinds of operations? In fact, because of security considerations, because, JS this language running environment is more special, said he special, special where? Although we have written a good JS code will eventually be placed on the server, but he is not executed on the server, but by the server sent to the browser to execute, the browser side of the operation of the file is obviously not safe, so that these functions in the client is not able to do, but because of the special operating environment can not do

1.5, understand the client JS can do things, we must also clear a concept, that is Javascrip can only run on the browser side? Front-end developers know that Javascrip is composed of Ecmascrip language, Bom,dom, and at the language level, she just gives us some operational syntax, such as defining variables, functions, types, process controls, and so on. The bom,dom is provided by the browser and is not provided by ES. So the JS we often refer to is that most of Es,js's functions (Dom,bom (browser-open API) are determined by the browser's execution engine, which also derives an idea that any programming language, his ability is not determined by the language itself, It is determined by his enforcement environment. For example, Java, he is a language is also a platform, for JavaScript language is ES, platform is a browser. So JS can only run in the browser? Not too! For most languages, running on a single platform, such as Java only runs on virtual machines, but there are languages running on multiple platforms, Java at some level is not necessary to run on multiple platforms, because virtual machines are cross-platform (that is, cross-operating systems such as Windows, Linux, etc.). JS is also able to run on multiple platforms, the browser is able to run JS, because he is the execution of the JS engine. JS also, as long as supported by his platform can be executed. So to think that language has a very powerful function, only need to provide a powerful platform, node is such a platform to execute JS, then what is node exactly? Next, let's briefly describe what a node is.  What is node? According to official documentation, node is a JavaScript runtime that gives Google V8 an engine that can be understood as a virtual machine running JS. He was using an event-driven, non-blocking I/O model, and he moved the JS environment to the server side, with no connection to the client. is a purely service-side thing, node just provides a platform for JS. Node inside actually divided two pieces, one is encapsulated the V8 engine, the purpose is to execute ES (such as defining variables, define functions, etc.), another provides a large number of tool libraries, is to help node to achieve a variety of functions, to provide some of the previous JS environment do not do things, such as file operations, network operations, Operation of the operating system.
Since node is a platform (the so-called platform is used to run a particular language), it means that node is used to run the language, then Java is the language, can node run Java? According to Nodejs founder Ryan Dahl, he initially chose the language of Ruby, but the efficiency of the virtual machine of the Ruby language is not very good finally give up, according to this idea, it seems that node will be Java Virtual Machine integration should be able to run Java, But the node author eventually chose JavaScript. This way JS can be implemented in the service side of the operation, JS running on node platform (divided into V8 section, used to execute ES, and a large number of tool library components (API) called LIBUV, providing the previous JS environment does not work, such as file operations, network operations, etc.).
Knowing what node is, you should also be aware of what node is used for in the web.
(1) node can accept all requests from client users and be able to respond quickly, so node can be used as a Web site.
(2) node can be used as a middle layer to distribute the call data interface, for example, there is a Web site data is provided by Java, we can let node as a middle, to accept the user's request, and then through node to invoke the Java data interface, After getting the data, make a bottle of HTML directly at the node level and then give the rendered page directly to the user. Why not just ask for the Java interface, because node is known as a high-performance Web server that is much better at concurrency and compression than traditional platforms, so this package can greatly reduce server development.
From the above two points, it can be concluded that node in the Web either from the front page to the back end of the full package of services, one is to do only one point.
Word, node is a JavaScript running environment (platform), he is not a language, nor is it the framework of JavaScript. Can be used to develop server-side applications, web systems. It is characterized by small size, fast and high performance.

Vue's Nodejs Introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.