JavaScript是Web汇编语言,没关系。

Some years ago I said that JavaScript is the Assembly Language of the Web. In fact, lots of people said it, because it's true. Later, some folks disagreed, saying that this is an inaccurate analogy. Of course, it is inaccurate because it's an analogy. That said, as analogies go, it's pretty good. Sure, assemblers are architecture and processor specific. Maybe "JavaScript is the Web's Bytecode" is better. At the very least, JavaScript is a totally reasonable compile target.

几年前,我说过JavaScript是Web的汇编语言。 实际上,很多人都这么说,因为这是真的。 后来,有些人不同意,说这是一个不准确的类比。 当然,这是不准确的,因为这是一个类比。 也就是说,按照类推,它还不错。 当然,汇编程序是特定于体系结构和处理器的。 也许“ JavaScript是Web的字节码”更好。 至少, JavaScript是一个完全合理的编译目标

Given that (using Wikipedia as a dictionary here and has a decent definition:

鉴于此(此处使用Wikipedia作为字典,并具有不错的定义:

An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong correspondence between the language and the architecture's machine code instructions.

汇编语言是计算机或其他可编程设备的低级编程语言,在该语言中,汇编语言与体系结构的机器代码指令之间存在非常强的对应关系。

It's initially not clear that JavaScript is a good assembly language as it's a high-level programming language that is itself interpreted, then JIT-ted, then turned into machine instructions. Phrased differently, JavaScript floats pretty high in the stack. Certainly every processor has its own assembler and they are very specific, but the browser's JavaScript VM is what runs the "new machine code." There's only one processor architecture. The Web. (again, analogy!)

最初尚不清楚JavaScript是一种好的汇编语言,因为它是一种高级编程语言,其本身会先进行解释,然后进行JIT处理,然后转变为机器指令。 换句话说,JavaScript在堆栈中的浮动很高。 当然,每个处理器都有自己的汇编器,并且它们是非常特定的,但是浏览器JavaScript VM是运行“新机器代码”的文件。 只有一种处理器架构。 网络。 (再次类推!)

JavaScript remains a popular transpilation/compilation target. From Google's GWT to Clojure to TypeScript to CoffeeScript, it all stops at JavaScript because JavaScript is the ubiquitous virtual machine that we already have installed on our machines.

JavaScript仍然是流行的转换/编译目标。 从Google的GWT到Clojure到TypeScript到CoffeeScript,所有这些都停止在JavaScript上,因为JavaScript是我们已经在计算机上安装的无处不在的虚拟机

Google Native Client (NaCl) is great and will likely have a role to play, but there's only one language that works everywhere without installation or trouble and that's JavaScript.

Google Native Client (NaCl)很棒,可能会扮演一定的角色,但是只有一种语言可以在任何地方正常工作,而不会造成安装或麻烦,而这就是JavaScript。

We don't all have x86 machines. We don't have have machines that we could feed assembler or C. Certainly not in a portable way. JavaScript is the great portable equalizer.

我们并不都拥有x86机器。 我们没有可用于汇编程序或C的机器。当然不是便携式的。 JavaScript是出色的可移植均衡器。

There's languages that transform to JavaScript like TypeScript and CoffeeScript and HAXE and so many more, but many of these are arguably transformations, not compilations. They also tend to compile to lots of different kinds of JavaScript.

还有那个变换为JavaScript像打字稿和CoffeeScript的和HAXE和语言的那么多,但其中许多,可以说是变革,而不是编辑。 它们还倾向于编译为许多不同种类JavaScript。

Enter asm.js. Why not take the sprawling language that is JavaScript and pick just the subset that one would want if one were to compile something to it? Why not take the assembly-esque parts of JavaScript and formalize it? Mozilla is doing this with the clear goal to compile things to JavaScript and make it perform well. Their FAQ says they're seeing slowdowns around a factor of two, which is amazing, in case you're wondering. It's also worth noting that I, as a user, don't care if you compile your C to JavaScript. I just want a great experience on the open web, and that's another reason that targeting JavaScript moves the web forward.

输入asm.js。 为什么不采用JavaScript之类的庞大语言,而只选择一个人想要编译的子集呢? 为什么不采用JavaScript的汇编式部分并将其形式化? Mozilla这样做的明确目标是将内容编译为JavaScript并使其表现良好。 他们的常见问题解答说,他们看到速度下降了两倍左右,如果您想知道的话,这是惊人的。 还值得注意的是,作为用户,我不在乎是否将C编译为JavaScript。 我只想在开放的Web上有一个很好的体验,这是针对JavaScript推动网络向前发展的另一个原因。

Working in tandem, there's emscripten, a LLVM bitcode to JavaScript compiler. We can take C/C++ and compile it to JavaScript. Don't buy it? They ported Unreal Engine 3 in 4 days with asm.js as the target.

协同工作,有emscripten ,即JavaScript编译器的LLVM位代码。 我们可以使用C / C ++并将其编译为JavaScript。 不买吗? 他们在4天内以asm.js为目标移植了虚幻引擎3

You can argue that JavaScript isn't the x86 or Assembly of the web. You can argue all you want. It's still happening.

您可以说JavaScript不是x86或Web的汇编。 您可以争论所有您想要的。 它仍在发生。

As our great philosopher Kosh from Babylon 5 once said: "The avalanche has already started. It is too late for the pebbles to vote."

正如巴比伦五世的伟大哲学家科什(Kosh)曾经说过的那样:“雪崩已经开始了。卵石投票还为时已晚。”

The avalanche has already started. It is too late for the pebbles to vote.

It's not clear that JavaScript is the end state. In fact, if anything it's clear there is no end state. But along the way we will - actually are - passing though the JavaScript as Assembler part of the trip.

尚不清楚JavaScript是否为最终状态。 实际上,很明显,没有结束状态。 但是,一路走来,我们实际上通过JavaScript作为汇编程序的一部分。

Sponsor: Big thanks to SoftFluent for sponsoring the feed this week! Less Plumbing, More Productivity! Generate rock-solid foundations for your .NET applications from Visual Studio and focus on what matters!

赞助商:非常感谢SoftFluent本周赞助了feed! 减少管道,提高生产率! 从Visual Studio为您的.NET应用程序打下坚实的基础,并专注于重要事项!

翻译自: https://www.hanselman.com/blog/javascript-is-web-assembly-language-and-thats-ok

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值