为什么 javascript 是浏览器中实现的唯一客户端脚本语言? [英] Why is javascript the only client side scripting language implemented in browsers?

查看:25
本文介绍了为什么 javascript 是浏览器中实现的唯一客户端脚本语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么浏览器不添加对 Python 脚本的支持以替代 Javascript?或者更通用的脚本语言?Javascript 是唯一跨浏览器实现的,是否有原因?毕竟,脚本标签确实支持指定使用的脚本语言.

Why don't browsers add support for, say, Python scripting as an alternative to Javascript? Or more general purpose scripting languages? Is there a reason that Javascript is the only one implemented across browsers? After all, the script tag does have support to specify the scripting language used.

(我知道 IE 中有 VBScript 支持,但它似乎已经过时了.)

(I know there is VBScript support in IE, but it seems obsolete for all intents and purposes.)

推荐答案

好吧,Google 正试图通过 飞镖.社区还没有完全接受这个想法.要么.

Well, Google is trying to buck that trend with Dart. The community hasn't been entirely receptive to the idea; either.

Google 提议为 Webkit 添加多个 VM 支持效果不是很好.

Google proposed adding multiple VM support for Webkit which didn't go down very well.

一个特别的评论很好地总结了为什么会有一些阻力:

One particular comment summed it up nicely as to why there has been some resistance to that:

在这种情况下,该功能是向网络公开其他编程语言,除了当前最棒"的粉丝之外,对任何人都没有任何实际好处.语言(不久前可能是 Go,大约一年前这可能是 ruby​​,在 Python 之前,我记得不久前我也曾短暂地流行过 Haskell,Lua 一直处于边缘很长一段时间,在这种情况下,它是 Dart——谁能说 6 个月内不会有一种完全不同的语言流行?),但作为成本,它使网络碎片化并增加了大量额外的维护负担——只是维护v8 和 jsc 绑定不是微不足道的,它们用于相同的语言.

In this case the feature is exposing additional programming languages to the web, something without any real benefit to anyone other than fans of the current "most awesome" language (not too long ago that might have been Go, a year or so ago this would have been ruby, before than python, i recall i brief surge in haskell popularity not that long ago as well, Lua has been on the verges for a long time, in this case it's Dart -- who's to say there won't be a completely different language in vogue in 6 months?), but as a cost it fragments the web and adds a substantial additional maintenance burden -- just maintaining the v8 and jsc bindings isn't trivial and they're for the same language.

这里的问题不是我们可以在 webkit 中创建多个虚拟机吗";是我们可以向网络公开多种语言吗",对于前者,我说我们已经这样做了,对于后者,我说我们不想这样做.

The issue here isn't "can we make multiple vms live in webkit" it's "can we expose multiple languages to the web", to the former i say obviously as we already do, to the latter I say that we don't want to.

除非我们想把 webkit 变成每个人都讨厌的引擎,因为它的所有独特的功能"打破了开放的网络,就像 90 年代后期的某些浏览器.

Unless we want to turn webkit into the engine that everyone hates because of all its unique "features" that break the open web, a la certain browsers in the late 90s.

CoffeeScript 是新兴的客户端脚本语言的另一个例子.然而,它不是在浏览器中支持另一个虚拟机(就像 Google 试图用 Dart 做的那样),而是编译为 JavaScript.还有其他几种将 X 编译为 JavaScript"的方法.也这样做.emscripten 是将 LLVM 编译为 JavaScript 的一个很好的例子.

CoffeeScript is another example of an emerging client-side scripting language. However, rather than support another virtual machine in a browser (as Google is trying to do with Dart), it compiles to JavaScript. There are several other "compile X to JavaScript" that do that as well. emscripten is a good example of compiling LLVM to JavaScript.

所以还有很多其他的客户端语言;他们只是都使用 JavaScript 作为中间体.我认为 Dart 也应该这样做,尽管 他们还有一些改进的空间.

So there are plenty of other client languages; they just all use JavaScript as an intermediate. I'd argue that should be what Dart does as well, though they have some room to improve.

这篇关于为什么 javascript 是浏览器中实现的唯一客户端脚本语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆