• <翻译>commonJS让JavaScript走向了统治全世界的道路上


    这是一篇介绍commonJS的文章,英文地址:

    http://arstechnica.com/web/news/2009/12/commonjs-effort-sets-javascript-on-path-for-world-domination.ars

    闲来无事,觉得这篇文章介绍commonJS写得很好,翻译如下:

    今年(2009年)是JavaScript的全新之年,又新又快的JavaScript引擎和类库已经走向成熟。随着ECMAScript5起草发布,JavaScript这门语言已经烽火燎原。在这之前,JavaScript除了在web浏览器方面发力外,在其他广大领域基本上没有什么作为。但是今年是JavaScript走出浏览器全面面向其他领域的标志之年,最明显的标志就是今年的欧洲JavaScript会议。

    自从1996年,JavaScript1.1在网景公司的Netscape Navigator3.0发布后,已经面世了很多JavaScript编程平台,比如有个在澳大利亚最火的Helma(海马)的系统已经闻名遐迩。在2007年,位于旧金山的在线协作企业AppJet提供了一项用来创建和支持主机服务器端JavaScript应用的服务(现在这个服务已经中止了)。Aptana公司也提供了一套IDE支持前后台JavaScript的web应用程序叫做Jaxer。经过了每一代web的发展,但是JavaScript没能成为像Perl,PHP,Python,Ruby,Java或其它可供选择的通用编程语言。

    然而,有几件事情的发生改变了这样的情况:由JavaScript驱动的http请求方式的出现,繁荣引发了高度交互的网站和应用。这让出现更快的能方便web开发同时快速响应异常的JavaScript引擎需求变得日益迫切,同时,这些高交互的应用程序经常要求高效率的代码运行在客户端和服务器端。特别是,根据经验来说,技术的进步通常需要以实现在服务器渲染和基本的用户体验的技术上(这句话我也不是很懂)。

    JavaScript有更多的事情要做,JavaScript是唯一一门能运行在每一台客户端电脑上的编程语言,他已经这样运行了10年了。在后QBasic年代,html,css和JavaScript语言已经开始像一个笨拙的、戴眼镜的穴居人开始走向现代社会,更显著的是出现了一大群能稳定运用iquery的动画设计师和JavaScript工程师。尽管JavaScript有一些小缺点,但是它还是很cool,人们开始慢慢接受并喜欢上它。

    所以我们来谈谈是什么阻止JavaScript统治世界了?

      1、JavaScript没有模块系统,为了完成JavaScript的脚本,工程师们必须管理网页,链接,插入,或手动提取和评价。这里没有本地设备可以进行隔离或进行管理。

      2、JavaScript没有标准的类库,它有浏览器API、数据、数学函数,但是没有文件系统API、少得可怜的输入输出API或者根本的二进制数据类型。

      3、JavaScript没有标准的为web服务器、数据库服务的接口。

      4、JavaScript没有包管理系统,管理系统的依赖自动安装jsan(不要混淆为json这属于范围的隔离

    CommonJS是一项倡议,由凯文.丹格在一月份提出,写在他的个人博客上,并创立了一个邮件列表在他的博客里凯文概述了上述问题,并与爱好者联合起来写一些规格,称为服务器端脚本,支持各种平台下的互操作性

    “这不是一个技术性问题,而是人们联合起来做出一个决定朝着建立一个更强大的工具的问题”这项申明这样写道。

    一周之后,有224个用户,653条留言申明:我们知道凯文的申明震撼了世界。它可能帮助凯文已经创建Python的Turbo Gears框架Paver目前Mozilla的贝斯平。在HelmaHannes Wallnofer,Chris Zumbrunn后面出现了。因为JSON的扩展而出名的Kris ZYP也出现了,带着 的JavaScript持久对象存储项目出现了 ondrej Zara带来v8cgi绘图板,Ihab Awad带来谷歌的Cja,韦斯加兰带来一个Mozilla的SpiderMonkey为基础的实施

    一个月后,我们会聚在一个规格为模块系统和可互操作的模块。现在,有超过12个CommonJS模块的实现装载机,成百上千的顺从的模块。

    是一个日益扩大的CommonJS收集的标准,包括:

    1、模块

    2、二进制字符串和缓存

    3、字符集编码

    4、二进制、缓存、文本的输入和输出(io)流

    5、系统运行参数、环境和流

    6、文件系统接口

    7、单元测试断言,运行,和报告

    8、web服务器网关接口

    9、本地和远程软件包和软件包管理

    到目前为止,CommonJS已经集成了产品规格的模块(1.1),系统模块(1.0)和一个单元测试的API(第1.0章)。下一个的目的是为了推动一个二进制API;两个ECMA TC39(负责ECMAScript的技术委员会)和W3C(负责浏览器标准的标准机构)正在考虑共同的追求。

    Modules are a big deal. CommonJS modules represent the first time a JavaScript community has converged on a module system that is as good as (if not better than) the best of Python and Ruby's—supporting not only dependency management, but also scope isolation and relative module identifiers. Module systems supporting CommonJS can be written for servers, browsers, desktop applications, and secure sandboxes. Browser deployments can vary from XHR+eval (for easy debugging) to script injection (for production or debugging) either with a build step or dynamic, server-side support. This means that modules targeting CommonJS compliance are truly interoperable. The CommonJS module standard separates the concern of how your module system works from how modules should be written.

    模块是一个大问题。CommonJS模块代表了第一次JavaScript社区系统聚集一个和Python、RTuby同样好的,不仅依赖管理,还范围相对模块隔离和标识符的模块。模块系统让CommonJS可以用于服务器,浏览器,桌面应用程序、安全的sandboxes。浏览器部署千差万遍,从XHR+eval到脚本注入,或者一个构建步骤或动态的服务器支持。这意味着模块CommonJS的真正目标应该是符合可互操作的。CommonJS模块的标准将关注你的模块系统的工作原理和模块应该怎样被写。

    And the best part is that it's real. At jsconf.eu, several the CommonJS founder projects showcased CommonJS compliant module systems, a couple projects announced they were using CommonJS, and many others expressed interest in bringing CommonJS to their platforms.

    同时最好的部分是他的真实,在js大会上,几位commonJS的创始人陈述了commonJS的可顺从模块系统,以部门工程师宣称他们正在使用commonJS,还有很多人表示对commonJS很感兴趣可能会在他们的平台上使用commonJS。

    NodeJS, a server-side JavaScript platform built on Google's lightening-fast V8 engine by Ryan Dahl, showcases purely asynchronous IO and event loop concurrency. Dahl spoke passionately about the pitfalls of threading and synchronous IO. "Threaded concurrency is a leaky abstraction," he claimed, and further, "Doing the right thing should be easy; doing the wrong thing should be hard." In most programming contexts, there are pervasive synchronous IO libraries and system routines. It can be hard to know whether an API will block, which makes it impossible to reliably write non-blocking code. Anyone who has tried to write a concurrent socket server knows that the road is littered with the bones of those who came before. Dahl's talk won him a standing ovation. Node is targeting a degree of CommonJS interoperability and presently supports the CommonJS module system. 

    NodeJS,一种服务器端的JavaScript平台,他是基于google的轻便快速的v8引擎,展示了一种纯粹的异步IO和事件循环并发。戴尔激情讲述同步线程化和异步IO的陷阱。“现成并发是一个有缺陷的概念,”他说,并进一步提出,“做正确的事应该很容易,做这些事应该很难。在大多数编程环境,有普遍的同步IO库和系统程序。很难知道一个API是否会被阻止,这使得要写一个不被打断的代码变得不可能完成。他的谈话赢得了全场起立鼓掌。NodeJS就是针对CommonJS互操作性的和目前很好的支持了CommonJS模块系统。

    Narwhal is a cross-platform, multi-engine general purpose JavaScript platform brought to you by Tom Robinson and 280 North, the makers of Cappuccino, Objective-J, 280 Slides, and 280 Atlas. Narwhal presently supports Mozilla's Rhino, V8, Apple's JavaScriptCore, and desktop applications in Mozilla's XULRunner. Narwhal can also host its modules for use in webpages.

    Narwhal 是一个跨平台的、多引擎javascript平台,是由汤姆•罗宾森和280 North创造。目前支持拉的Narwhal的有Mozilla的犀牛,V8引擎,苹果公司的JavaScriptCore,并且桌面应用的XULRunner。Narwhal模块同时也可以用于网页。

    Narwhal supports CommonJS modules and has prototype implementations of IO, file-system support, and binary data. Narwhal also comes with a wealth of standard library modules collected and ported from every end of the Web for everything from command line option parsing to secure hashing. Narwhal works out of the box and includes a package manager, "tusk," that gives you instant access to literally dozens of installable packages. In all seriousness, the catalog is growing quickly because making a package is as simple as adding a package.json file to the root of a project on Github and as flexible as putting a Zip archive with apackage.json anywhere on the Web.

    (未完待续)

  • 相关阅读:
    $(document).ready(function(){}) 与 window.onload = function(){} 区别
    [如何在Mac下使用gulp] 1.创建项目及安装gulp
    Mac 执行 gulp 报错 bash: gulp: command not found
    css 字体单位之间的区分以及字体响应式实现
    [nodejs]在mac环境下如何将node更新至最新?
    [angular 1.x] 使用select 实现下拉列表 ngoptions 与 ngrepeat的取舍
    事件冒泡、事件捕获、事件委托初探
    Android 随机铃声管理器
    git 强制恢复到某一版本
    混乱中生存
  • 原文地址:https://www.cnblogs.com/fredshare/p/2474231.html
Copyright © 2020-2023  润新知