前端也要学英语——我们放弃了TypeScript

106 阅读5分钟

写在前面

前端也要学英语系列,针对有外企工作意向或者海外远程办公需求的前端开发者,通过翻译一些原汁原味的技术文章,积累计算机相关英语词汇和表达。

正文部分

Turbo 8正在放弃TypeScript

Turbo 8 is dropping TypeScript

大家都说,TypeScript对微软来说是一个巨大的成功。

By all accounts, TypeScript has been a big success for Microsoft.

我看到过很多人因为在JavaScript中添加了可以被编译器检查的显式类型而欣喜不已

I've seen loads of people sparkle with joy from dousing JavaScript with explicit types that can be checked by a compiler.

但我从来不是它的粉丝

But I've never been a fan.

五分钟后不会,五年之后也不会。

Not after giving it five minutes, not after giving it five years.

因此,我非常高兴地宣布,我们将从Turbo 8的下一个重要版本中删除TypeScript。

So it's with great pleasure that I can announce we're dropping TypeScript from the next big release of Turbo 8.

事实上,我其实很喜欢JavaScript。

The fact is that I actually rather like JavaScript.

我甚至可以说它是我仅次于Ruby的第二喜欢的语言。

I'd go so far as to say it's my second favorite language after Ruby.

是的,一个有距离的第二,但尽管如此仍然可以排在第二。

Yes, a distant second, but a second none the less.

情况并非总是这样

This wasn't always the case.

在JavaScript中有了合适的类,以及ES6以来的所有其他改进之后,编写代码变成了一种真正的乐趣。

But after we got proper classes in JavaScript, and all the other improvements that flowed since ES6, it's become a real joy to write.

我仍然认为JavaScript并不完全适配我们在web应用程序服务器端所做的大部分工作,但我完全尊重并欣赏其他人的不同看法。

I still don't think JavaScript is well-suited for most of the work we do on the server side of the web-app equation, but fully respect and appreciate that others feel differently.

对我来说,拥有这样一个功能强大的JavaScript是我们的幸运,浏览器完全不需要``编译器就可以对其进行解释

To me, it's simply our good fortune that we now have such a capable JavaScript, which browsers are able to interpret without any need for a compiler at all.

TypeScript对我来说是个阻碍

TypeScript just gets in the way of that for me.

不仅因为它需要显式的编译步骤,还因为它用类型技巧污染了代码,这给我的开发体验带来了很少的乐趣,而且经常带来相当大痛苦

Not just because it requires an explicit compile step, but because it pollutes the code with type gymnastics that add ever so little joy to my development experience, and quite frequently considerable grief.

应该容易的事情变得困难,而困难的事情变得“any”。

Things that should be easy become hard, and things that are hard become any.

不,谢谢!

No thanks!

不过,这并不是在请求``改变``任何人的想法

This isn't a plea to convert anyone of anything, though.

正如我在编程类型和心态中所讨论的,很少有程序员对改变他们对类型的看法感兴趣

As I discussed in Programming types and mindsets, very few programmers are typically interested in having their opinion on typing changed.

大多数程序员发现自己在职业生涯的早期就被打字所深深吸引,然后把剩下的时间花在合理化自己和他人的正确选择上。

Most programmers find themselves drawn strongly to typing or not quite early in their career, and then spend the rest of it rationalizing The Correct Choice to themselves and others.

这就是JavaScript和TypeScript二分法的神奇之处,TypeScript团队意识到完全接管JavaScript是不可能的,所以完全的兼容性必须从一开始就考虑进去。

That's part of the magic of this JavaScript v TypeScript dichotomy, and full credit to the TypeScript gang for realizing that a full take-over of JavaScript was never going to happen, so complete compatibility had to be baked in from the start.

仅仅因为Turbo 8放弃了TypeScript并不意味着你不能用它来编写客户端代码,或者使用任何其他使用它的库

Just because Turbo 8 is dropping TypeScript won't mean you can't write your client code in it, or use any other library that employs it.

我们可以混合搭配,这很棒。

We get to mix and match, which is wonderful.

这也是必要的。

It's also necessary.

因为与Ruby等语言不同,Ruby是服务器端的众多可选语言之一,而JavaScript是客户端的一个必选语言。

Because unlike languages like Ruby, which are languages of choice when it comes to the server side, JavaScript is a language of necessity when it comes to the client side.

虽然您可以将方言编译到其中,但您仍然必须接受这样一个事实:在浏览器中运行代码意味着运行JavaScript。

While you may compile dialects into it, you still have to accept the fact that running code in the browser means running JavaScript.

因此,在这种情况下,能够在没有任何工具任何强类型情况下编写这样的代码是一种幸事

So being able to write that, free of any tooling, and free of any strong typing, is a blessing under the circumstances.

再见了,TypeScript。

So farewell, TypeScript.

愿你为你的同行带来更多的严谨满足,同时让我们其他人享受JavaScript最初设计光荣精神:没有强类型

May you bring much rigor and satisfaction to your tribe while letting the rest of us enjoy JavaScript in the glorious spirit it was originally designed: Free of strong typing.