Ask HN: SICP is often recommended as mind opener, what did you learn from it?
21–30 of 32 posts
Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#22Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#23But I had forgotten many of the details. Here is just one: in 3.1.1, Local State Variables, SICP shows how to, in effect, define classes and create objects using only function definition with lambda and set! (that is, assignment) in the definition body. The function you define this way is a like a class, the functions it returns are like instances. So you can do all this without any specifically object-oriented language features. This occupies just a few pages near the beginning of a long book - the whole book is dense with worked-out ideas like this.
I would add that the cumulative effect of all these examples in SICP is to demonstrate that you can solve any programming problem from first principles - that is, by combining a few simple but powerful constructs in the several ways they describe. Moreover, a solution constructed this way might be simpler and easier to understand than a solution made the more usual way: by looking for a specialized language construct or library that seems to offer an already-made solution to the problem.
(This is copied from a comment I made here several years ago: https://news.ycombinator.com/item?id=8495934)
Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#241. It taught me to think of programming languages as constructed things, rather than just being "there" and immutable. In particular, to think about the purpose of each language feature, and separating features into core primitives vs. syntactic sugar that could be reduced to those core primitives. It becomes harder to do this for "complicated" languages like C++ and Python, because many of their language features are not for one purpose but bundle together lots of disparate ideas. But it's still worth making the effort to see what choices the designers of those languages made, and how different choices would give you different points in the space of programming languages.
2. Once you have a small enough "core language", you can start thinking about algorithms that operate on programs. I had always thought of programs as expressing algorithms that operate on data, but didn't think of programs as data themselves. Of course every program is text, but in complicated languages with many constructs it seems horrendously hard to write programs that operate on other programs and change their meaning. But if your language desugars to a simple core language, the ability to transform programs opens the door to techniques like automatic differentiation of programs, probabilistic programming (like Church), and many others. These would now be called domain-specific languages, but those are often thought of as limited toys for very specific tasks. Instead, I like to think how every task has the "right" language to express it, and when you do API design you're really embedding a DSL in some "host language".
Since you asked, the other big development in my approach to programming came from learning Haskell and embracing types as an elegant way of expressing universal truths about programs. Sometimes the type of a function fully determines what the function can be, like how the only function of the type (forall a) a -> a is the identity function; this idea becomes more revelatory with more complicated types.
I don't use functional programming very much in my day-to-day life, but I think learning these ideas has shaped my approach to every language. It's not really about the superficial "functional patterns" that people often think of, like using map and filter and such, which is often idiomatically wrong in many other languages.
Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#25Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#26I don't think it "blew my mind" or opened up a new world to me though, but learning how to solve problems with basic tools was fun.
Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#27I didn't read the book, but I watched the recorded [lectures][1]. I got the sense that course was the tip of an iceberg of an entire academic discipline of programming philosophy and practical wisdom. On its face, though, it is an introduction to programming that starts with symbolic substitution, moves on to mutation and other tricks, and then I think gets into interpreter design. If you want your mind blown, read "…
Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#28I didn't study SICP directly, but took a course which was inspired by it. Perhaps the question needs the qualifier of whether you've encountered lisp before or not. > ... What did it do differently than other programming languages ... Ah. I don't think anyone would ask this if they knew lisp. At the very least, you can approach languages like JavaScript, C, C++, Python, (etc.) with broadly the same brush where you're…
s/lisp/Clojure/, I think.
Re: Ask HN: SICP is often recommended as mind opener, what did you learn from it?
#29SICP is a multi-layered, intensely philosophical book and philosophical truths are not transmitted like pieces of eight but are made real through praxis.