淘客熙熙

主题:计算机编程的经典SICP -- 南山东沟

共:💬13 🌺64 新:
分页树展主题 · 全看
  • 家园 计算机编程的经典SICP

    最近Deep Learning 很火。而Deep Learning 最重要的算法 Backpropagation 需要能自动求微分。实际上,Symbolic Differentiation这个问题几十年前在SICP中就有涉及了。SICP (Structure and Interpretation of Computer Programs) 算是计算机编程的经典著作了, 很值得一读,写法与一般的教材明显不同。

    https://mitpress.mit.edu/sites/default/files/sicp/full-text/sicp/book/book.html

    1986 录像是由SICP的两位作者授课, 很值得一看。

    https://www.youtube.com/watch?v=2Op3QLzMgSY&list=PLB63C06FAF154F047

    练习可以用Chez Scheme(王垠大力推荐)。据说是世界上速度最快的 Scheme. 最近被CISCO 买了,现在开源了。

    https://cisco.github.io/ChezScheme/

    通宝推:独草,学菩提,南宫长万,杨微粒,ton,
    • 家园 计算机语言我是外行,请教一下

      我对计算机语言的理解就是汇编,C语言,Basic,后来的VB,再后来的Python。

      我的理解不同计算机语言就是命令方式有不同,对变量类型的定义有不同,输入输出方式有点不一样,可能编程方便一点,运算效率高一点,其他的基本一样。

      这些语言没有认真学过,也不觉得有本质的区别,都是工作中要用到,临时抽几天学习,边学边写程序。等我学好了,一般项目也结束了,然后这门语言就被直至脑海直到忘记。

      前几天想起一个电路结构,可以模拟人脑的思考和记忆过程,正在寻找一个工具来仿真。现成的仿真程序肯定没有,不知道您的这个SICP有什么特殊的地方,需要的话我可以现学。

      多谢指点,预先致谢!

      • 家园 ❗️🤣 ❗️

        点看全图

        陈王:我帮你找了好几天,从剑桥到普林斯顿⋯甚至莫斯科大学也去了,其中的艰辛历程很难表述与你。遗憾的是你需要的仿真工具一个没发现,但却发现了已经存在了模似人脑思考和记忆的仿真程序。很短很好玩,如果您需要interface , 打个招呼。什么?我哪儿?噢,我音乐学院就读,搞雕塑的。

      • 家园 如果只是入门的话

        过程式语言建议用python,函数式语言建议用Ocaml。

      • 家园 大部分编程语言都是定义计算过程

        所以只要会了一种,学新的就很容易。包括面向对象的编程,不过是换一种形式组织数据和计算过程。

        但是LISP/Scheme 是个特例。很多用C/C++/Java/Basic 很难实现的东西,比如自动微分,用Scheme 就容易多了。我的感觉主要是因为LISP/Scheme 可以动态产生代码,因为它本身就不区分数据和代码(都是LIST)。而一般的编程语言,代码编译后就不能变了,只有数据能变。

        SICP 这个视频讲到了电路模拟,不知道是否对您有帮助

        https://www.youtube.com/watch?v=yedzRWhi-9E&list=PLE18841CABEA24090&index=10

      • 家园 另外,Lisp还是Emacs的脚本语言

        另外,Lisp还是Emacs的脚本语言。Emacs的生父Richard Stallman在他的网站上是这样吹Lisp的:

        The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages.

        Unlike most languages today, which are focused on defining specialized data types, Lisp provides a few data types which are general. Instead of defining specific types, you build structures from these types. Thus, rather than offering a way to define a list-of-this type and a list-of-that type, Lisp has one type of lists which can hold any sort of data.

        Where other languages allow you to define a function to search a list-of-this, and sometimes a way to define a generic list-search function that you can instantiate for list-of-this, Lisp makes it easy to write a function that will search any list — and provides a range of such functions.

        In addition, functions and expressions in Lisp are represented as data in a way that makes it easy to operate on them.

        When you start a Lisp system, it enters a read-eval-print loop. Most other languages have nothing comparable to `read', nothing comparable to `eval', and nothing comparable to `print'. What gaping deficiencies!

        While I love the power of Lisp, I am not a devotee of functional programming. I see nothing bad about side effects and I do not make efforts to avoid them unless there is a practical reason. There is code that is natural to write in a functional way, and code that is more natural with side effects, and I do not campaign about the question. I limit my campaigning to issues of freedom and justice, such as to eliminate nonfree software from the world.

        Lisp is no harder to understand than other languages. So if you have never learned to program, and you want to start, start with Lisp. If you learn to edit with Emacs, you can learn Lisp by writing editing commands for Emacs. You can use the Introduction to Programming in Emacs Lisp to learn with: it is free as in freedom, and you can order printed copies from the FSF.

        You can learn Scheme (and a lot of deep ideas about programming) from Structure and Interpretation of Computer Programs by Abelson and Sussman. That book is now free/libre although the printed copies do not say so.

        How I do my computing

      • 家园 在Lisp中,函数是一等公民

        既然参数可以是函数指针,返回值同样也可以是函数指针,因此可以有func()();这样的调用。返回函数的函数在C语言中很少见,在一些函数式编程语言(例如LISP)中则很常见,基本思想是把函数也当作一种数据来操作,输入、输出和参与运算,操作函数的函数称为高阶函数(High-order Function)。

        回调函数

        C语言之类的贴近机器的语言中往往有函数和运算符的区别,表达式中还有什么运算符优先级。但是Lisp中这些都是函数,加法是加法函数,减法是减法函数。当b大于0的时候,

        (if (> b 0) + -)的返回值就是加法函数+,反过来b小于等于0的时候,(if (> b 0) + -)的返回值就是加法函数-。

        于是((if (> b 0) + -) a b)在b大于0的时候,就是a和b的和(+ a b);在b小于等于0的时候,就是a减去b(- a b);这样就可以实现一个a+b的绝对值的函数

        (define (a-plus-abs-b a b)

        ((if (> b 0) + -) a b))

        【声明函数a-plus-abs-b,具有a和b两个参数,返回值是((if (> b 0) + -) a b)】

      • 家园 陈王兄好,我也是外行

        我看过SICP书的第一章。

        计算机语言的入门教学其实用两种语言最合适。

        一种是面向机器的,比如Fortran和C;典型教材是Linux C编程一站式学习,介绍C,顺带体系结构,汇编入门等。

        另一种是面向数学的,比如Common Lisp和Scheme;典型教材就是SICP,第一章就是构造函数抽象。然后我发现原来写程序还能这样思考www

        我SICP第一章的习题解:

        https://github.com/yx-wh/practice/tree/master/scheme

        我使用的解释器是racket

      • 家园 对计算机语言来说

        你尚处于咿呀学语阶段,人家谈论的是如何妙笔生花

分页树展主题 · 全看


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河