node. js

Source: Internet
Author: User

JavaScript is a script run in the browser, it is simple, lightweight, easy to edit, this script is usually used for front-end programming of the browser, but a developer Ryan discovered that the front-end scripting language can run on the server, a storm sweeping the world began. [1] node. JS is a platform built on the chrome JavaScript runtime to easily build responsive, easy-to-scale Web applications. node. js is lightweight and efficient with event-driven, non-blocking I/O models and is ideal for data-intensive, real-time applications running on distributed devices. The V8 engine executes JavaScript very fast and performs very well. Node is a JavaScript run environment (runtime). It actually encapsulates the Google V8 engine. The V8 engine executes JavaScript very fast and performs very well. Node optimizes some of the special use cases, providing an alternative API that allows V8 to run better in a non-browser environment.Foreign namesnode. jscategoryJavaScript toolsRelease TimeMay 2009DeveloperRyan Dah Catalogue

1 history

2 Features

3 modules

4 Installation

Version 5 released

6 Integrated development Environment

7 Sample Programs

1 History editor
    • In February 2009, Ryan Dahl announced on his blog that he was prepared to create a lightweight Web server based on V8 and provide a set of libraries.
    • In May 2009, Ryan Dahl released the original version of the node. js package on GitHub, and in the next few months someone started using node. js to develop the app.
    • In November 2009 and April 2010, the two session of the JSCONF conference was organized with node. JS Lectures.
    • At the end of 2010, node. JS received joyent funding from cloud computing service provider, founder Ryan Dahl joined Joyent full-time responsible for node. JS Development.
    • In July 2011, node. JS released the Windows version with Microsoft Support. [2]
2 feature editing The V8 engine itself uses some of the latest compilation techniques. This makes code written in scripting languages such as JavaScript significantly faster, but saves development costs. Demanding performance is a key element of node. JavaScript is an event-driven language, and node takes advantage of this to write a highly scalable server. Node uses a schema called Event loop, which makes it both easy and secure to write servers that are highly scalable. There are a variety of techniques to improve server performance. Node chooses a architecture that improves performance and reduces development complexity. This is a very important feature. Concurrent programming is often complex and mine-infested. Node bypasses these, but still provides good performance. Node uses a series of "non-blocking" libraries to support the way events loop. Essentially, it provides interfaces for resources such as file systems and databases. When sending a request to the file system, there is no need to wait for the hard drive (addressing and retrieving the files) and the non-blocking interface notifies node when the hard disk is ready. The model simplifies access to slow resources in an extensible way, intuitive and understandable. Especially for the familiar with onmouseover, onclick and other DOM events users, there is a sense of déjà vu. While it is not unique to node to run JavaScript on the server side, it is one of the most powerful features. We have to admit that the browser environment limits our freedom to choose a programming language. The desire to share code between any server and an increasingly complex browser client application can be achieved only through JavaScript. While there are other platforms that support JavaScript running on the server side, because of these features, node has grown rapidly and become a de facto platform. Within a very short time of node launch, the community has contributed a large number of extension libraries (modules). Many of them are connected to the database or other software drivers, but there are many are based on their strengths produced by the very useful software. Finally, the node community has to be mentioned. Although the node project is very young, it is rare to see a community that is so fanatical about a project. Whether you're a novice or an expert, everyone revolves around projects, uses and contributes to their capabilities, and strives to create a land of exploration, support, sharing, and advice. [3]Advantages of node. JSNodejs, as an emerging background language, has a lot of attractions: RESTful API single-threaded node. JS can still process tasks in parallel without adding additional external threads--node.js is single-threaded. It implements parallel operations through event polling, which we should take advantage of--avoid blocking operations as much as possible and use non-blocking operations instead. Non-blocking IOV8 virtual machine event driver [4]3 module editing Node. JS uses module modules to classify different functions to simplify application development. The modules module is somewhat like a class library in C language. Each node. JS class Library contains a very rich variety of functions, such as the HTTP module contains a lot of functions related to the HTTP function, can help developers to easily http,tcp/udp, such as the operation, but also can easily create HTTP and tcp/ UDP server. It is very convenient to use modules in a program, just as follows: here, the HTTP class library is introduced, and the HTTP class library reference is stored in the HTTP variable. At this point, node. JS will search our app for the existence of a node_modules directory and search the directory for the presence of HTTP modules. If node. js cannot find this directory, it will go to the global module cache and the user can specify the location of the module by relative or absolute path, for example: var MyModule = require ('./mymodule.js '), and the module contains a lot of functional code snippets, The code in the module is mostly private, meaning that the function methods and variables defined in the module are only called in the same module. Of course, some methods and variables can be exposed to the module, this time you can use the exports object to implement. [2]4 Installing the editor node. JS installation below describes the installation under node. js, first download the relevant installation package based on the operating system on the Nodejs website, and for installation under Ubuntu[5] (Linux), which can be done as follows: sudo apt-get Updatesudo Apt-get Install node or: sudo aptitude updatesudo Aptitude Install nodenode.js will be in the SID Library and can be added to the list of sources sources sudo echo Deb Http://ftp.us.debian Org/debian/sid main >/etc/apt/sources.list.d/sid.list but note that after the installation is complete, you need to remove the/etc/apt/ Sources.list.d/sid.list. [2] version 5 release edit September 30, 2013, node. JS 0.10.20 released. [6] Improvement Department:
    • TLS: Fix occasional hangs and partial display (Fedor Indutny)-fix "NPM err! CB () Never called! "
September 24, 2013, node. JS 0.10.19 released. Improvement Department:
    • UV: Upgrade to v0.10.17
    • NPM: Upgrade to 1.3.11
    • ReadLine: Start processing input from Control character (Eric Schrock)
    • Configure: Added Mips-float-abi (soft, hard) option (Andrei sedoi)
    • Stream: Object mode changed to allow no value (Isaacs)
    • TLS: Block read returns redundant values (Nathan Rajlich)
    • TLS:NPN protocol changed to connect to local (Fedor Indutny)
September 04, 2013, node. JS 0.10.18 released. Improvement Department:
    • UV: Upgrade to v0.10.15
    • Stream: Do not block unset _events Property (Isaacs)
    • Stream: The passed ' buffer ' is encoded in a decoded manner (Isaacs)
August 21, 2013, node. JS 0.10.17 released. Improvement Department:
    • UV: Upgrade to v0.10.14
    • Http_parser: Do not receive Pun/gem method as Put/get (Chris Dickinson)
    • TLS: Fix declaration when read SSL is destroyed (Fedor Indutny)
    • Stream: Throws ' Error ' when the listener is removed (Isaacs)
    • Dgram: Fix the declaration of the wrong Send () parameter (Ben Noordhuis)
    • ReadLine: Pause stdin (Daniel Chatfield) before exiting Terminal raw mode
August 16, 2013, node. JS 0.10.16 released. Improvement Department:
    • V8: Repairing the back door of cve-2013-2882
    • NPM: Upgrade to 1.3.8
    • Crypto: Fixed hex data entry for ASSERT () (Ben Noordhuis)
    • Crypto: Fix randombytes () Error path memory leak (Ben Noordhuis)
    • Events: fix memory leaks without exposing event names (Ben Noordhuis)
    • http: correctly handling HEX/BASE64 encoding (Isaacs)
    • http: Boost Res.write (BUF) performance (Ben Noordhuis)
    • Stream: Fixed dual-pipe error display (Eran Hammer)
6 Integrated development Environment editor An IDE with writing JavaScript is available. A regular Notepad can also be developed.7 Sample program editing Any set of standards is started by a well-known program: Hello World! In node, HTTP is the primary. node is optimized for creating HTTP servers, so most of the examples and libraries you see online are focused on the Web (HTTP framework, template Library, and so on). Here's a Nodejs Hello World demo [7]:
1234567 varhttp = require(‘http‘);server = http.createServer(function(req, res) {res.writeHeader(200, {"Content-Type": "text/plain"});res.end("Hello World\n");});server.listen(8000);console.log("httpd start @8000");

node. js

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: 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

  • 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.