Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What can nodejs do?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "what can nodejs do?". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "what can nodejs do?"

What nodejs can do: 1, realize the programmer's full stack development; 2, unify the common class library, standardize the code; 3, asynchronous programming; 4, deal with IO-intensive applications; 5, build complex systems; 6, realize the monitoring system for memory stack, and so on.

This article operating environment: Windows7 system, nodejs10.16.2, Dell G3 computer.

Nodejs introduction:

Node.js is a JavaScript runtime environment based on the Chrome V8 engine. Node.js uses an event-driven, non-blocking Istroke O model to make it lightweight and efficient. Node.js 's package manager, npm, is the largest open source ecosystem in the world.

What can nodejs do?

1. Nodejs is based on the Javascript language, so you don't have to learn a new language alone, thus reducing the threshold for learning. At the same time, Javascript language is very important in the front-end development of Web, especially the application of HTML5 must be used, so the unified language of front and background can not only realize the full stack development of programmers, but also unify the common class library and standardize the code. With this alone, Nodejs has won the favor of the market.

2. Instead of redeveloping the runtime environment, Nodejs chose the fastest browser kernel V8 as the execution engine to ensure the performance and stability of Nodejs.

3. The development of Nodejs is very efficient, and the code is simple, proud of the single-threaded mechanism of Nodejs. Another feature of Nodejs, asynchronous programming, gives Nodejs a clear advantage in dealing with IO-intensive applications. Personally, Nodejs is 10 times more efficient than Java for Web development and simpler than PHP code.

4. The community of Nodejs is growing, not only the number of packages is increasing rapidly, but also the quality of packages is significantly better than that of other languages. Many star packages are simple and smart, designed for developers' habits. The toolkits I use most often, such as socket.io, moment.js, underscore.js, async.js, express.js, bower.js, grunt.js, forever.js... It's really changing my previous programming habits.

Of course, in addition to my reasons for using Nodejs, many companies also have their own reasons to use it.

Ebay's reasons for choosing Nodejs can be summarized as follows:

Dynamic languages: very efficient developers and the ability to build complex systems such as http://ql.io.

Performance and I IO O load: Nodejs solves the IO-intensive problem very well, through asynchronous IO.

Connection memory overhead: each Node.js process can support more than 120000 active connections, consuming about 2K of memory per connection.

Operation: the monitoring system of Nodejs for memory stack is realized.

15 Nodejs application scenarios

Now that we have a preliminary understanding of Nodejs, let's take a look at the application scenario of Nodejs.

1 Web development: Express + EJS + Mongoose/MySQL

Express is a lightweight and flexible Nodejs Web application framework, which can build websites quickly. The Express framework is based on the built-in Http module of Nodejs, and the Http module is repackaged to actually handle Web requests.

Ejs is an embedded Javascript template engine that compiles code to generate HTML.

Mongoose is the object model tool of MongoDB. Through the Mongoose framework, you can access MongoDB.

Mysql is the communication API that connects to the MySQL database and can access the MySQL.

Usually using Nodejs for Web development requires three frameworks to work together, just like SSH in Java.

2 REST development: Restify

Restify is a Nodejs-based REST application framework that supports both the server side and the client side. Restify focuses more on REST services than express, removing template, render and other functions in express, while strengthening the use of REST protocol, versioning support, and exception handling of HTTP.

3 Web chat room (IM): Express + http://Socket.io

Socket.io is a software package that is based on Nodejs architecture and supports websocket protocol for all-time communication. Socket.io provides a complete package for building real-time applications across browsers, and socket.io is implemented entirely by javascript.

4 Web crawler: Cheerio/Request

Cheerio is a fast, flexible, encapsulated jQuery core function toolkit specially tailored for the server. Cheerio includes a subset of the jQuery core, removing all DOM inconsistencies and browser incompatibility from the jQuery library, revealing its truly elegant API. Cheerio works on a very simple, consistent DOM model, parsing, manipulating, and rendering have become incredibly efficient. The basic end-to-end benchmark shows that Cheerio is about eight times faster than JSDOM (8x). Cheerio encapsulates @ FB55 compatible htmlparser and can parse almost any HTML and XML document.

5 Web blog: Hexo

Hexo is a simple, lightweight, Node-based static blogging framework. With Hexo, we can quickly create our own blog, which can be done with just a few commands.

At the time of release, Hexo can be deployed on its own Node server or github. For individual users, deploying on github has many benefits, which can not only save the cost of the server, but also reduce the hassle of various system operation and maintenance (system management, backup, network). So, github-based personal sites are starting to become popular. .

6 Web Forum: nodeclub

Node Club is a new type of community software developed with Node.js and MongoDB, with elegant interface, rich features, compact and rapid. It has been applied in Node.js Chinese technology community CNode, but you can use it to build your own community.

7 Web slides: Cleaver

Cleaver can generate Markdown-based presentations. If you already have a Markdown document, you can make a slide show in 30 seconds. Cleaver is a tool for Hacker.

8 front-end package management platform: bower.js

Bower is a package management tool introduced by twitter. Based on the modular idea of nodejs, it distributes the functions into various modules and makes the relationship between modules and modules, and manages the relationship between modules through Bower.

9 OAuth Certification: Passport

The Passport entry is an authentication middleware based on Nodejs. The purpose of Passport is only for "login authentication", so the code is clean, easy to maintain and can be easily integrated into other applications. Web applications generally have two forms of login authentication: username and password authentication login and OAuth authentication login. Passport can configure different authentication mechanisms according to the characteristics of the application. This article will introduce the user name and password authentication login.

10 scheduled task tool: later

Later is a Nodejs-based tool library that performs scheduled tasks in the simplest way. Later can be run in Node and browsers.

11 browser environment tools: browserify

The emergence of Browserify allows the Nodejs module to run in the browser, organize the front-end code with the syntax format of require (), and load the npm module. In the browser, the compiled code that calls browserify is also written in the tag.

The operation with Browserify is divided into three steps. 1. Write node programs or modules, 2. Precompiled into bundle.js with Browserify, 3. Load the bundle.js in the HTML page.

12 command line programming tool: Commander

Commander is a lightweight nodejs module that provides powerful functions for user command line input and parameter parsing. Commander is derived from a Ruby project of the same name. Commander features: self-recording code, automatically generate help, merge short parameters ("ABC" = = "- A-B-C"), default options, mandatory options, command parsing, prompt.

13 Web console tool: tty.js

Tty.js is a command line window that supports running in a browser. It is based on the node.js platform, relies on the socket.io library, and communicates with the Linux system through websocket. Features: support multi-tab window model; support vim,mc,irssi,vifm syntax; support xterm mouse events; support 265 color display; support session.

14 client utility: node-webwit

Node-Webkit is the integration of NodeJS and WebKit technology, which provides a low-level framework for client application development across Windows and Linux platforms, and uses the popular Web technology (Node.JS,JavaScript,HTML5) to write applications. Application developers can easily use Web technology to implement a variety of applications. The performance and features of Node- Webkit have made it the world's leading application platform for Web technology.

15 operating system: node-os

NodeOS is a friendly operating system developed by NodeJS, which is completely built on the Linux kernel and uses shell and NPM for package management. NodeJS can not only manage packages, but also manage scripts, interfaces and so on. Currently, both Docker and Vagrant are built using the first version of NodeOS.

These are all the contents of the article "what can nodejs do?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report