Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Interactive SICP (xuanji.appspot.com)
280 points by zodiac on Dec 2, 2012 | hide | past | favorite | 51 comments



Hello everyone, OP here. This is my first Show HN post.

I guess most of you should know what SICP is. I took a class where it was used as a textbook (only the first 3 chapters, unfortunately) and loved it.

Most of the syntax-highlighted code fragments can be clicked on and edited. Either click somewhere else after that or press ctrl-enter to re-evaluate the scheme code. There are also some auto-graded exercises which involve writing code, as well as some multiple-choice questions (inspired by coursera)

So far only the first section is up. I don't think I can finish converting the whole of SICP to this format, so any help is much appreciated! I've tried to make the API as short as I can, but still able to run arbitrary code (eg for auto-graders). The main code is in isicp/coding.js and the content is stored in chapter-specific html files. All this is done via client-side javascript. I used biwascheme for the scheme interpreter and codemirror for the editor.


Open to suggestions? Since we're using Scheme, it would be nice to have the hierarchy of parentheses rainbow-highlighted when you hover an expression with the mouse, much like what is done at http://wiki.call-cc.org/chicken-for-php-programmers


Very nice! I sent this to Abelson and Sussman and they both loved it. I know the idea of an "intelligent book" has long been a dream of theirs.

If you find yourself in Boston, you can certainly visit CSAIL and chat with them if you want.


I think there's a typo in example 1.5: "In normal-order evaluation, (p) is not evaluated because predicate of if evaluates to false". The 'false' should be 'true'.


A great initiative. I hope you manage to finish it.

I hope people extend the same treatment to non-lisp canonical texts.


One reason it was possible to choose SICP was the license (Creative Commons), which I think is pretty rare for a text of this quality. If I could I'd do the same for K&R.


Great job, over the past week i have been doing an interactive implementation of SICP picture language, and have a working prototype to play around, check it out here: http://rquintas.net/picture-language/


SICP is an advanced text, and using it to teach amateurs how to program is, probably, a mistake.

Brian Harvey have done a great job to simplify and make it more freshman-friendly. I think his CS61A is the best intro course available (but I don't think that the sentence ADT is a such great idea, and it make things little messier, not more clear).

The HtDP2 approach is also remarkable, but problem is it is part of Racket promotion (word dr.racket is used hundred times in the first chapter). The idea to make changes in a program visible, via using graphical primitive functions is brilliant, but controversial one - it is too soon (but it kicks and makes a progress visible)

I think that functions with multiple arguments, first-class "citizens" (values has a type, everything is a pointer), pairs, lists, then generic functions and environments must be taught first, and visualized interactively, similar to that python tool. Then, after, you can teach parts from HtDP and then SICP.

People who really enjoyed this initiation will go through whole books themselves.)


I can't say how "amateurs" maps to MIT freshmen, but I wanted to point out that back in the day SICP was used, in its entirety, in 6.001, the one-semester entry-level computer science course at MIT.


That is true. People who were able to find their way to MIT is by no means "amateurs".

The rest of us, however, might find it overwhelming, due to lack of appropriate habits and training.


I'm currently doing SICP with Harvey and to be honest after list and cons in general are introduced I wish the course would abandon sentences altogether.


I agree. I'm doing the same course and because I couldn't get their implementation of Scheme(ucb-scheme) to work, I'm really out-of-sync with the course.

I'm doing the examples and exercises in Racket.


Are you taking 61as, the self-paced version? I was under the impression they were either already using, or planning to switch to, a JavaScript Scheme implementation to ease just this sort of problem.

I know one of he people who is running 61as, and I believe he wants to move as much as possible into the browser. In fact, they might even use a JavaScript-based Emacs clone instead of Emacs proper next time.

I think using the browser should make setting up the environment much easier than using some old, unsupported Scheme implementation!


No, I'm watching the 61A videos on Youtube.

I'll need to check out the Javascript based implementation sometime. But it is really annoying that the course is using something that hasn't been updated in ages.


I'm in AS. We aren't using a js interpreter and actually I haven't seen them mention such a switch much. That's news to me.


In that case, I think that's what they're going to be working on over winter break for the next iteration of the class. At the very least, I'm sure it's a possiblity; there's obviously no guarantee that it is practical or will get done.

I think it's a good idea, personally. It could also make many of the assignments more interactive.


Are you having trouble because you're running a different platform that they developed their implementation on?

If so my way of dealing with this when I'm too lazy to deal with trying to get stuff to work on another system, is to using something like Virtual Box and work on the exact OS the library/language I want to work with was made for.


No, I'm using Linux(Arch) so I guess I am on an intended platform. It is on the user contributed repos but the installation didn't work. I tried installing just stk-scheme too but that didn't work either.


Can you try stk-simply?


Agreed. It's still just a mild annoyance overall, but one that hits early on.


SICP was the text for first-year intro computer science at Chicago when I was there. I don't think it's too much to ask of motivated amateurs.


I've done some of the picture exercises from Concrete Abstractions. They were quite fun but significantly harder than assignments which didn't tax my spatial perception skills.

I just checked, MIT holds the copyright for HtDP, so an interactive version like this isn't possible.


> MIT holds the copyright for HtDP, so an interactive version like this isn't possible.

A person could ask. Sometimes these things are done reflexively and a simple query will get a pleasant response.


The site doesn't seem to need a server to function - so it would be awesome if you could add a cache manifest to make it available offline:

http://www.html5rocks.com/en/tutorials/appcache/beginner/


Good initiative. I wish it was done in clojure/clojurescript, would have been great. But still its a nice way to learn. One suggestion. Add paredit mode to balance the parens. Without paredit mode one has to worry about balancing the parens and its a painful experience. It's like coding in notepad. Looks great! Looking forward to more chapters :)


I can't imagine a Clojure SICP really working. The whole idea of SICP is to take a super-simple language and learn to build your own data-structure, psuedo-languages, and clarify how expressions, structures, etc. we use everyday are used, created, and implemented.

I really wish people wouldn't look at Clojure and think that it is the same as Scheme, especially the flavor presented in SICP, because it isn't. They're two entirely different languages and conflating the two as the same because OMG Parenthesis is like saying Python and Ruby are the same because they are categorized as scripting languages.

Clojure and Scheme attempt to solve very different issues. Scheme does a wonderful job in the sphere allocated in SICP. SICP could theoretically be taught with Clojure, but one must wonder why it hasn't been fully attempted yet. I think that once you try out Clojure, you would see the glove doesn't fit very well, so to speak. The main issue is that SICP is extremely fast and ideally, you'd want a language that takes a day to sort of learn and understand. Clojure certainly does not have this advantage. Clojure has many built-in structures. If you did do SICP in Clojure, you'd effectively be using a Scheme without cons, car, and cdr and using a Clojure without map, filter, etc etc etc. What's the point of that?


Yeah, I do agree that the simplicity of scheme helps. It really is a good teaching language. That said, courses are starting to adapt SICP to different languages (MIT and UCB use python, while my own university, NUS, uses javascript: http://www.comp.nus.edu.sg/~cs1101s/ - there's an interactive SICP in javascript there, too)

I think a clojure interactive textbook of this sort would have to be targeted at the kind of programmer wishing to learn clojure - ie it would assume some prerequisites and discuss features specific to clojure. It seems to me to be a shame to strip clojure down to a very small scheme-like language and then teach that.


I was actually thinking of the whole web app being written in clojure/clojurescript actually. And not teaching SICP via clojure.


Oh. Well both biwascheme and codemirror use javascript, and the amount of glue code I have to write isn't that much, so I'm not sure the benefits of clojurescript would outweigh that of being able to talk to these libraries directly.


Sorry for repeating myself, but I really need contributors for this - I can't finish it just working on my own on weekends.


Hey,

I thought about doing this 3 or 4 days ago (eerily similar -- I had even decided on Biwa Scheme as well). To avoid duplication of effort, I would rather contribute to your iSICP than start my own.

Drop me a line at me@f.rancis.co


SICP - Structure And Interpretation Of Computer Programs

Is an MIT computer science textbook.

http://mitpress.mit.edu/books/structure-and-interpretation-c...


Looks awesome. I think exercise 1.2 is broken. I enter in:

(/ (+ 5 (+ 4 (- 2 (- 3 (+ 6 (/ 4 5)))))) (* 3 (* (- 6 2) (- 2 7))))

and it tells me the result is wrong, but wolfram and my own REPL confirms the result.


The autograder checks for (+ 5 4 (- 2 ...)), instead of nesting the additions. You can view the source to see the grader. I'm not sure how to make it accomodate all the ways it could be nested though.


Why not check the result and also check for the presence of parentheses? That way you can verify the result and make sure nobody's just copying and pasting in an answer.

One could easily do something like (-2.466..) as the answer, but given that you just need a simple way to verify answers, I think my strategy works well.


I think you could get away with not even checking for parens, if you go with the idea that people doing it properly won't try to cheat it (because they'll learn nothing).

For people who do want to 'cheat', the grade is meaningless anyway.


I thought about that, but my reasoning for checking parens is that there's a decent subset of people who might get stuck and just google an answer, but if it gets rejected, then they'll put more time into figuring out the correct answer.

I guess I'm trying to view it from the POV of a beginner, as most CS people/programmers can work through this without needing the website.


Normalize it and then check if it is equal; this took longer than I like to admit: http://jsfiddle.net/jeKMF/


I think it expects you to combine the addition and multiplication, like this:

    (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7)))


I came up with the same solution and had the same wrong result.


"Green Bar" on the right: It is the navigation menu that comes into focus once you click on it. You can focus on the content w/o getting distracted by the ToC. :)

To OP. Don't worry. It is intuitive enough (for me at least (-; )


ok, here is my suggestions:

1, add a on page chat for people, so they could help each other

2, add comment extension for the page, so people could add extra notes or corrects for your error :] , i saw those style here `http://hgbook.red-bean.com/read/a-tour-of-mercurial-the-basi...

3, if possible, DO develop an app for mobile device, so you could get income or reputation which could driven you to continue this greate initial and finally done the job


uhh, It's got some sort of green bar, but it's stuck waaay over to my right and I can't read it. Chrome OSX


try clicking on the left edge of the green bar

sorry if it's not intuitive - I wanted the content to not be too wide (for reading) and had an idea to place some non-critical things on the remaining space, but then I decided it shouldn't always be visible

edit: I've fixed the page to make the green tab visible by default


The best way to cue that it is clickable is to have it "bounce" when you mouse over it, indicating that it is hidden on purpose and can be expanded.


Thanks, I've seen those bounces before but it never occurred to me to use it.

btw, I love your blog


Same. Firefox Win7

I usually don't interrupt my reading so often with interaction. I like to read a section at a time and then do the exercises. But with this format, I could see dabbling in a little interactive work more often - which is probably a good thing.


same with safari, osx


If I ever get up to Scheme, I'm adding this to my chart of interactive resources for learning programming.


Anyone have ideas for how best to show footnotes? The current version doesn't have them.


well, i just planing to post a blog about interactive books, hmm , seems late




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: