除了第一类函数和词法作用域之外,JavaScript 与Scheme 实现还有什么共同之处?
我一直想知道为什么 Douglas Crockford 不断将 JavaScript 与Scheme 进行比较。是的,JS 的设计者本来打算将其设计为Scheme;但是,除了一流的函数支持和词法作用域(已损坏)之外,JS 与Scheme 有何共同点,使其成为“披着C 外衣的Lisp”?
I have always wondered why Douglas Crockford keeps comparing JavaScript to Scheme. Yes JS was intended to be Scheme by its designer; but besides the first class function support and the lexical scoping (broken), what features does JS have in common with Scheme that makes it "Lisp in C's Clothing"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我想到的另一件事是在整个语言和库中普遍使用单一普遍存在的数据结构:在Scheme的情况下,cons列表,映射(称为 >objects)(对于 ECMAScript)。
不仅如此,ECMAScript 拥有一流的过程,而且这些过程是唯一的抽象机制。 (或者更准确地说封装机制。)
Another thing that comes to mind is the pervasive use of a single ubiquitous data structure throughout the language and the libraries: cons lists in the case of Scheme, maps (called objects) in the case of ECMAScript.
Then there is not just the fact that ECMAScript has first-class procedures, but that those procedures are the only abstraction mechanism. (Or more precisely encapsulation mechanism.)
在此列表中最重要的一件事就是拥有 REPL。看起来像是一个技术问题,特别是当这些 repl 通常隐藏在一些“开发人员工具”后面时,但它对语言有巨大的影响。 (例如,当有 repl 时,很自然地有一个真正的
eval
等。)它基本上使代码的动态评估具有一流的地位,这对于像 JS 这样的东西非常有用,并且可能具有它的成功比一流函数(直到几年前才真正被使用)做出了更大的贡献。One thing that should be high on this list is having a REPL. Seems like a technicality, especially when these repls are usually hidden behind some "developer tools" thing, but it has a huge effect on the language. (For example, it's natural to have a real
eval
when there's a repl, etc.) It basically puts dynamic evaluation of code have first class status, which is extremely useful for something like JS, and probably has contributed much more to its success than first class functions (which really were hardly used until a few years ago).从我的脑海中浮现出来,再加上浏览维基百科:
Off the top of my head, plus glancing at Wikipedia:
好吧,JavaScript 缺乏同像性,并且这是 Lisp 方言的主要属性之一。
Well, JavaScript lacks homoiconicity, and this is one of the main properties of Lisp dialects.