本文共 15405 字,大约阅读时间需要 51 分钟。
We are going to deliver a sequence of posts on “How to develop Applications using Node JS, Express JS, Angular JS, Mongo DB, Redis, and RESTful WebServices“.
我们将在“ 如何使用Node JS,Express JS,Angular JS,Mongo DB,Redis和RESTful WebServices开发应用程序 ”上发表一系列帖子。
We will discuss all these posts on Windows Environment only. There is no much difference in Node JS Platform installation and developing applications in other OS Environments.
我们将仅在Windows Environment上讨论所有这些文章。 在其他操作系统环境中,Node JS平台的安装和开发应用程序没有太大区别。
In this post, we are going to discuss about some basics of Node JS Platform.
在本文中,我们将讨论Node JS Platform的一些基础知识。
Node JS is an Open Source Java Script Platform used to develop fast and scalable server-side and networking applications very easily.
Node JS是一个开源Java脚本平台,用于非常轻松地开发快速且可扩展的服务器端和网络应用程序。
Google’s V8 Engine is an Open Source JavaScript Engine for the Chrome Web browser. V8 Engine is completely written in C++ Language.
Google的V8引擎是用于Chrome Web浏览器的开源JavaScript引擎。 V8 Engine完全用C ++语言编写。
Ryan Dahl is a big fan of “Google’s Gmail”. He was impressed by Gmail performance and started created new Platform.
Ryan Dahl是“ Google的Gmail”的忠实拥护者。 Gmail的性能给他留下了深刻的印象,并开始创建新的平台。
Ryan Dahl has developed a Server-Side Platform “Node JS” in 2009 on top of Google’s V8 Engine. That means Node JS applications run on V8 Engine.
Ryan Dahl在2009年基于Google的V8引擎开发了服务器端平台“ Node JS”。 这意味着Node JS应用程序可以在V8 Engine上运行。
Unlike some UI Frameworks for example Angular JS, use to write Client-side JavaScript, Node JS Platform is used to write Server-side JavaScript.
与用于编写客户端JavaScript的某些UI框架(例如Angular JS)不同,Node JS Platform用于编写服务器端JavaScript。
We can run Node JS applications on most of the OS Platforms like Windows, Linux, Mac etc.
我们可以在Windows,Linux,Mac等大多数OS平台上运行Node JS应用程序。
Official Website for Node JS Platform:
Node JS平台的官方网站: :
Node JS is a Platform. It is not a Framework or Web Framework. It is not a Language.
Node JS是一个平台。 它不是框架或Web框架。 它不是语言。
It is a Platform which contains thousands of thousands of modules to develop wide variety of applications. We can install base Node JS Platform and update all your application required modules very easily.
它是一个包含成千上万个模块的平台,用于开发各种应用程序。 我们可以安装基本的Node JS平台并非常轻松地更新您所有应用程序所需的模块。
Node JS “Module” is also known as Package. Now onwards, when we refer Module means Node JS Package.
节点JS“模块”也称为包。 现在开始,当我们提到Module时就是Node JS Package。
Node JS is not for Multi-Threaded applications. It follows Single Thread with Event Loop architecture. If you don’t know what is “Even Loop” architecture, don’t get tense at this moment. We will discuss on “What is Event Loop and How Node JS deals with multiple requests” in coming posts.
Node JS不适用于多线程应用程序。 它遵循具有事件循环体系结构的单线程。 如果您不知道什么是“ Even Loop”架构,那么现在不要紧张。 我们将在以后的文章中讨论“什么是事件循环以及Node JS如何处理多个请求”。
We will discuss how to setup Node JS Base Platform and how to add/install required modules at required time in coming posts.
我们将在后续文章中讨论如何设置Node JS Base Platform以及如何在需要的时间添加/安装所需的模块。
Major advantage of Node JS Platform is that it’s modularity. Each and every functionality is divided and implemented as a separate module or package. When we install Node JS Platform, by default it installs only few modules. If our application requires other modules, then we can easily install and configure then at any point of our application development phases.
Node JS has thousands of thousands modules. Some modules were developed by Node JS Community and some were by Third-party Clients. We will discuss and provide some examples about these modules in coming posts.
While writing this post, Node JS Platform supports the following number of packages.
We can check this updates on its official website:
Some of the Node JS Modules are written in Java Script and some are in C/C++ Language. It’s 40% modules are written in JS and 60% modules are written C/C++.
模块化Node JS平台的主要优点是它的模块化。 每个功能都被划分并实现为单独的模块或包。 当我们安装Node JS Platform时,默认情况下它仅安装几个模块。 如果我们的应用程序需要其他模块,那么我们可以在应用程序开发阶段的任何时候轻松地安装和配置。
Node JS有成千上万个模块。 一些模块是由Node JS社区开发的,而某些则是由第三方客户端开发的。 我们将在以后的文章中讨论并提供有关这些模块的一些示例。
在撰写本文时,Node JS Platform支持以下数量的软件包。
我们可以在其官方网站上查看此更新: :
一些Node JS模块是用Java脚本编写的,而另一些则是用C / C ++语言编写的。 它的40%模块是用JS编写的,而60%模块是用C / C ++编写的。
Node JS is used to develop Server-side Java Script. It also contains a separate module for Web Application Framework i.e. Express JS.
Express JSNode JS用于开发服务器端Java脚本。 它还包含Web应用程序框架的单独模块,即Express JS。
Node JS supports Non-blocking IO i.e. it uses Asynchronous IO Model to interact with File system or to do Socket communication or network communication.
Asynchronous IO Model means if IO processing is taking more time, then it permits other processing to continue before the transmission has finished.
Java Developers are very much familiar about Blocking IO and Non-Blocking IO. Java IO package follows Blocking IO or Synchronous IO Architecture whereas Java NIO 2 follows Non-Blocking IO or Asynchronous IO Architecture.
非阻塞或异步IONode JS支持非阻塞IO,即它使用异步IO模型与文件系统交互或进行Socket通信或网络通信。
异步IO模型意味着,如果IO处理花费更多时间,则它允许其他处理在传输完成之前继续进行。
Java开发人员对阻塞IO和非阻塞IO非常熟悉。 Java IO软件包遵循Blocking IO或Synchronous IO Architecture,而Java NIO 2遵循Non-Blocking IO或Asynchronous IO Architecture。
We can use this API to write JavaScript easily to interact with MongoDB database. Node JS-mongodb module uses Mongoose to interact with MongoDB database.
MongoDB Wrappers API Node JS平台包含一个单独的模块,用于将MongoDB No SQL数据库与应用程序集成。 它提供了MongoDB包装器API。我们可以使用此API轻松编写JavaScript以与MongoDB数据库进行交互。 节点JS-mongodb模块使用Mongoose与MongoDB数据库进行交互。
Node JS platform contains a separate module to integrate Redis No SQL database with applications. It provides a Redis wrapper API. We can use this API to write JavaScript easily to interact with Redis database.
Redis客户端库APINode JS平台包含一个单独的模块,用于将Redis No SQL数据库与应用程序集成。 它提供了Redis包装器API。 我们可以使用此API轻松编写JavaScript以与Redis数据库进行交互。
Node JS platform supports many template engines to write HTML. Default template engine supported by Node JS is “Jade”.
Jade is a whitespace-sensitive template engine for developing HTML applications very easily.We can write template pages once and reuse them very easily to reduce development time. We will discuss how to install and write Jade templates in a separate post.
玉模板引擎Node JS平台支持许多模板引擎来编写HTML。 Node JS支持的默认模板引擎是“ Jade”。
Jade是一个对空格敏感的模板引擎,可非常轻松地开发HTML应用程序。我们可以编写一次模板页面,然后非常轻松地重用它们,以减少开发时间。 我们将在另一篇文章中讨论如何安装和编写Jade模板。
We can develop and use HTTP Web Server within no time. We need to use http package to implement Web Server. We will discuss one post on how to install http package and develop a Web Server.
网络服务器我们可以立即开发和使用HTTP Web Server。 我们需要使用http包来实现Web服务器。 我们将讨论一篇有关如何安装http软件包和开发Web服务器的文章。
Node JS Platform provides very good Socket Module API to develop Real-time, Multi-User Chat and Multi-Player Gaming Applications very easily. It supports Unix Socket programming like pipe().
更好的套接字APINode JS平台提供了非常好的套接字模块API,可以非常轻松地开发实时,多用户聊天和多玩家游戏应用程序。 它支持Unix套接字编程,例如pipe()。
All layers from Front-End to Back-End support same Data Format i.e. JSON (Java Script Object Notation). UI Layer Angular JS Supports JSON Format, Server-Side Scripts written in Express JS supports JSON Format and Back-end MongoDB NO SQL supports same JSON Format.
一种语言和一种数据格式 我们只需要使用一种语言来编写整个应用程序,即Java Script。 我们只需要用Java脚本对从UI到控制器到业务层再到持久层(从前端到后端)的所有层进行编码。从前端到后端的所有层都支持相同的数据格式,即JSON(Java脚本对象表示法)。 UI层Angular JS支持JSON格式,用Express JS编写的服务器端脚本支持JSON格式,后端MongoDB NO SQL支持相同的JSON格式。
Node JS is Open Source Module. It provides many modules for free to use in our applications.
开源的节点JS是开源模块。 它提供了许多可在我们的应用程序中免费使用的模块。
To improve our application performance, we will scale our infrastructure. There are two ways to scale any application:
Vertical Scalability means adding more resources to a single node. Horizontal Scalability means adding more nodes to a system.
Node JS uses Horizontal Scaling instead of Vertical Scaling to our applications. It’s consistent with today’s Cloud Technology trend.
高度可扩展为了提高我们的应用程序性能,我们将扩展基础架构。 有两种扩展任何应用程序的方式:
垂直可伸缩性意味着向单个节点添加更多资源。 水平可伸缩性意味着向系统添加更多节点。
Node JS对我们的应用程序使用“水平缩放”而不是“垂直缩放”。 这与当今的云技术趋势保持一致。
I/O operations often blocks our application because it can take a long time to read a big file, or make a large query against a database, or wait for any stream of data to fully transmit.
As Node JS follows Non-Blocking IO architecture and also uses only JavaScript to develop entire application, we can achieve better performance and low latency.
If we develop our UI and Data Intensive applications by using MEAN Stack, we can achieve very high performance. MEAN Stands for MongoDB, Express JS, Angular JS and Node JS.
更好的性能和较低的延迟I / O操作通常会阻塞我们的应用程序,因为它可能需要很长时间才能读取大文件,或者对数据库进行大查询,或者等待任何数据流完全传输。
由于Node JS遵循无阻塞IO架构,并且仅使用JavaScript开发整个应用程序,因此我们可以获得更好的性能和较低的延迟。
如果我们使用MEAN Stack开发UI和数据密集型应用程序,则可以实现很高的性能。 MEAN代表MongoDB,Express JS,Angular JS和Node JS 。
Node JS Modules are cached once they are loaded into application for first time. Multiple calls to load a module may not cause the module code to be executed multiple times.
缓存模块节点JS模块在首次加载到应用程序后即被缓存。 多次调用以加载模块可能不会导致模块代码多次执行。
Now-a-Days many people are using Node JS Platform to develop and maintain their applications. Some of the popular companies who are using Node JS Platform are;
如今,许多人正在使用Node JS平台来开发和维护他们的应用程序。 一些正在使用Node JS Platform的受欢迎的公司包括:
We can use Node JS Platform to develop the following kind of applications.
我们可以使用Node JS Platform开发以下类型的应用程序。
In coming post, we will discuss about “How to setup Node JS Base Platform” and also about “Node JS Components“.
在接下来的文章中,我们将讨论“ 如何设置Node JS基本平台 ”以及“ Node JS组件 ”。
翻译自:
转载地址:http://hvqzd.baihongyu.com/