为什么使用原型继承实现JavaScript? [英] Why was JavaScript implemented using prototypal inheritance?

查看:126
本文介绍了为什么使用原型继承实现JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多文章和帖子解释了JavaScript继承是如何工作的,但为什么JavaScript使用原型继承而不是经典继承来实现?

There are lots of articles and posts explaining how JavaScript inheritance works, but why was JavaScript implemented using prototypal inheritance instead of classical inheritance?

我喜欢JavaScript,所以我我不是说这是件坏事......我只是好奇。

I love JavaScript, so I'm not saying it's bad thing... I'm just curious.

推荐答案

以下是Brendan Eich关于什么的说法发生了:
http://weblogs.mozillazine.org/roadmap /archives/2008/04/popularity.html

Here's what Brendan Eich has to say about what happened: http://weblogs.mozillazine.org/roadmap/archives/2008/04/popularity.html


正如我经常说的那样,和Netscape的其他人一样可以确认,我被招募到Netscape,承诺在浏览器中做一个方案。至少客户工程管理,包括Tom Paquin,Michael Toy和Rick Schell,以及一些名叫Marc Andreessen的人,确信Netscape应该以源代码形式嵌入HTML格式的编程语言。

As I've often said, and as others at Netscape can confirm, I was recruited to Netscape with the promise of "doing Scheme" in the browser. At least client engineering management including Tom Paquin, Michael Toy, and Rick Schell, along with some guy named Marc Andreessen, were convinced that Netscape should embed a programming language, in source form, in HTML.

来自高级工程管理层的diktat是该语言必须看起来像Java。这排除了Perl,Python和Tcl以及Scheme。

The diktat from upper engineering management was that the language must "look like Java". That ruled out Perl, Python, and Tcl, along with Scheme.

我并不自豪,但我很高兴我选择了Scheme-ish一流的功能和Self-ish(虽然是单数)原型作为主要成分。 Java影响,特别是y2k Date错误,但原始与对象的区别(例如,字符串与字符串)是不幸的。

I'm not proud, but I'm happy that I chose Scheme-ish first-class functions and Self-ish (albeit singular) prototypes as the main ingredients. The Java influences, especially y2k Date bugs but also the primitive vs. object distinction (e.g., string vs. String), were unfortunate.

这篇关于为什么使用原型继承实现JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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