当您阅读 SICP 时,哪些概念令您感到惊讶?

发布于 2024-07-10 05:47:45 字数 82 浏览 4 评论 0原文

SICP -“计算机程序的结构和解释”

对此的解释会很好

有人可以解释一下元语言抽象

SICP - "Structure and Interpretation of Computer Programs"

Explanation for the same would be nice

Can some one explain about Metalinguistic Abstraction

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

童话 2024-07-17 05:47:45

SICP 确实让我们明白了这样一个观点:可以将代码和数据视为同一事物。

我之前在考虑通用图灵机(UTM 的输入只是程序的表示)或冯诺依曼架构(其中单个存储结构同时保存代码和数据)时就理解了这一点,但 SICP 使这个想法更加清晰。 方案 (Lisp) 在这里有所帮助,因为程序的语法与一般列表的语法(即 S 表达式)完全相同。

一旦你有了代码和数据的“等价性”,突然间很多事情就变得容易了。 例如,您可以编写具有不同评估方法(惰性、不确定性等)的程序。 以前,我可能认为这需要对编程语言进行扩展;现在看来,这需要对编程语言进行扩展。 实际上,我可以自己将其添加到语言中,从而使核心语言最小化。 另一个例子,你可以类似地实现一个面向对象的框架; 再说一次,我可能天真地认为这需要修改语言。

顺便说一句,我希望 SICP 多提及一件事:类型。 编译时进行类型检查是一件了不起的事情。 面向对象编程的 SICP 实现没有这个好处。

SICP really drove home the point that it is possible to look at code and data as the same thing.

I understood this before when thinking about universal Turing machines (the input to a UTM is just a representation of a program) or the von Neumann architecture (where a single storage structure holds both code and data), but SICP made the idea much more clear. Scheme (Lisp) helped here, as the syntax for a program is exactly the same as the syntax for lists in general, namely S-expressions.

Once you have the "equivalence" of code and data, suddenly a lot of things become easy. For example, you can write programs that have different evaluation methods (lazy, nondeterministic, etc). Previously, I might have thought that this would require an extension to the programming language; in reality, I can just add it on to the language myself, thus allowing the core language to be minimal. As another example, you can similarly implement an object-oriented framework; again, this is something I might have naively thought would require modifying the language.

Incidentally, one thing I wish SICP had mentioned more: types. Type checking at compilation time is an amazing thing. The SICP implementation of object-oriented programming did not have this benefit.

蒗幽 2024-07-17 05:47:45

我还没读过那本书,我只看了视频课程,但它教会了我很多东西。 作为一等公民的职能对我来说是令人兴奋的。 执行“变量”对我来说是非常新鲜的事情。 观看这些视频后,我现在看待 JavaScript 和编程的方式发生了很大变化。

哦,我想我撒谎了,真正让我震惊的是 + 是一个函数。

I didn't read that book yet, I have only looked at the video courses, but it taught me a lot. Functions as first class citizens was mind blowing for me. Executing a "variable" was something very new to me. After watching those videos the way I now see JavaScript and programming in general has greatly changed.

Oh, I think I've lied, the thing that really struck me was that + was a function.

虚拟世界 2024-07-17 05:47:45

我认为关于 SICP 最令人惊讶的事情是看到创建图灵完备语言实际上只需要很少的原语——几乎任何东西都可以从无到有构建。

由于我们正在讨论 SICP,我将在 http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/,这是您希望在 20 小时内获得的最好的计算机科学入门课程。

I think the most surprising thing about SICP is to see how few primitives are actually required to make a Turing complete language--almost anything can be built from almost nothing.

Since we are discussing SICP, I'll put in my standard plug for the video lectures at http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/, which are the best Introduction to Computer Science you could hope to get in 20 hours.

楠木可依 2024-07-17 05:47:45

我认为非常酷的是 具有延迟评估的流。 我认为关于生成素数的一件事非常巧妙。 就像“PEZ”分配器一样,可以神奇地分配序列中的下一个素数。

The one that I thought was really cool was streams with delayed evaluation. The one about generating primes was something I thought was really neat. Like a "PEZ" dispenser that magically dispenses the next prime in the sequence.

沙与沫 2024-07-17 05:47:45

A. Rex 的回答中的一个“数据和代码是同一件事”的例子让我深受启发。

当我在俄罗斯学 Lisp 时,我们的老师告诉我们,这种语言是关于列表的:car、cdr、cons。 真正令我惊讶的是,您根本不需要这些函数 - 您可以编写自己的给定闭包。 所以,Lisp 终究不是关于列表的! 这是一个很大的惊喜。

One example of "the data and the code are the same thing" from A. Rex's answer got me in a very deep way.

When I was taught Lisp back in Russia, our teachers told us that the language was about lists: car, cdr, cons. What really amazed me was the fact that you don't need those functions at all - you can write your own, given closures. So, Lisp is not about lists after all! That was a big surprise.

烟酉 2024-07-17 05:47:45

我完全不熟悉的一个概念是协程的想法,即让两个函数做互补的工作并使程序流程控制在它们之间交替。

A concept I was completely unfamiliar with was the idea of coroutines, i.e. having two functions doing complementary work and having the program flow control alternate between them.

别想她 2024-07-17 05:47:45

我读SICP的时候还在读高中,主要关注的是第一章和第二章。 对于当时的我来说,我喜欢用代码表达所有这些数学思想,并让计算机完成大部分脏活。

当我辅导SICP时,我对不同的方面印象深刻。 其一,数据和代码实际上是同一件事的难题,因为代码是可执行数据。 关于元语言抽象的章节对许多人来说是令人难以置信的,并且有许多重要的信息。 首先,所有规则都是任意的。 这让一些学生感到困扰,特别是那些本质上是物理学家的学生。 我认为美妙之处不在于规则本身,而在于研究规则的后果。 代码中的一行更改可能意味着词法作用域和动态作用域之间的差异。

如今,尽管 SICP 对许多人来说仍然很有趣且富有洞察力,但我确实知道它正在变得过时。 其一,它不教授调试技能和工具(我在其中包含类型系统),而这对于当今庞大的系统中的工作至关重要。

I was still in high school when I read SICP, and I had focused on the first and second chapters. For me at the time, I liked that you could express all those mathematical ideas in code, and have the computer do most of the dirty work.

When I was tutoring SICP, I got impressed by different aspects. For one, the conundrum that data and code are really the same thing, because code is executable data. The chapter on metalinguistic abstractions is mind-boggling to many and has many take-home messages. The first is that all the rules are arbitrary. This bothers some students, specially those who are physicists at heart. I think the beauty is not in the rules themselves, but in studying the consequence of the rules. A one-line change in code can mean the difference between lexical scoping and dynamic scoping.

Today, though SICP is still fun and insightful to many, I do understand that it's becoming dated. For one, it doesn't teach debugging skills and tools (I include type systems in there), which is essential for working in today's gigantic systems.

‖放下 2024-07-17 05:47:45

最让我惊讶的是实现语言是多么容易。 那个人可以在黑板上写下Scheme的解释器。

I was most surprised of how easy it is to implement languages. That one could write interpreter for Scheme onto a blackboard.

沫尐诺 2024-07-17 05:47:45

读了SICP的一些章节后,我感受到了不同意义上的递归

I felt Recursion in different sense after reading some of the chapters of SICP

左耳近心 2024-07-17 05:47:45

我现在正在阅读“作为常规接口的序列”部分,并且发现作为一等公民的过程的概念非常令人着迷。 另外,递归的应用是我在任何语言中从未见过的。

I am right now on Section "Sequences as Conventional Interfaces" and have found the concept of procedures as first class citizens quite fascinating. Also, the application of recursion is something I have never seen in any language.

水染的天色ゝ 2024-07-17 05:47:45

关闭。

来自主要命令式背景(Java、C# 等——我大约一年前才第一次阅读 SICP,现在正在重新阅读),从函数角度思考对我来说是一个很大的启示; 它完全改变了我今天对工作的看法。

Closures.

Coming from a primarily imperative background (Java, C#, etc. -- I only read SICP a year or so ago for the first time, and am re-reading it now), thinking in functional terms was a big revelation for me; it totally changed the way I think about my work today.

荭秂 2024-07-17 05:47:45

我读了这本书的大部分内容(没有练习)。 我学到的是如何在特定层面上抽象现实世界,以及如何实现一种语言。

每一章都有让我惊讶的想法:

前两章向我展示了两种抽象现实世界的方法:用过程抽象和用数据抽象。

第3章介绍现实世界中的时间。 这导致了国家的结果。 我们尝试分配,这会引发问题。 然后我们尝试流。

第四章是关于元语言抽象,换句话说,我们通过构造一个评估器来实现一种新的语言,评估器确定表达式的含义。

由于第 4 章中的评估器本身就是一个 Lisp 程序,因此它继承了底层 Lisp 系统的控制结构。 因此,在第 5 章中,我们将在抽象模型(寄存器机)的帮助下深入了解真实计算机的逐步操作。

谢谢。

I read most part of the book (without exercise). What I have learned is how to abstract the real world at a specific level, and how to implement a language.

Each chapter has ideas surprise me:

The first two chapters show me two ways of abstracting the real world: abstraction with the procedure, and abstraction with data.

Chapter 3 introduces time in the real world. That results in states. We try assignment, which raises problems. Then we try streams.

Chapter 4 is about metalinguistic abstraction, in other words, we implement a new language by constructing an evaluator, which determines the meaning of expressions.

Since the evaluator in Chapter 4 is itself a Lisp program, it inherits the control structure of the underlying Lisp system. So in Chapter 5, we dive into the step-by-step operation of a real computer with the help of an abstract model, register machine.

Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文