(翻译)《Hands-on Node.js》—— Introduction

时间:2023-02-17 18:10:46

今天开始会和大熊君{{bb}}一起着手翻译node的系列外文书籍,大熊负责翻译《Node.js IN ACTION》一书,而我暂时负责翻译这本《Hands-on Node.js》(下载),为方便理解不采用直译的方式,若有翻译不当的地方还请不吝赐教,我会及时堪正。

(翻译)《Hands-on Node.js》—— Introduction

引言

在09年欧洲JSConf大会上,一位叫做Ryan Dahl的年轻程序员介绍了一项他所负责的项目。该项目结合了谷歌V8 Javascript引擎以及event loop机制,从而可以使用JS来创建服务端平台。该项目跟其它服务端JS平台不太一样:所有的I/O基元都是事件驱动的,没有其它捷径。借力于强大又简单的JS,原本基于异步读写的应用任务,由复杂变得简单好实现。

Dahl演讲完毕时会场掌声不断,他的项目也取得了空前的发展,日益流行并被广泛采用。

该项目被命名为Node.js,时下常被程序员们简称为“Node”。Node提供了纯事件驱动的、无阻塞的架构来创建高并发的程序,使用它能让你轻松构造快速又可扩展的网络服务。

Introduction

At the European JSConf 2009, a young programmer by the name of Ryan Dahl, introduced a project
he had been working on. This project was a platform that combined Google’s V8 JavaScript engine
and an event loop to create a server-side platform programmable in JavaScript. The project took a
different direction from other server-side JavaScript platforms: all I/O primitives were event-driven,
and there was no way around it. Leveraging the power and simplicity of JavaScript, it turned the
difficult task of writing asynchronous applications into an easy one. Since receiving a standing
ovation at the end of his talk, Dahl’s project has been met with unprecedented growth, popularity
and adoption.
The project was named Node.js, now known to developers simply as ‘Node’. Node provides purely
evented, non-blocking infrastructure for building highly concurrent software.
Node allows you to easily construct fast and scalable network services.

原文

为何Node如此突然地、呈指数倍地流行起来?

服务端JS其实已经出现多时了,是什么让Node平台如此引人注目?

环顾之前的那些服务端JS的实现,更着重处理的地方还是把其它平台(比如Ruby、PERL、Python)上常用的方法迁移到JS中,而JS本身不露锋芒。Node跳过了这种处理,并表示——“让我们使用web上那些可成功驱动事件的编程模块,来轻松创建可扩展的服务,并让这种方式无可替代、无所不能”。

可以说JS本身为Node的成功做出了很大的贡献,但这点不能解释Node之前的其它服务端项目为何没有流行起来。虽然JS的确具备了普遍性,但对此Ryan Dah指出,不像其它服务端中JS所做的尝试,统一客户端和服务端的语言并非Node的首要目标。

在我看来,Node成功的主要因素有三个:

1. Node很简单——使用了事件驱动I/O编程,是最好的I/O编程方式,比起其它现有平台的实现更易懂、更成功。

2. Node很精练——它不会试着去解决全部问题,而是依靠清晰明确的功能性API为处理internet协议奠定了基础和支持。

3.Node不妥协——不会试着去兼容之前的软件,并让人们重新审视并首肯了其定位。

Why the sudden, exponential popularity?

Server-side JavaScript has been around for some time, what makes this platform so appealing?
In previous server-side JavaScript implementations, javascript was the raison d’etre, and the
approach focussed on translating common practices from other platforms like Ruby, PERL and
Python, into JavaScript. Node took a leap from this and said: “Let’s use the successful event-driven
programming model of the web and use it to make an easy way to build scalable servers. And let’s
make it the only way people can do anything on this platform.”.
It can be argued that JavaScript itself contributed to much of Node’s success, but that would not
explain why other the server-side projects proceeding Node have not yet come close in popularity.
The ubiquity of JavaScript surely has played a role, but, as Ryan Dahl points out, unlike other Serverside
JavaScript attempts, unifying the client and server into a common language was not the primary
goal for Node.
In my perspective there are three factors contributing to Node’s success:
1. Node is Easy - Node makes event-driven I/O programming, the best way to do I/O programming,
much easier to understand and achieve than in any other existing platform.
2. Node is Lean - Node does not try to solve all problems. It lays the foundation and supports
the basic internet protocols using clean, functional APIs.
3. Node does not Compromise - Node does not try to be compatible with pre-existing software,
it takes a fresh look at what many believe is the right direction.

原文

本书涵盖内容

我们会分析为何Node不走寻常路,以及为何你应该使用Node、如何使用Node。我们会从一个概述开始,然后很快转入模块化代码。在最终你将懂得创建和测试你自己的Node模块、服务端/客户端应用,并享受Node的便捷和各种API。

What does this book cover?

We will analyze what makes Node a different proposal to other server-side solutions, why you
should use it, and how to get started. We will start with an overview but quickly dive into some
code module-by-module. By the end of this book you should be able to build and test your own
Node modules, service producers/consumers and feel comfortable using Node’s conventions and
API.

原文

本书没有涵盖的内容

本书并不打算介绍完全部的Node API,但我们会介绍那些作者认为的大部分应用所需要的、常用的部分。

本书也不会涉及任何Node框架。Node是一个很棒的创建框架的工具,其中也不乏好用的框架,比如簇管理的、跨进程通讯的、web框架、网络流量整合工具、游戏引擎等等。不过在你开始接触框架之前,你应该先熟悉Node的基础架构并了解它为这些构建模块提供了些什么。

What does this book not cover?

This book does not attempt to cover the complete Node API. Instead, we will cover what the author
thinks is required to build most applications he would build on Node.
This book does not cover any Node frameworks; Node is a great tool for building frameworks and
many are available, such as cluster management, inter-process communication, web frameworks,
network traffic collection tools, game engines and many others. Before you dive into any of those
you should be familiar with Node’s infrastructure and what it provides to these building blocks.

原文

阅读本书的先决条件

本书假设你之前并未了解任何Node知识,但各种例子的代码毕竟是用JS书写的,所以熟悉JS这门语言有助你理解。

Prerequisites

This book does not assume you have any prior knowledge of Node, but the code examples are written
in JavaScript, so familiarity with the JavaScript language will help.

原文

练习

本书在部分小节会有练习题,你可以在书的最后找到这些练习的答案,但我建议你先自行动手解题,棘手处可查阅本书或访问http://nodejs.org查阅完整的API文档。

Exercises

This book has exercises in some chapters. At the end of this book you can find the exercise
solutions, but I advise you to try do them yourself. Consult this book or use the comprehensive
API documentation on the official http://nodejs.org¹ website.

原文

源码

你可以在GitHub上找到本书的部分源码和练习:

https://github.com/pgte/handson_nodejs_source_code

或者直接下载它们:

https://github.com/pgte/handson_nodejs_source_code/zipball/master

Source code

You can find some of the source code and exercises used in this book on GitHub:
https://github.com/pgte/handson_nodejs_source_code²
or you can download it directly:
https://github.com/pgte/handson_nodejs_source_code/zipball/master³

原文

本书的引导方向

在阅读完本书后,你将了解Node API并可以从事研究那些基于Node所搭建出来的东西(比如适配器、框架和模块),让我们启程吧。

Where will this book lead you?

By the end of it, you should understand the Node API and be able to pursue the exploration of other
things built on top of it, being adaptors, frameworks and modules.
Let’s get started!

原文

(翻译)《Hands-on Node.js》—— Introduction

(翻译)《Hands-on Node.js》—— Introduction的更多相关文章

  1. 翻译--Blazing fast node.js: 10 performance tips from LinkedIn Mobile

    1.避免使用同步代码: // Good: write files asynchronously fs.writeFile('message.txt', 'Hello Node', function ( ...

  2. [Node.js] Introduction to apiCheck.js

    timeoutLog.js: var apiCheckFactory = require('api-check'); var myCheck = apiCheckFactory(); module.e ...

  3. Node.js v0.10.31API手工-DNS

    原版的API品种,这是从以前的翻译和翻译风格不同 Node.js v0.10.31API手冊-文件夹 DNS 使用 require('dns') 引入此模块. dns 模块中的全部方法都使用了 C-A ...

  4. A chatroom for all! Part 1 - Introduction to Node.js(转发)

    项目组用到了 Node.js,发现下面这篇文章不错.转发一下.原文地址:<原文>. ------------------------------------------- A chatro ...

  5. &lbrack;翻译&rsqb; 比较 Node&period;js,Python,Java,C# 和 Go 的 AWS Lambda 性能

    [翻译] 比较 Node.js,Python,Java,C# 和 Go 的 AWS Lambda 性能 原文: Comparing AWS Lambda performance of Node.js, ...

  6. Node&period;js Addons翻译&lpar;C&sol;C&plus;&plus;扩展&rpar;

    PS:请先升级Node 6.2.1,Node 升级命令 npm install -g n;n stable.NOde.js扩展是一个通过C/C++编写的动态链接库,并通过Node.js的函数requi ...

  7. Jade —— 源于 Node&period;js 的 HTML 模板引擎

    2013-12-11 发布 Jade —— 源于 Node.js 的 HTML 模板引擎 开源项目介绍 web 模板引擎 node.js jade 207.8k 次阅读  ·  读完需要 69 分钟 ...

  8. Node&period;js npm 详解

    一.npm简介 安装npm请阅读我之前的文章Hello Node中npm安装那一部分,不过只介绍了linux平台,如果是其它平台,有前辈写了更加详细的介绍. npm的全称:Node Package M ...

  9. Node&period;js实现RESTful api&comma;express or koa&quest;

    文章导读: 一.what's RESTful API 二.Express RESTful API 三.KOA RESTful API 四.express还是koa? 五.参考资料 一.what's R ...

随机推荐

  1. Javascript获取div真实高度

    第一种情况就是宽高都写在样式表里,就比如#div1{width:120px;}.这中情况通过#div1.style.width拿不到宽度,而通过#div1.offsetWidth才可以获取到宽度. 第 ...

  2. 完全卸载AndroidStudio

    一:卸载Android Studio 由于从1.5正式版直接升级到2.1的版本,整个项目构建都变得异常的慢,所以决定卸载重新安装2.0的正式版.但是Mac下使用dmg安装的app很多都是不能使用拖拽的 ...

  3. HotSpot 自动内存管理笔记与实战

    1.对象的创建 虚拟机遇到一条new指令时,首先会去检查这个指令的参数是否能在常量池中定位到一个类的符号引用,并且检查这个符号引用代表的类是否已被加载.解析和初始化过.如果没有,则必须先进行相应的类的 ...

  4. linux入门级常用命令

    1) 关闭Linux系统的命令:init 02) Linux终端:Linux终端也称为虚拟控制台.Linux终端采用字符命令行方式工作,用户通过键盘输入命令,通过Linux终端对系统进行控制.3) 切 ...

  5. DevExpress&period;XtraGrid winform试用分享

    DevExpress.XtraGrid在winform里使用还挺麻烦,为了减少重复代码和代码复用,本人针对DevExpress.XtraGrid封装了一个Form的基类,其中涵盖了DevExpress ...

  6. IE6兼容透明背景图

    JS代码: <!--[if IE 6]><script src="~/Scripts/UI/DD_belatedPNG.js"></script&gt ...

  7. HDU----&lpar;4291&rpar;A Short problem&lpar;快速矩阵幂&rpar;

    A Short problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. jQuery EasyUI学习资源汇总

    jQuery EasyUI学习资源汇总 EasyUi – 1.入门 EasyUi – 2.布局Layout + 3.登录界面 EasyUi – 4.datwagrid 学习Jquery EasyUI的 ...

  9. &lbrack;uva11992&rsqb;Fast Matrix Operations(多延迟标记,二维线段树,区间更新)

    题目链接:https://vjudge.net/problem/UVA-11992 题意:n*m的矩阵,每次对一个子矩阵操作,有三种操作:加x,设置为x,查询.查询返回子矩阵和.最小值.最大值 n很小 ...

  10. Python函数的定义、参数传入与函数的调用

    作为计算机代码的一种抽象方式,函数在Python中扮演了极为重要的角色.今天给大家介绍Python函数的定义.参数的传入以及调用方式.其中函数参数的传入方式为本节重点内容.Python函数的参数形式包 ...