
一幅前谷歌软件工程师绘制的漫画《Welcome to Google》(欢迎来到谷歌)曾在一段时间内广为流传。画中有两条分叉的路,哪条都走不通。一条是主路,标记为“已弃用”(“别想了”,路牌上写着)。另一条新路标记为“仍在施工中”(“危险”),同样无法通行。这就是 2014 年 200 万前端开发者面临的进退维谷的选择,当时谷歌意外弃用了其流行的 JavaScript 框架 AngularJS,转而推出 Angular 2,后者架构截然不同、名称令人困惑、没有升级路径,甚至尚未正式发布。
A cartoon from an ex-Google software engineer, titled “Welcome to Google,” made the rounds a while back. It featured two diverging roads, neither passable. One was the main road, marked as deprecated (“don’t even think about it,” the sign read). The new road, however, was marked as still under construction (“Danger”), and so was unusable as well. That was the no-win choice two million frontend developers faced in 2014, when Google unexpectedly deprecated its popular JavaScript framework, AngularJS, in favor of Angular 2, which had a radically different architecture, a confusing name, no upgrade path, and wasn’t even fully released yet.
于是,许多开发者转动方向盘,奔向了“React 城”或“Vue 镇”。谷歌如何搞砸 Angular 升级,为如何“不”更新软件包提供了及时的教训,前谷歌开发者倡导者 Stephen Fluin 上周在 All Things Open 大会的演讲中对此进行了梳理。“不确定性会扼杀动力,”Fluin 说,“当你夺走开发者所熟知和热爱的一切,他们会感到灰心丧气。”
So, many developers turned the wheel and headed to Reactville or Vuetown instead. How Google botched the Angular upgrade provides timely lessons in how not to update a software package, which former Google Developer Advocate Stephen Fluin outlined in a talk at the All Things Open conference last week. “Uncertainty kills motivation,” said Fluin. “When you're taking away everything [developers] know and love, they're going to feel disheartened.”
Fluin 现任 Buildkite 开发者关系负责人,但他曾在 2016 年至 2021 年间在谷歌负责 Angular 项目。“当时情况有点艰难,简直像是一场‘死亡行军’,”他对听众说,“我们完全不知道 Angular 2 何时发布,而 Angular 的核心基础不断在变。”从 AngularJS 到 Angular 2谷歌更新 Angular 自有其理由。AngularJS 团队从谷歌基础设施部门被调至广告部门,以便软件能得到更充分的利用。
Fluin is now head of developer relations for Buildkite, but he worked for Google from 2016 to 2021 on the Angular project. “Things were a little bit rough at the time. It was a bit of a death march,” he told the audience. “We had no idea when Angular 2 was going to come out, and the core fundamentals of Angular kept changing.”From AngularJS to Angular 2 Google had good reasons for updating Angular. The AngularJS team had been snatched from Google’s infrastructure division and placed under its ad division, where the software could be more fully exploited.
为了支撑该规模的运营,Angular 需要更严谨的工程标准。最初的 AngularJS 于 2009 年作为谷歌工程师 Miško Hevery 的一个副项目推出,旨在扩展 HTML。谷歌将 AngularJS 拉入内部项目,是因为谷歌开发者发现它比基于 Java 的 Google Web Toolkit(GWT)更容易上手。
To support operations of that size, Angular needed greater rigor. The original AngularJS was launched in 2009 as a side project of Google engineer Miško Hevery, who wanted to extend HTML. Google pulled AngularJS into an internal project because Google developers found it easier to work with than the Java-based Google Web Toolkit (GWT).
该框架很快也受到了外部网页开发者的青睐,他们很容易就能理解 HTML 的尖括号(框架名字也由此而来),并且想要更多的交互式组件。赫维里(Hevery)构建了采用传统控制器模型的 AngularJS 1.3,该模型在 JavaScript 的 $scope 对象下处理所有用户输入、逻辑和数据传输。在 2014 年欧洲 Angular 大会(ng-europe 2014)上发布的 Angular 2 在架构上发生了重大转变。
The framework quickly caught on with outside web developers too, who readily understood the angle brackets of HTML (hence the name) and wanted more interactive components. Hevery built AngularJS 1.3 with a traditional controller model, which handled all user input, logic and data transport under the JavaScript $scope object. Angular 2, announced at the ng-europe 2014 conference, was a major shift in architecture.
它转向了组件模型,每个 HTML 模板都拥有自己的类属性。在与谷歌的 Dart 经历了一段被迫且不愉快的短暂结合后,团队完全用 TypeScript 重写了 Angular,完全没有向后兼容性。需要接受的东西太多了,欧洲 Angular 大会上的介绍演讲似乎把 Angular 开发者吓到了,而不是激励他们。对于每一个被废弃的功能,演讲者都会展示一张墓碑的图片(“RIP 控制器”),并在背景中播放教堂钟声敲响的录音。
It shifted to a component model, with each HTML template enjoying its own class properties. After a forced, unhappy dalliance with Google's Dart, the team rewrote Angular completely in TypeScript, with no backward compatibility whatsoever. It was a lot to take in, and the introductory talk at ng-europe seemed to spook Angular developers more than inspire them. For each discarded feature, the speakers displayed a graphic of a tombstone (“RIP Controllers”) and played a recording of a church bell tolling in the background.
“那场演讲今天依然因它对社区造成的伤害而‘闻名’,”弗卢因(Fluin)说道。“所有你了解并热爱的 AngularJS 特性都消失了。它们死了。而且没有人预料到这一点。”
“That talk is still infamous today for what it did to the community,” Fluin said. “All these things that you know and love about AngularJS are gone. They're dead. And nobody knew this was coming.”
弗卢因在他的演讲中指出,总的来说,当时并不是进行软件迁移的好时机。Python 在从版本 2 迁移到版本 3 的过程中遇到了困难,KDE 桌面从版本 4 迁移到版本 5 时也是如此。对于许多人来说,从 GNOME 2 到 3 的艰难过渡依然历历在目。名字里有什么玄机?“如果你试图让你的开发者跟你一起走,就要给他们一条路径。不要只是毁了你的旧东西,然后又没有准备好新东西,”弗卢因建议道。
In general, it was not a good time for software migrations, Fluin noted in his talk. Python was having a rough time migrating from version 2 to 3, as was the KDE desktop moving from version 4 to version 5. And the rocky transition from GNOME 2 to 3 still loomed in the rearview mirror for many. What's in a name? “If you're trying to bring your developers with you, give them a path. Don't just kill your old thing and then not have a new thing ready,” Fluin advised.
许多开发者倒戈到了 React 和 Vue.js,这是另外两个同样采用组件模型且已经投入生产的 JavaScript 前端框架。在 2016 年的 JavaScript 现状调查(State of JS Survey)中,React 是最受欢迎的前端框架,有 53% 的 JS 开发者表示他们曾使用过它。
Many devs defected to React and Vue.js, two other JavaScript frontend frameworks that also embraced the component model and were already in production. In the 2016 State of JS Survey, React was the most popular frontend framework, with 53 percent of JS devs reporting that they had used it.
Angular的受众严重分化:百分之三十的人仍在使用经典版本,而只有百分之十三的人使用Angular 2。百分之十的用户采用了当时崭露头角的Vue。Angular 2最终于2016年9月发布,随后在次年3月发布了Angular 4。由于不明原因,第3版被完全跳过了。与此同时,直到2021年底才正式退役的经典版AngularJS在2016年春季更新到了1.5版,引入了组件。
Angular’s audience was heavily bifurcated; 30 percent still used the classic version while only 13 percent used Angular 2. Ten percent of users adopted the still up-and-coming Vue. Angular 2 was finally released in September 2016, followed by Angular 4 the following March. Version 3 was skipped entirely for no discernable reason. Meanwhile, AngularJS classic, which was not formally retired until the end of 2021, was updated to version 1.5 in the spring of 2016, introducing components.
让局势更加混淆的是该框架的命名,这让许多普通观察人士感到困惑。AngularJS与Angular 2不同吗?“2”是Angular名称的一部分、标志着彻底的架构转变,还是它的版本号?事实证明,让公众理解名称的变更是一个巨大的泥潭。
Muddying the waters further was the naming of the frameworks, which confounded many casual observers. Was AngularJS different from Angular 2? And was the “2” part of the Angular name, signaling the complete architectural shift, or its version number? Getting the public to understand the name change turned out to be a major quagmire.
弗鲁因表示:“我们不得不修补公众沟通指南。我们不得不培训专家。我们不得不修复谷歌的知识图谱。”知识图谱是谷歌关于世界的事实数据库。“命名和版本控制很重要,”他对观众说道,“它们在纯技术意义上并不重要,但对人类来说很重要,因为你试图让其保持与时俱进的是人类。”
Fluin said: “We had to fix public communication guidelines. We had to train experts. We had to fix Google's knowledge graph,” which is Google’s database of facts about the world. “Naming and versioning matter,” he told the audience. “They don't matter in a pure technical sense, but they matter to human beings because it's human beings you're trying to keep up to date with.”
把Angular差点“撞沉”归咎于谷歌高管似乎很容易,但它在满足谷歌的需求方面取得了成功。如今,组件驱动的Angular为Gemini的用户界面、谷歌分析以及无数其他谷歌应用提供动力。它现在正与谷歌内部的高性能框架Wiz进行融合,Wiz最初是为命运多舛的谷歌+社交网络设计的。
It would be easy to blame the Google brass for nearly shipwrecking Angular, but it has been a success at meeting Google’s needs. Today, the component-driven Angular powers Gemini’s user interface, Google Analytics, and countless other Google apps. It is now converging with Google’s internal Wiz high-performance framework, originally designed for the ill-fated Google+ social network.
Angular也已经稳定下来,形成了更具可预测性且对用户更加友好的更新模式。更新有着例行的发布节奏,目前为每年两次。它们严格遵循语义版本控制指南,主版本号表示破坏性变更。谷歌在向公众发布该框架的每个新版本之前,都会在其自己的应用上进行测试。任何计划移除的功能都会先被弃用一年。
Angular has also settled into a more predictable and user-friendly update pattern. Updates have a routine release cadence, currently twice a year. They dutifully follow semantic versioning guidelines, with major version numbers signifying breaking changes. Google tests each new version of the framework on its own apps before releasing it publicly. Any feature slated for removal is deprecated for a year first.
但回顾来看,Google 或许最好给 Angular 2 起一个完全不同的名字,哪怕这意味着必须从零开始建立新的用户群。“JavaScript 开发者喜欢尝试新框架。所以,假装成一个新框架可能会更好,”Fluin 告诉 The Register。
But in retrospect, Google may have been better off giving Angular 2 an entirely different name, even if it meant building up a new user base from scratch. “JavaScript developers loved trying new frameworks. So, pretending to be a new framework might have been better,” Fluin told The. ®