Node.js如此受欢迎的7个原因

To put it simple, Node.js outshines other web applications by replacing websockets with revolutionary push technology. You would ask, what is so unique about it? Well, we finally have cutting-edge web applications with two-way, real-time connections where both the server and client can build communication, allowing them to exchange valuable data. Now this is in stark contrast to our conventional web response paradigm where only the client initiates communication.

简而言之,Node.js通过用革命性的推送技术代替websocket,从而使其他Web应用程序胜过其他应用程序。 您会问,这有什么独特之处? 好了,我们终于有了具有双向实时连接的尖端Web应用程序,服务器和客户端都可以在其中建立通信,从而允许他们交换有价值的数据。 现在,这与我们的常规Web响应范例形成了鲜明的对比,在常规的Web响应范例中,只有客户端才能发起通信。

Top 7 Reasons Why Node.js is So Popular

Node.js server technology is used to create and run a wide variety of web applications, and is quite similar to what Ruby On Rails, Spring Framework and ASP.NET does. It leverages JavaScript as the main language, which is a lightweight built-in web server and has a plethora of Plugins managed via the Node Package Manager (NPM), allowing you to custom-build your applications to meet your needs. It may sound like any other good web technology, but it has certain features that make it a popular choice among developers to build a wide spectrum of web applications.

Node.js服务器技术用于创建和运行各种Web应用程序,并且与Ruby On Rails,Spring Framework和ASP.NET十分相似。 它利用JavaScript作为主要语言,它是一种轻量级的内置Web服务器,并具有通过节点包管理器(NPM)管理的大量插件,可让您自定义构建应用程序以满足您的需求。 它听起来可能与其他任何优秀的Web技术一样,但是它具有某些功能,使其成为开发人员广泛构建Web应用程序的选择。

Discussed here are the top 7 reasons why you should use Node.js:

这里讨论了应该使用Node.js的7大理由:

1. It is JavaScript Everywhere

1.到处都是JavaScript

One of the biggest reasons why Node.js is so popular is because it uses JavaScript as its main language to build web applications. And to be honest, JavaScript is now the only choice to develop web applications in the browser. What more! A new and robust framework is introduced quite frequently to woo developers. With Node.js, JavaScript has literally revolutionized on the server. The language is common to most web developers, and is certainly driving the world today. And according to experts, the trend will not fade away soon.

Node.js如此受欢迎的最大原因之一是因为它使用JavaScript作为主要语言来构建Web应用程序。 老实说,JavaScript现在是在浏览器中开发Web应用程序的唯一选择。 还有什么! 经常引入新的健壮框架来吸引开发人员。 借助Node.js,JavaScript确实在服务器上进行了革命。 该语言对于大多数Web开发人员来说都是通用的,并且无疑正在驱动当今的世界。 而且据专家称,这种趋势不会很快消失。

Since JavaScript is a language that most developers know or have used at some point of time, the transition from another web technology to Node.js is a breeze. This makes it a preferred choice among web developers.

由于JavaScript是大多数开发人员有时会使用的一种语言,因此从另一种Web技术到Node.js的转换非常容易。 这使其成为Web开发人员的首选。

2. It’s lightning Fast

2.快如闪电

Node.js is primarily a JavaScript runtime that is powered by V8, developed by Google for use in Chrome. V8 has the ability to compile and execute JavaScript at lightning fast speed, mainly because it compiles JavaScript into a native machine code. In addition to this, Node.js has a magical event loop, which is a single thread performing all I/O operations in an asynchronous manner. In Node.js, when an application has to perform I/O operation, it sends asynchronous tasks and callback action to the event loop, and then continues to perform the rest of the program. On completion of sync operation, the event loop automatically returns to the task to execute callback. This is much unlike traditional looping, which consumes a lot of memory and is exceptionally difficult to execute.

Node.js主要是由V8提供支持JavaScript运行时,由Google开发并用于Chrome。 V8能够以闪电般的速度编译和执行JavaScript,主要是因为V8将JavaScript编译为本地机器代码。 除此之外,Node.js还具有神奇的事件循环,该循环是一个以异步方式执行所有I / O操作的线程。 在Node.js中,当应用程序必须执行I / O操作时,它将异步任务和回调操作发送到事件循环,然后继续执行程序的其余部分。 同步操作完成后,事件循环将自动返回任务以执行回调。 这与传统的循环非常不同,传统的循环消耗大量内存,并且异常难以执行。

Thus, reading/writing to file system, network connections, and to the database is executed very fast in Node. It allows developers to build fast and highly scalable network applications that are capable of handling bulk amounts of simultaneous connections having high throughput.

因此,在Node中非常快速地执行对文件系统,网络连接以及对数据库的读/写操作。 它允许开发人员构建快速且高度可扩展的网络应用程序,该应用程序能够处理大量具有高吞吐量的同时连接。

3. It is Lightweight

3.轻巧

Typically, Node.js uses a basic event-driven architecture. This means everything executed on it, including every single operation and call, is a series of asynchronous callback. This enables Node to run on a single thread as unlike other web technologies where a new thread is spawned for every client request. This not only makes it light-in-weight, but also forms the foundation of Node’s non-blocking I/O feature.

通常,Node.js使用基本的事件驱动架构。 这意味着对其执行的所有内容(包括每个单独的操作和调用)都是一系列异步回调。 这使Node可以在单个线程上运行,这与其他Web技术不同,在Web技术中,会为每个客户端请求生成一个新线程。 这不仅使其轻巧,而且构成了Node无阻塞I / O功能的基础。

4. A Single Language for All Layers

4.适用于所有层的单一语言

Another key benefit of Node.js is language re-use. Other web technologies like Spring or ASP.NET requires developers to have knowledge in another language to write code on the server-side, be it VB.NET, Java, or C#. This means all functions necessarily include two languages – one on the client-side and the other on server-side. On the contrary, Node uses only JavaScript for the client and server side. Thus, web developers have to interact only in a single language across all layers. Adding to it, this can be re-used over and over again for future communications.

Node.js的另一个主要优势是语言重用。 其他Web技术(例如Spring或ASP.NET)要求开发人员具有另一种语言的知识才能在服务器端编写代码,无论是VB.NET,Java还是C#。 这意味着所有功能都必须包含两种语言-一种在客户端,另一种在服务器端。 相反,Node仅在客户端和服务器端使用JavaScript。 因此,Web开发人员只需在所有层中使用单一语言进行交互。 除此之外,它可以反复使用以用于将来的通信。

5. High Performance

5.高性能

PayPal uses Node.js, and has reported doubling the number of requests per-second and reducing the response time by 35%. On the other hand, Wal Mart, the retail giant had a superb experience with Node.js in 2013, when they put all their mobile-based traffic via Node.js on Black Friday, the busiest shopping time of the year. Amazingly, on Black Friday, Wal Mart servers did not go over a mere 1% CPU utilization and yet they deploy with 200,000,000 users online. LinkedIn, the global networking site, moved from Ruby to Node to handle their mobile traffic, and reduced the number of servers to 30 to 3, i.e. almost 90% reduction. The new system was up to 20 times faster. All these figures clearly indicate performance capability of Node.js.

PayPal使用Node.js,并已报告说每秒将请求数量增加一倍,并将响应时间减少35%。 另一方面,零售业巨头沃尔玛(Wal Mart)在2013年拥有出色的Node.js体验,当时他们将所有基于移动设备的流量都通过Node.js放置在一年中最繁忙的黑色星期五。 令人惊讶的是,在黑色星期五,沃尔玛服务器的CPU使用率并没有超过1%,而是在线部署了2亿用户。 全球网络站点LinkedIn从Ruby迁移到Node以处理其移动流量,并将服务器数量减少到30到3,即减少了近90%。 新系统的速度提高了20倍。 所有这些数字清楚地表明了Node.js的性能。

6. It can be Hosted Anywhere

6.可以在任何地方托管

Or to say, almost anywhere! Considering exponential growth in Node.js usage in recent years, there are several cloud-based hosting providers and web servers that support web applications built on Node out-of-the-box. This includes Google, Amazon AWS, Heroku, Microsoft IIS, Microsoft Azure, and many others.

或者说,几乎在任何地方! 考虑到近年来Node.js的使用呈指数增长,有几种基于云的托管提供程序和Web服务器支持开箱即用的Node上构建的Web应用程序。 这包括Google,Amazon AWS,Heroku,Microsoft IIS,Microsoft Azure等。

7. It is Easy to Modify and Maintain

7.易于修改和维护

Traditionally built applications become less adaptive and rigid over time as new requirements are fed. Eventually, they start creaking under the stress they were not built for. However, developing new services using Node.js is comparatively easier. With Node, a bunch of small applications is built instead of a single, large application. This allows making changes or adding a new functionality with much ease, without having to make changes deep inside the code-base.

随着新要求的提出,传统上构建的应用程序随着时间的流逝变得适应性和刚性下降。 最终,他们在原本不适合的压力下开始吱吱作响。 但是,使用Node.js开发新服务相对容易一些。 使用Node,可以构建一堆小型应用程序,而不是一个大型应用程序。 这样可以轻松进行更改或添加新功能,而无需在代码库内部进行更改。

Conclusion

结论

Yes, Node.js is trending at the moment. It has huge possibilities that developers can leverage to build highly robust and scalable web applications. So, it is worth a try before it is dead. After all, this is the world of web development!

是的,Node.js目前正在发展。 开发人员可以利用巨大的可能性来构建高度健壮和可扩展的Web应用程序。 因此,在它死之前值得尝试。 毕竟,这是Web开发的世界!

Author Bio:

作者简介:

Mehul Rajput is a CEO of Mindinventory, a prominent web development and mobile app development company specialized in Node.js development services. He does blogging as hobby and love to write on web and mobile technologies.

Mehul Rajput是Mindinventory的首席执行官,Mindinventory是一家专注于Node.js开发服务的著名Web开发和移动应用程序开发公司。 他的爱好和热爱写博客是为了写Web和移动技术。

翻译自: https://www.thecrazyprogrammer.com/2016/03/top-7-reasons-node-js-popular.html