I have been engaged in C, assembly, C ++, C #, Java, JavaScript, and PHP for three years since I got started with the first Programming Language C, there are also some things like HTML and CSS. There is never a language that makes me look like a node. js is equally fascinating. I mentioned nodejs in my blog before... syntaxHighlighter has been engaged in C, assembly, C ++, C #, Java, JavaScript, and PHP for three years since I first came into contact with the programming language C, there are also some things like HTML and CSS. There is never a language that makes me look like a node. js is equally fascinating. I used to contact nodejs. My blog mentioned that many people recommended nodejs when using web socket to select servers. But I didn't have any idea about nodejs at the time, so I didn't understand the code written by others, but I am very familiar with it. Basically, I am using javascript running on the server to explain what nodejs is. This makes me more confused about how javascript can be used as a socket server, after writing the server in C #, I looked back at node. js. In ten minutes, I was totally attracted. Note: As blog writing is about nodejs In the syntax stage, many questions are not clearly stated, and many people disagree with it. For some principles, see node. js misunderstanding what is node. what is js. what about js? Check out the description of nodejs on the official website: Node. js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. node. js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across SS distributed devices. we can summarize the following nodes. js is a platform built on the Chrome JavaScript runtime environment, which is very important. js is not a language, but a platform node. js It makes it easier to build a fast and stable network program node. js features event-driven and non-blocking I/O features, making it lightweight and highly efficient node. js is very suitable for running JavaScript on the server side of a data-intensive real-time application on distributed devices? Chrome JavaScript runtime is also known as Chrome's V8 JavaScript Engine, which is an underlying JavaScript Engine developed by Goole for Chrome browsers. It is used to parse JavaScript statements and create its runtime environment, make sure that the statements we write in the browser are the same as we expected. So why is node. js the JavaScript running on the server? Why should nodejs be related to V8? In addition to Google's V8, JavaScript can be interpreted very quickly. One important reason is that the V8 JavaScript engine is not limited to running in a browser, but can be embedded in any application. Node. js and. net framework is similar to a platform (some of them cannot be understood here, but they are not like. net has created a language -- C # running on this platform, but cleverly borrowed the JavaScript syntax that web developers are very familiar with and used the V8 engine to parse statements, and can be used on the server. So strictly speaking, node. js is not the Javascript running on the server, but a platform that can run JavaScript syntax on the server. Why use node. js has been a new bottle of old wine for a long time. It seems that except for a fresh one, JavaScript syntax can be used, node. js has no advantages. Why should we use it instead of Java or C # that can be run on the server? This should begin with the node. js event-driven and non-blocking I/O features. Those familiar with JavaScript should be familiar with event-driven systems. node. js uses a series of "non-blocking" libraries to support event loops. Essentially, it provides interfaces for resources such as file systems and databases. For example, when a database is accessed and an event mechanism is used, the process is handed over immediately after a request is initiated. when data is returned, an event is triggered, continue to process the data. In the traditional blocking I/O, the running process is int num = query ('select * from ...... '); print (num );................... // The print method of the irrelevant statement must wait for the query method to return the result. If a network connection failure occurs in the database, the print method must wait until the query method times out before execution. Then, some irrelevant statements can be executed once, in non-blocking I/O, the query ('select * from... ', callback (data ){............. // print ();});.............. // The irrelevant statement is used with ajax. The result is processed in the callback function, but the following statement execution is not affected. No wonder node. javaScript needs to use JavaScript to do this. Several features of JavaScript make it competent for functional programming of the event mechanism, and support anonymous functions and function parameters Node. in js, the code is executed by a single process and a single thread (the code we write is, but the node. js itself is not interested. You can take a look at this for further understanding), use the event polling mechanism and non-blocking I/O, and process tasks in parallel without adding additional threads. Node. js solves the problem of wasting a lot of Process resources by blocking programming and is only waiting, resulting in a large amount of memory and cpu waste. Therefore, it dared to claim its own perfect for data-intensive real-time web applications. How to install nodejs is still very simple. In particular, the installation package now integrates npm. You don't have to install it separately. Download the installation package and run it, in addition, if you want to use nodejs completely, you need to have a C language compiling environment, git, and python. The use of window can be a little more troublesome and you need to do this. If you have a special liking for the command line, you can see How to Install Node. what is js npm? npm is the abbreviation of node packaged modules. It is actually a node. js module management tool. What is module? The so-called module is similar to the package concept in java, A collection of solutions will officially provide several core components. Many third-party solutions are used to install third-party modules because the nodejs community is very active and there are many useful third-party packages, we can install npm install [-g] using the npm command in the terminal. : The install command can be used to download and install the Global path of nodejs from nodule. If it is not added, it will be installed to the current path npm remove. : Remove modulenpm update : There are some common commands to update the module. You can refer to the common npm commands.
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:
info-contact@alibabacloud.com
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