面向对象程序员的方案 [英] scheme for object-oriented programmers

查看:84
本文介绍了面向对象程序员的方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Scheme完全感兴趣,并从一些玩具编程示例入手,并且正在阅读Paul Graham的在Lisp上.

I'm thoroughly intrigued by Scheme, and have started with some toy programming examples, and am reading through Paul Graham's On Lisp.

我找不到的一本书是一个旨在向"OO人"教授Scheme的书或网站,即像我这样的人,他们已经用c ++/Java/Python完成了99%的编码.

One thing I haven't been able to find is a book or website intended to teach Scheme to "OO people", i.e. people like myself who've done 99 % of their coding in c++/Java/Python.

我看到闭包在某种意义上是对象y,因为它们具有局部状态,并提供一个或多个可以访问该状态的函数.但是我不想学习Scheme只是为了将我现有的习惯移植到该方案上.这就是为什么我现在正在学习Scheme而不是Common Lisp的原因.我担心CLOS可能只是我现有的OO习惯的拐杖.

I see that closures are sort of object-y, in the sense that they have local state, and offer one or more functions that have access to that state. But I don't want to learn Scheme only to port my existing habits on to it. This is why I'm learning Scheme rather than Common Lisp at the moment; I fear that CLOS might just serve as a crutch to my existing OO habits.

理想的是一本书或网站,提供以OO语言以及以Schemey方式在Scheme中解决问题的案例研究.我想我将非常感谢科学计算和/或计算机图形学的问题,但是任何事情都会做.

What would be ideal is a book or website that offers case studies of problems solved in both an OO language, and also in Scheme in a Schemey way. I suppose I would most appreciate scientific computing and/or computer graphics problems, but anything would do.

任何教学线索都将不胜感激.

Any pedagogical leads would be much appreciated.

推荐答案

我怀疑CLOS是否会成为旧习惯的拐杖,我发现它与C ++/Java/Python中的OO风格完全不同,并且非常有趣.我不了解所有细节,但我会推荐彼得·塞贝尔(Peter Seibel)的《实践常见Lisp》.如果您在

  • Lisp上阅读没什么麻烦,那么您应该可以深入在PCL中介绍CLOS 的各章.另外,我建议他比较Java和Common Lisp的 Google技术讲座.

    I doubt CLOS would serve as a crutch for old habits, I found it to be pretty different from the OO style in C++/Java/Python, and very interesting. I don't understand all the details, but I would recommend Peter Seibel's Practical Common Lisp. If you are reading On Lisp without much trouble, you should be able to dive into the chapters introducing CLOS in PCL. Also, I'd recommend his Google Tech Talk comparing Java and Common Lisp.

    这里还有一些建议,可以使这个答案更加全面:

    Here's a few more recommendations to make this a more full-fledged answer:

    经典文字 计算机程序的结构和解释 涵盖了第3章中的许多示例使用闭包构建模块化系统的过程(并解决引入状态和可变性的问题).第2章包括一些通用的和数据/类型导向的编程,它们可能有助于激发CLOS的研究.虽然这本书确实不需要介绍,但它是一项高大的工作,而且自春天以来,我一直只是在慢慢地阅读它.如果您对Scheme感兴趣,强烈推荐.

    The classic text Structure and Interpretation of Computer Programs covers quite a few examples in chapter 3 of building modular systems using closures (and addresses issues with introducing state and mutability). Chapter 2 includes some generic and data/type-directed programming which could be helpful for motivating study of CLOS. This book really needs no introduction though, it's a towering work, and I've only been reading it slowly since the spring. Highly recommended if you are interested in Scheme.

    尽管SICP是一本很棒的书,但它并非没有缺陷:对这些文章的真正有趣的观察是文章详细阐述了对SICP的一些批评,由如何设计程序的作者撰写(我没有阅读HTDP,但听说效果很好).尽管本文不会专门教您寻找的内容-比较函数式编程和OO编程-但这确实很有趣.他们的新生本科课程从使用Scheme进行函数式编程的第一学期开始(我认为是PLT/Racket)开始,然后是使用C ++或Java进行OO编程的一学期……至少这是他们在本文中描述的课程.

    While SICP is a great book, it's not without its flaws: A really interesting look at these is the essay "The Structure and Interpretation of the Computer Science Curriculum" which elaborates on a few criticism of SICP, and is written by the authors of How to Design Programs (I haven't read HTDP but I hear it's very good). While this essay won't teach you specifically what you are looking for - comparing functional and OO programming - it is really interesting anyway. Their freshman undergraduate course starts with a first semester introduction to functional programming using Scheme (I think, PLT/Racket) and is followed by a semester of OO programming with C++ or Java... at least that's the course they describe in the essay.

    这些来自Peter Norvig的幻灯片介绍了OO编程中一些常见的设计模式,并说明了为什么它们在动态,功能性语言(例如Scheme和Lisp)中缺失或不必要:

    These slides from Peter Norvig address some of the design patterns common in OO programming and show why they are missing or unnecessary in dynamic, functional languages like Scheme and Lisp: http://norvig.com/design-patterns/

    谨慎推荐与Little Schemer图书相同作者的这本书: Java少,模式少.我不能肯定地说这是否是一本好书,这是令人难以置信的奇怪,并且有一些非常糟糕的排版决定(斜体,衬线,可变宽度,上标不属于编程文本) ,但是看一下可能会很有趣.无论如何,您可能会发现它很便宜.不要认真对待此建议.我认为最好坚持使用计划文本.

    I cautiously recommend the book by the same authors as the Little Schemer books: A Little Java, A Few Patterns. I can't say for sure if this is a really a good book or not, it was incredibly strange and there are some really bad typesetting decisions (italic, serif, variable-width, superscript doesn't belong in a text on programming), but it might be interesting to take a look at. You can probably find it cheap, anyway. Don't take this recommendation that seriously. I think it would be better to stick to the Scheme texts.

    p.s.我必须不同意一条评论,即函数式编程在面向对象编程中并不那么复杂,我认为这完全是错误的.函数式编程的所有方面确实令人难以置信.当您不仅仅使用map/filter/reduce和一流的功能,并查看功能领域中的其他内容,例如惰性评估,避免副作用和变异以及强大的静态类型语言时,它会变得非常有趣,并且肯定和传统 OO编程一样复杂.我自己只是从头开始,但发现了很多新想法.编程是复杂的业务,无论是面向对象还是功能.

    p.s. I have to disagree with one comment stating that functional programming is not as complicated at OO programming, I think that's grossly misstating it. Functional programming in all its breadth is truly mind-boggling. When you go beyond map/filter/reduce and first-class functions, and take a look at other things in the functional realm like lazy evaluation, avoiding side effects and mutation, and the strong, static-typed languages, it gets pretty interesting, and is certainly just as complicated as traditional OO programming. I've only just scratched the surface myself but have discovered a great deal of new ideas. Programming is complicated business, whether OO or functional.

    这篇关于面向对象程序员的方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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