News for hackers. Stuff that matters.
Re:SICP in Clojure (In Progress) by silkodyssey on Saturday October 24, 2009 @05:13PM (#900948)
Rich Hickey has some interesting things to say about learning clojure via SICP. http://groups.google.com/group/clojure/browse_thread/thread/...
Re:SICP in Clojure (In Progress) by dschobel on Saturday October 24, 2009 @05:55PM (#900979)
Kind of off-topic, but I'm pretty surprised clojure doesn't do TCO.

Is that a JVM limitation?

Re:SICP in Clojure (In Progress) by ikitat on Saturday October 24, 2009 @06:00PM (#900982)
Yes
Re:SICP in Clojure (In Progress) by dantheman on Saturday October 24, 2009 @06:39PM (#901006)
This one of the things that Microsoft got right with the CLR. That TCO is required by scheme is where I finally grokked programming language semantics -- how implementation and form are intertwined.
Re:SICP in Clojure (In Progress) by tl on Saturday October 24, 2009 @07:48PM (#901050)
Isn't the TCO problem largely a non-issue? My understanding is that if you do (defn function [...] ... (recur ...)) instead of (defn function [...] ... (function ...)) the compiler handles it for you.
Re:SICP in Clojure (In Progress) by scythe on Saturday October 24, 2009 @07:56PM (#901057)
There's more to tail-call optimization than simply imitating iteration using recursion.
Re:SICP in Clojure (In Progress) by dmoney on Saturday October 24, 2009 @08:03PM (#901062)
What else is it used for?
Re:SICP in Clojure (In Progress) by silentbicycle on Sunday October 25, 2009 @12:04PM (#901692)
It may help to stop thinking of it being used specifically for recursion - there can be tail calls between several functions. In cases where TCO is applicable, function A calls B, and B calls C, but since B isn't doing anything to the result, C can return directly to A. This is transitive - D, E, F, ... could all return to A as well, in constant space. It "goto"s the next function (but with arguments), and returning and popping the results off the call stack is deferred.

Rather than going into fairly abstract examples* , TCO is useful because it allows more things to be expressed in terms of function calls, without having to worry about blowing the stack. While the discussion surrounding them can be a bit overly academic, they ultimately matter because they can help make code clearer. (Not always, but you can implement clearer looping mechanisms on top of them.) A tail call is like a de-fanged goto.

* Just one: Parsing by implementing a finite state machine in function calls. See Shriram Krishnamurthi's "The Swine Before Perl" (http://www.cs.brown.edu/~sk/Publications/Talks/SwineBeforePe...).

While the stacktrace no longer records intermediate steps, (and thus loses info useful for debugging), language implementations can typically hook tail calls to save the information when a debugging flag is on. It's not as big a problem in practice as some people think.

Re:SICP in Clojure (In Progress) by chancho on Saturday October 24, 2009 @08:23PM (#901087)
Re:SICP in Clojure (In Progress) by Xichekolas on Sunday October 25, 2009 @12:08AM (#901237)
Also, this blog post (which did the rounds on HN a while back) was excellent for understanding it:

http://funcall.blogspot.com/2009/04/you-knew-id-say-somethin...

(It's part of a 5 part series... but you don't have to necessarily read all of them... it kind of wanders.)

Re:SICP in Clojure (In Progress) by JoelMcCracken on Saturday October 24, 2009 @05:03PM (#900939)
What's wrong with scheme?
Re:SICP in Clojure (In Progress) by bretthoerner on Saturday October 24, 2009 @05:45PM (#900969)
Nothing, but if you're starting from scratch and know you'd have a real world use-case for Clojure sometime soon, why not learn its APIs, warts, etc rather than Scheme's?
Re:SICP in Clojure (In Progress) by tjr on Saturday October 24, 2009 @06:51PM (#901016)
SICP really isn't about learning Scheme, and probably shouldn't be about learning Clojure... but if someone wants to present the material in Clojure, sure, why not?
Re:SICP in Clojure (In Progress) by l0stman on Saturday October 24, 2009 @07:04PM (#901024)
Well, SICP is hardly about Scheme itself as a language. Some features such as macros aren't mentioned at all.

It has more emphasis on programming paradigms and Scheme is just a tool to convey them. Its core is small and simple enough that you could introduce advanced topics without the need for the reader to learn the language beforehand.

Re:SICP in Clojure (In Progress) by tayssir on Sunday October 25, 2009 @06:36PM (#902269)
Well, the many tools for _The Elements of Computing Systems_ are written in Java, which makes it easy for people to experiment. http://www1.idc.ac.il/tecs/software.html

So perhaps a conceivable bonus is that SICP can somehow be merged with that book.

(This is not a direct answer to your question; there's nothing wrong with Scheme; just mentioning advantages of using Clojure.)

Re:SICP in Clojure (In Progress) by timf on Sunday October 25, 2009 @05:22AM (#901432)
Re:SICP in Clojure (In Progress) by alrex021 on Saturday October 24, 2009 @04:39PM (#900914)
Current status of the adaptation: http://sicpinclojure.com/content/current-status
Re:SICP in Clojure (In Progress) by dschobel on Saturday October 24, 2009 @04:45PM (#900919)
Seems like a Herculean task for one person.

I wonder if the author considered making it a wiki and enlisting the clojure community's help?

Re:SICP in Clojure (In Progress) by scott_s on Saturday October 24, 2009 @04:59PM (#900936)
If you look at the status page, he wants to implement community features including editing.
Re:SICP in Clojure (In Progress) by cesare on Saturday October 24, 2009 @05:23PM (#900958)
The website runs on Drupal, which has multi user editing, revisions etc. The 'book' module (included in the default installation) is basically a wiki. So, the infrastructure is already in place.
Re:SICP in Clojure (In Progress) by c00p3r on Sunday October 25, 2009 @01:09PM (#901760)
Why JVM while there is LLVM?

btw, is there any work-in-progress implementations of arc using llvm?