Clojure from SICP? Good idea?

1915 views
Skip to first unread message

Michael Campbell

unread,
Mar 25, 2008, 4:29:42 PM3/25/08
to clo...@googlegroups.com
If I'm trying to learn a lispy type language from SICP, is there much
advantage to using clojure over scheme to do it?

I /want/ to use clojure, but wondered if the impedance mismatch would be
more than its worth.

Paul Drummond

unread,
Mar 25, 2008, 5:37:36 PM3/25/08
to Clojure
On Mar 25, 8:29 pm, Michael Campbell <michael.campb...@gmail.com>
wrote:
Why not use both! I am reading "On Lisp" and SICP and spend a lot of
time converting Common Lisp and Scheme examples into Clojure. IMO
It's an interesting and fun way to learn - if nothing else it keeps
you on your toes! ;)

If you are just starting out with lisp style, I'd recommend sticking
with PLT Scheme (with its nice, simple UI) and following the examples
in the book until you understand them. Once understood you could then
try to convert them into Clojure and see how far you get.

Regarding the "impedance mismatch" can you elaborate? As a Lisp
dialect, Scheme and Clojure have a lot more in common than, say, Java
and Clojure.

Paul.

Michael Campbell

unread,
Mar 25, 2008, 5:42:15 PM3/25/08
to clo...@googlegroups.com
Paul Drummond wrote:

> Regarding the "impedance mismatch" can you elaborate? As a Lisp
> dialect, Scheme and Clojure have a lot more in common than, say, Java
> and Clojure.

What I meant by that is a reference to something Rich said a few days ago;
(paraphrased) "Clojure is not Scheme, so don't let things you've learned
in/from Scheme unduly influence how you think about them in Clojure".

Not knowing either, I don't know how close or far apart idioms between the 2
languages are, and don't want to confuse myself by mixing up learning the
langauge and learning its (correct) idioms.


Paul Drummond

unread,
Mar 25, 2008, 6:40:36 PM3/25/08
to Clojure
> What I meant by that is a reference to something Rich said a few days ago;
> (paraphrased) "Clojure is not Scheme, so don't let things you've learned
> in/from Scheme unduly influence how you think about them in Clojure".
> Not knowing either, I don't know how close or far apart idioms between the 2
> languages are, and don't want to confuse myself by mixing up learning the
> langauge and learning its (correct) idioms.

Hmmm. I think Rich is just warning us not to make particular
assumptions about Clojure's implementation, philosophy or direction.
Clojure is a independent dialect of Lisp and therefore isn't Scheme
and as long as you bare that in mind while learning I don't think
there will be a problem.

I may be wrong - I am learning myself and can only comment on my
experiences so far. Currently, I am benefiting no-end from studying
and comparing the different implementations (CL, Scheme, Clojure, even
Java).

As an example, I recently challenged myself with the task of
converting some CL code (qwenty-questions, 6.1 "On Lisp") which made
destructive updates on hash-tables using setf, which of course you
can't do in Clojure so I was forced to think about the functional
approach and I had to consider the program differently. Even though I
have read about immutable data structures and the disadvantages of
destructive updates in the past, it wasn't until I actually came
across these concepts/issues that I really got it. I learned heaps
about Clojure and the functional style it promotes and also a lot
about Common Lisp (setf, funcall, etc.) in the process.

Paul.

loumf

unread,
Mar 26, 2008, 7:41:16 AM3/26/08
to Clojure
I personally used SICP and On Lisp as a guide to learning clojure and
found it helpful. I blogged my progress here (start from Day 1 to see
the SICP translations)

http://www.loufranco.com/blog/files/category-20-days-of-clojure.html

Rich Hickey

unread,
Mar 26, 2008, 10:53:05 AM3/26/08
to Clojure


On Mar 25, 4:29 pm, Michael Campbell <michael.campb...@gmail.com>
wrote:
Everyone's experience will be different, of course. Here's my 2 cents:

I don't think SICP is a book about a programming language. It's a book
about programming. It uses Scheme because Scheme is in many ways an
atomic programming language. Lambda calculus + TCO for loops +
Continuations for control abstraction + syntactic abstraction (macros)
+ mutable state for when you need it. It is very small. It is
sufficient.

The book really deals with the issues in programming. Modularity,
abstraction, state, data structures, concurrency etc. It provides
descriptions and toy implementations of generic dispatch, objects,
concurrency, lazy lists, (mutable) data structures, 'tagging' etc,
designed to illuminate the issues.

Clojure is not an atomic programming language. I'm too tired/old/lazy
to program with atoms. Clojure provides production implementations of
generic dispatch, associative maps, metadata, concurrency
infrastructure, persistent data structures, lazy seqs, polymorphic
libraries etc etc. Much better implementations of some of the things
you would be building by following along with SICP are in Clojure
already.

So the value in SICP would be in helping you understand programming
concepts. If you already understand the concepts, Clojure lets you get
on with writing interesting and robust programs much more quickly,
IMO. And I don't think the core of Clojure is appreciably bigger than
Scheme's. What do Schemers think?

I think the Lisps prior to Clojure lead you towards a good path with
functional programming and lists, only to leave you high and dry when
it comes to the suite of data structures you need to write real
programs, such data structures, when provided, being mutable and
imperative. Prior Lisps were also designed before pervasive in-process
concurrency, and before the value of high-performance polymorphic
dispatch (e.g. virtual functions) as library infrastructure was well
understood. Their libraries have decidedly limited polymorphism.

Alas, there is no book on Clojure yet. But, to the extent Schemes go
beyond the standard to provide more complete functionality (as most
do), there are no books on that either. Just docs in both cases.

Learning Scheme or Common Lisp on your way to Clojure is fine. There
will be specifics that don't translate (from Scheme - no TCO, false/
nil/() differences, no continuations; from CL - Lisp-1, symbol/var
dichotomy). But I personally don't think SICP will help you much with
Clojure. YMMV.

Rich

Michael Campbell

unread,
Mar 26, 2008, 12:11:15 PM3/26/08
to clo...@googlegroups.com
Rich Hickey wrote:
>
>
> On Mar 25, 4:29 pm, Michael Campbell <michael.campb...@gmail.com>
> wrote:
>> If I'm trying to learn a lispy type language from SICP, is there much
>> advantage to using clojure over scheme to do it?
>>
>> I /want/ to use clojure, but wondered if the impedance mismatch would be
>> more than its worth.
>
> Everyone's experience will be different, of course. Here's my 2 cents:

Rich, seriously, stuff like that needs to be on a wiki somewhere. I'd be glad
to put it on the clojure one, but I'm not sure if you'd like it to be, nor if
so, where. Let me know though and I'd be glad to do it.

Rich Hickey

unread,
Mar 26, 2008, 12:56:25 PM3/26/08
to Clojure


On Mar 26, 12:11 pm, Michael Campbell <michael.campb...@gmail.com>
Taken as a whole, it's a bit of a rant :)

But yes, sure. The Clojure wiki is there to allow users to help other
users. If I say something here on the group that clarifies something,
or post a useful example, feel free to work it up as a wiki entry.
I've got a full plate and would love to see the wiki grow in the hands
of others, butting in only for correctness or idiomaticity.

One project I'd love to see users take on is providing a small example
of the use of every library function (and its output). That would be a
great complement to the documentation.

Rich
Reply all
Reply to author
Forward
0 new messages