ecmascript
JavaScript is a living language which is constantly adding new features. What I want to do in this post is break down that process and show the steps needed for a new feature to go from a simple idea to part of the official specification. To do that, we’ll need to cover three things: ECMA, ECMAScript, and the TC39.
JavaScript是一种生动的语言,正在不断添加新功能。 我在这篇文章中要做的是分解该过程,并说明将新功能从简单的想法变为正式规格的一部分所需的步骤。 为此,我们需要介绍三件事:ECMA,ECMAScript和TC39。
Note that I’ve also recorded a video version of this article, if you’d prefer to watch that:
请注意,如果您更喜欢看这篇文章,我还录制了本文的视频版本:
Let’s take ourselves back to 1995. The cult classic Heavy Weights was in theaters, Nicolas Cage won an Oscar, and websites looked something like this. Now, odds are the way you viewed this website was with Netscape Navigator.
让我们回到1995年。备受追捧的经典电影《重量级》曾在电影院里演出,尼古拉斯·凯奇(Nicolas Cage)赢得了奥斯卡奖,而网站看起来像这样。 现在,使用Netscape Navigator的可能性很大。
At the time, Netscape Navigator was the most popular web browser with almost 80% market share. The founder of Netscape, the company behind Netscape Navigator, was Mark Andreessen. He had a vision for the future of the web and it was more than just a way to share and distribute documents. He envisioned a more dynamic platform with client side interactivity — a sort of “glue langauge” that was easy to use by both designers and developers.
当时,Netscape Navigator是最受欢迎的Web浏览器,拥有近80%的市场份额。 Netscape Navigator的公司Netscape的创始人是Mark Andreessen。 他对网络的未来抱有远见,而不仅仅是共享和分发文档的一种方式。 他设想了一个具有客户端交互性的更加动态的平台-一种“胶水语言”,设计人员和开发人员都易于使用。
This is where Brendan Eich comes into the picture. He was recruited by Netscape with the goal of embedding the Scheme programming language into Netscape Navigator. But before he could get started, Netscape collaborated with Sun Microsystems to make their up and coming programming language Java available in the browser. Now this brings up the question, “If Java was already a suitable language, why bring on Brendan to create another one?“.
这就是Brendan Eich出现的地方。 他是由Netscape招聘的,目的是将Scheme编程语言嵌入到Netscape Navigator中。 但是在开始使用Netscape之前,Netscape与Sun Microsystems合作,在浏览器中提供了他们即将使用的编程语言Java。 现在,这就提出了一个问题:“如果Java已经是一种合适的语言,那么为什么要带Brendan创建另一种语言呢?”。
Well if you remember back to Netscape’s goal, they wanted a scripting language that was simple enough for designers and amateurs to use — Java wasn’t that. So the idea became that Java could be used by professionals and “Mocha”, which was the initial name of JavaScript, would be used by everyone else.
好吧,如果您还记得Netscape的目标,他们想要一种对于设计人员和业余爱好者来说足够简单的脚本语言-Java并不是那样。 因此,想法变成了Java可以由专业人员使用,而“ Mocha”(JavaScript的初始名称)将被其他所有人使用。
Because of this collaboration between languages, Netscape decided that Mocha needed to compliment Java and should have a relatively similar syntax. Then, in just 10 days, Brendan created the first version of Mocha which still had some functionality from Scheme, the object orientation of SmallTalk, and the syntax of Java. Eventually the name Mocha changed to LiveScript and then LiveScript changed to JavaScript as a marketing ploy to ride the hype of Java. So at this point, JavaScript was marketed as a scripting language for the browser — accessible to both amateurs and designers while Java was the professional tool for building rich web components.
由于语言之间的这种协作,Netscape决定Mocha需要补充Java,并且应该具有相对相似的语法。 然后,在短短10天之内,Brendan创建了Mocha的第一个版本,该版本仍然具有Scheme的功能,SmallTalk的面向对象以及Java的语法。 最终,Mocha的名称更改为LiveScript,然后LiveScript更改为JavaScript,以作为宣传Java的营销手段。 因此,在这一点上,JavaScript作为浏览器的一种脚本语言被推向市场,无论是业余爱好者还是设计师都可以使用,而Java是构建富Web组件的专业工具。
Now, it’s important to understand the context of when these events were happening. Besides Nicolas Cage winning an Oscar, Microsoft was also working on Internet Explorer. Because JavaScript fundamentally changed the user experience of the web, if you were a competing browser you had no choice but to come up with your own JavaScript implementation since it wasn’t standardized yet. So, that’s exactly what Microsoft did and they called it JScript.
现在,重要的是要了解这些事件发生的时间背景。 除了尼古拉斯·凯奇(Nicolas Cage)赢得奥斯卡奖外,微软还在开发Internet Explorer。 因为JavaScript从根本上改变了Web的用户体验,所以如果您使用的是竞争性浏览器,则您只能选择自己JavaScript实现,因为它尚未标准化。 因此,这正是Microsoft所做的,他们将其称为JScript。
This lead to a pretty famous problem in the history of the internet. JScript filled the same use case as JavaScript, but its implementation was different. This meant that you couldn’t build one website and expect it to work on both Internet Explorer and Nestscape Navigator. In fact, the two implementations were so different that “Best viewed in Netscape” and “Best viewed in Internet Explorer” logos became common for most companies who couldn’t afford to build for both implementations.
这导致了互联网历史上一个非常著名的问题。 JScript填充了与JavaScript相同的用例,但是其实现不同。 这意味着您无法构建一个网站,并期望它在Internet Explorer和Nestscape Navigator上都能正常工作。 实际上,这两种实现方式是如此不同,以致于“不起眼的Netscape”徽标和“最好的Internet Explorer徽标”徽标对于大多数无力为这两种实现构建的公司都变得司空见惯。
This is where Ecma comes into the picture. Ecma International is “an industry association founded in 1961, dedicated to the standardization of information and communication systems.” In November of 1996, Netscape submitted JavaScript to Ecma to build out a standard specification.
这是Ecma出现的地方。 Ecma International是“成立于1961年的行业协会,致力于信息和通信系统的标准化。” 1996年11月,Netscape向Ecma提交了JavaScript,以建立标准规范。
By doing this it gave other implementors a voice in the evolution of the language and, ideally, it would keep other implementations consistent across browsers. So let’s dive into how Ecma works.
通过这样做,它使其他实现者可以在语言的发展中发声,并且理想情况下,它将使其他实现在浏览器之间保持一致。 因此,让我们深入研究Ecma的工作原理。
Each new specification comes with a standard and a committee. In JavaScript’s case, the standard is ECMA-262 and the committee who works on the ECMA-262 standard is the TC39. If you look up the ECMA262 standard, you’ll notice that the term “JavaScript” is never used. Instead, they use the term “EcmaScript” to talk about the official language. The reason for this is because Oracle owns the trademark for the term “JavaScript”, so to avoid legal issues, Ecma used the term EcmaScript instead.
每个新规范都有一个标准和一个委员会。 就JavaScript而言,标准为ECMA-262,负责ECMA-262标准的委员会为TC39。 如果您查找ECMA262标准,您会发现从未使用过“ JavaScript”一词。 相反,他们使用术语“ EcmaScript”来谈论官方语言。 原因是因为Oracle拥有“ JavaScript”一词的商标,因此为避免法律问题,Ecma改用了EcmaScript。
In the real world, ECMAScript is usually used to refer to the official standard, EMCA-262, while JavaScript is used when talking about the language in practice. As mentioned earlier, the committee which oversees the evolution of the Ecma262 standard is the TC39, which stands for Technical Committee 39.
在现实世界中,通常使用ECMAScript来指代官方标准EMCA-262,而在实践中谈论该语言时使用JavaScript。 如前所述,负责监督Ecma262标准发展的委员会是TC39,它代表技术委员会39。
The TC39 is made up of “members” who are typically browser vendors and large companies who’ve invested heavily in the web like Facebook and PayPal. To attend the meetings, “members” (again, large companies and browser vendors) will send “delegates” to represent said company or browser. It’s these delegates who are responsible for creating, approving, or denying language proposals.
TC39由“成员”组成,这些成员通常是浏览器供应商以及在Facebook和PayPal等网络上进行了大量投资的大型公司。 为了参加会议,“成员”(同样是大型公司和浏览器供应商)将发送“代表”来代表所述公司或浏览器。 这些代表负责创建,批准或拒绝语言建议。
When a new proposal is created, that proposal has to go through certain stages before it becomes part of the official specification. It’s important to keep in mind that in order for any proposal to move from one stage to another, a consensus among the TC39 must be met. This means that a large majority must agree while nobody strongly disagrees enough to veto a specific proposal.
创建新提案时,该提案必须经过某些阶段才能成为正式规范的一部分。 重要的是要记住,为了使任何提案从一个阶段过渡到另一个阶段,必须在TC39之间达成共识。 这意味着绝大多数人必须同意,而没有人强烈不同意以否决一项特定的建议。
Each new proposal starts off at Stage 0. This stage is called the Strawman stage. Stage 0 proposals are “proposals which are planned to be presented to the committee by a TC39 champion or, have been presented to the committee and not rejected definitively, but have not yet achieved any of the criteria to get into stage 1.” So the only requirement for becoming a Stage 0 proposal is that the document must be reviewed at a TC39 meeting. It’s important to note that using a Stage 0 feature in your codebase is fine, but even if it does continue on to become part of the official spec, it’ll almost certainly go through a few iterations before then.
每个新提案都从阶段0开始。这个阶段称为Strawman阶段。 阶段0提案是“计划由TC39冠军提交给委员会的提案,或者已经提交给委员会并且没有被明确拒绝,但尚未达到进入阶段1的任何标准的提案。” 因此,成为第0阶段提案的唯一要求是必须在TC39会议上审查该文件。 需要注意的重要一点是,在代码库中使用Stage 0功能很好,但是即使它继续成为正式规范的一部分,也几乎肯定会在此之前进行几次迭代。
The next stage in the maturity of a new proposal is Stage 1. In order to progress to Stage 1, an official “champion” who is part of TC39 must be identified and is responsible for the proposal. In addition, the proposal needs to describe the problem it solves, have illustrative examples of usage, a high level API, and identify any potential concerns and implementation challenges. By accepting a proposal for stage 1, the committee signals they’re willing to spend resources to look into the proposal in more depth.
新提案成熟度的下一个阶段是第1阶段。为了进入第1阶段,必须确定属于TC39的官方“冠军”,并负责该提案。 此外,该提案需要描述其解决的问题,具有用法的说明性示例,高级API,并确定任何潜在的问题和实施挑战。 通过接受第一阶段的提案,委员会表示他们愿意花费资源来更深入地研究提案。
The next stage is Stage 2. At this point, it’s more than likely that this feature will eventually become part of the official specification. In order to make it to stage 2, the proposal must, in formal language, have a description of the syntax and semantics of the new feature. In other words, a draft, or a first version of what will be in the official specification is written. This is the stage to really lock down all aspects of the feature. Future changes may still likely occur, but they should only be minor, incremental changes.
下一阶段是阶段2。在这一点上,此功能很有可能最终成为正式规范的一部分。 为了进入第2阶段,该提案必须以正式语言描述新功能的语法和语义。 换句话说,将写成正式规范中的草稿或第一版。 这是真正锁定功能各个方面的阶段。 未来的更改仍可能会发生,但应仅是次要的增量更改。
Next up is Stage 3. At this point the proposal is mostly finished and now it just needs feedback from implementors and users to progress further. In order to progress to Stage 3, the spec text should be finished and at least two spec complient implementations must be created.
接下来是第3阶段。此时,提案已基本完成,现在只需要实施者和用户的反馈就可以进一步进行。 为了进入第3阶段,应完成规范文本,并且必须至少创建两个符合规范的实现。
The last stage is Stage 4. At this point, the proposal is ready to be included in the official specification. To get to Stage 4, tests have to be written, two spec complient implementations should pass those tests, members should have significant practical experience with the new feature, and the EcmaScript spec editor must sign off on the spec text. Basically once a proposal makes it to stage 4, it’s ready to stop being a proposal and make its way into the official specification. This brings up the last thing you need to know about this whole process and that is TC39s release schedule.
最后一个阶段是第4阶段。此时,该提案已准备好被包含在正式规范中。 要进入第4阶段,必须编写测试,两个符合规范的实现应通过这些测试,成员应具有使用此新功能的丰富实践经验,并且EcmaScript规范编辑器必须在规范文本上签名。 基本上,一旦提案进入第4阶段,它就可以停止成为提案,并进入正式规范。 这带来了您需要了解的整个过程的最后一件事,那就是TC39的发布时间表。
As of 2016, a new version of ECMAScript is released every year with whatever features are ready at that time. What that means is that any Stage 4 proposals that exist when a new release happens, will be included in the release for that year. Because of this yearly release cycle, new features should be much more incremental and easier to adopt.
截至2016年,每年都会发布新版本的ECMAScript,其中包含当时已准备就绪的所有功能。 这意味着当新版本发布时存在的所有第4阶段提案都将包含在该年份的版本中。 由于这个年度发布周期,新功能应该更多地增量且更易于采用。
This is part of my tylermcginnis.com “Modern JavaScript” course.
这是我的tylermcginnis.com “ 现代JavaScript ”课程的一部分。
翻译自: https://www.freecodecamp.org/news/ecmascript-tc39-and-the-history-of-javascript-26067498feb9/
ecmascript