Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
CL or Scheme?
54 points by mcandre on Nov 21, 2010 | hide | past | favorite | 44 comments
I started reading Practical Common Lisp. It took me two whole days to setup a CL system: Emacs, SLIME, CLISP, Quicklisp. The syntax is riddled with intricacies: LET or LET* or FLET or LABLES? Is Scheme (esp. Racket) any better?

Also, is newLISP based on CL, Scheme, or something else? I've had zero difficulty installing and coding it.



Depends on what you want to use it for.

If you want to create powerful, intricate production apps, you're probably better off with CL. It's got better libraries, a bigger community, and more history.

If, on the other hand, you're interested in learning Lisp for the purity, the "aha" moments, and to become a better programmer, I'd have to recommend Scheme. It's a lot simpler, more self-consistent, with an order of magnitude less confusing bits and "gotchas". But it's still every bit as good at showing why Lisp is awesome.

And, of course, I must mention Clojure, which aside from the JVM cruft is much "cleaner" than CL, but just as powerful and ready for production use. It's also even more intensely focused on functional programming than Scheme OR CL.


Racket is very easy to get going with, you just install it and use the IDE, which gives you the text editor/code area and REPL together like emacs/slime. Scheme is a smaller language. For example, there is no flet/labels, you just use (define) for nested functions. It's a good way to get going with a Lisp and see if you want to take on a heavier language like CL or Clojure.


Isn't letrec (Scheme) and labels (CL) used for the same purpose?


First of all both Common Lisp and Scheme are excellent languages with impressive implementations to choose between. Furthermore if you learn one of them, you'll be able to learn the other one in no time.

Instead of comparing languages, I'd suggest you pick between implementations. This suggestion might seem odd, but the Scheme standard (R*RS) is very minimal, which imply that all major Scheme implementations contain many, many libraries and language construct not mentioned in the standard.

I my self is a Racket user, which of course makes my view biased. Here are some of the reasons Racket is the perfect choice for me:

   - programs runs on Windows, OS X and Linux 
     with no source changes

   - the installation is pain free

   - the documentation of the language and libraries 
     are in a league of its own 
     (http://docs.racket-lang.org/)
     [that said, the Common Lisp spec is also very good]

   - the language is clean with a very good module system
     that supports macros the right way (IMO)

   - the community is very helpful (ask if there is a
     library/construct/feature you can't find 
     --- odds are you the wrong place)


"After all, a picture is worth five hundred “hello world”s."

Thanks for the link to Racket tutorial.


Unless you plan to switch your projects to a Lisp (by which I mean a general name for CL or Scheme) right away, I would recommend the following route:

1. Start with PLT Scheme/Racket. It's self contained, very well supported on all platforms, and Scheme is a leaner and cleaner language that will cause you less confusion in the beginning. This platform should be enough for you to learn Lisp and be enlightened by its idioms.

2. If in the future you plan to get serious with Lisp and write real projects in it, reconsider. You will have much more familiarity with the eco-system by then. Scheme vs. Common Lisp is a religious war of epic (= brace style) proportions, and it's not wise to get confused by it right when you start.


I'd say Common Lisp is the superior choice.

In terms of the availability of support libraries and what not, you'll find it easier with Common Lisp. Quicklisp would be the most recent (and awesome) tool that comes to mind.

In terms of the language itself, it's just more complete to me.

LET and LET* have very different uses, and while ugly, LABELS has helped me quite a fair bit, especially in porting over some recursive Haskell code.

Oh, and don't forget the wonders of LOOP =)

Other than that, I can't speak for Racket, nor any of the other Lisps out there. So take by biased opinion as a CL user for what its worth.


Why do you say LET and LET* have very different uses? I just use LET* if I need to reference a preceding variable in the same declaration (it happens). Actually I vaguely remember PG in one of his Lisp books saying LET* indicates bad code, something I never understood, though empirically I've noticed some evidence for it.


Well, maybe 'very different' was an overstatement =).

One way to look at it is that we should use single-use functions as far as possible to keep code straightforward.

And as jpr said, LET* can potentially promote bad style, giving one the inclination to mix functional and imperative styles in a potentially troublesome fashion.

I think it was in 'On Lisp' that PG said that use of LET* should be minimised for the reasons above.

But if not, you're right. Use LET* just as you mentioned, but don't use LET* for all cases.

Some discussion available @ Stack Overflow: http://stackoverflow.com/questions/554949/let-versus-let-in-...


> LET* indicates bad code, something I never understood

Neither did I, until I encountered something along the lines of:

    (let* ((foo ...)

           (foo ...)

           (foo ...)

           (foo ...)

           (foo ...)

           (foo ...)

           (foo ...))

        ...)


That's strangely unidiomatic. I wonder why that person didn't just write:

  (let ((foo ...))
    (setf foo ...)
    (setf foo ...)
    ...)
On a tangential note, while I try to avoid multiple assignment as much as possible, I also enjoy availing myself of CL's imperativeness whenever doing so makes my code smaller or more efficient. I really like CL's multiparadigm approach. The sweet spot seems to be: allow side-effects in the small (i.e. within functions or small scopes) and be as strict as you can in composing larger pieces.


LOOP is awesome, probably my favorite feature of Common Lisp after CLOS.


I like CL, though if there were a book called Common Lisp: The Good Parts a la Crockford, it would probably describe the subset I like to code in (at least as long as I got to add LOOP.) In other words, CL is huge and there are large parts of it you need never use. I guess the intricacies you mention are annoying, but somehow those things never bothered me (e.g. I'm fine with CAR and CDR; they're short and symmetrical). I'd say Scheme is better for exploring ideas and CL is better for getting things done, so it depends on what you want. PCL targets CL, of course, so if you like the book and have gotten over the painful Emacs setup hurdle you may as well stick with it.

newLISP isn't based on CL or Scheme, it's its own weird thing that is regarded as leprotic by the rest of the Lisp community.


I use Chicken Scheme. I prefer Scheme over Common Lisp for practical reasons. None of the Common Lisp implementations that I'm aware of can compile code to nice, small, executables that start fast and don't use a ton of memory. They all either produce a huge image file or generate bytecode that has to be run in a VM.


Few months ago I was where you were, just a bit less confused. I liked different names for different things (flet vs. labels, for example), the language comes built-in with useful data-structures and functions (e.g., hash-tables; which one do you use in Scheme), documentation about stuff (hyperspec) is 3 keystrokes away in SLIME, and most of the book on macros (which are said to be LISP's main strength) are written for CL. Few days ago, I've seen a monads package written for common lisp using macros. Like, WOW!

I have also tried Racket, and I was kinda disappointed. Nothing that I could particularly point my finger on, but.. it had that feeling of being a "toy".

Yes, it might also be a personality preference. I'm the kind of person that prefers Perl over Python.


newLISP is a scripting language with a Lisp-like syntax. It's designed to be a Lisp-flavoured alternative to Perl or PHP or AppleScript. The emphasis is on staying small (250Kb) and easy to install, learn, and use. As a non-programmer I'm not clever enough to learn CL or Clojure, but I found newLISP pretty easy to learn and use for day-to-day scripting tasks and CGI work.

It's based on the ideas of Lisp, rather than on anything more concrete. I've been able to glimpse some of the elegance that Lisp users are familiar with. It shares some Lisp DNA (hence the name), but the author's focus on code size and ease of use has moved it away from mainstream Lisp developments. It won't (and doesn't) appeal to everyone, and wouldn't be suitable for all projects, but I've found it a useful tool to have in my toolbox. At least, it helps me get my work done and I've had some fun with it too, which can't be a bad thing, can it?


If anyone's considering picking up newLISP, be advised they made some widely criticized design decisions (such as omitting lexical scope, closures, pass by reference, and GC) intended to speed up the interpreter. Last I heard, they don't plan on having a compiler.

http://arclanguage.org/item?id=2911


omitting lexical scope, closures, pass by reference, and GC

None of those decisions were made for performance reasons, but because the creator of newLisp had no idea how to do them (lexical scope and call by reference were initially performance hacks, and actually make programs faster and/or smaller.)

A better name for the language would have been newBASIC, but even Basic is garbage collected. People who intend to use newLisp really need not suffer the parentheses. The language exists in familiar form as QBasic.


According to http://www.paulgraham.com/thist.html, at the time implementing lexical scope was a leap of faith. It was broadly assumed to be less efficient.


yeah, lush (http://lush.sourceforge.net/) is a lot more interesting in the alternative-lisp space, but they too omit lexical scoping :(


I'm a huge fan of Scheme. Not so much because of the language itself as for its ubiquity. You can find a Scheme interpreter for almost any platform, and for those that don't have one yet, it's actually tractable to implement an interpreter yourself (in some other language).

It's also a very elegant and beautiful language. At the end of the day, though, your customers care whether your product is beautiful, less so whether the code is beautiful.

I've never used CL.


I'm like the OP in that I've set up the environment and am up to Ch 12 in Practical Common Lisp. Plus it finally motivated me to learn emacs after a couple of decades of vim. The extract from the Land of Lisp makes me think I might enjoy Scheme more, since I'm just learning Lisp at home for fun.

Can you recommend a particular online learning resource? I've had a quick look at MIT's videos of their lecture series, but I've just run out of spare disk space on the laptop, so storing a few GBs of movie is out for the moment. If there's something like PCL for Scheme, that would be great.


SICP isn't as entertaining, but it's a classic. http://mitpress.mit.edu/sicp/

Also, The Scheme Programming Language. http://www.scheme.com/tspl3/


The Scheme Programming Language now has a 4th Edition:

http://www.scheme.com/tspl4/


Thank you to you both.


Newlisp is my favorite Lisp dialect. Before that I used Scheme and before that, CL. I prefer Newlisp because combination of dynamic scope and fexprs is conceptually simpler and more expressive than combination of lexical scope and macros. If reader doesn't believe me, he can check what Thomas Lord wrote on Lambda the Ultimate site, http://lambda-the-ultimate.org/node/3640

He really understood fexprs well. Or John Shutt's disertation. Or, this part of Alan Kay's interview: http://kazimirmajorinc.blogspot.com/2010/02/alan-kay-on-fexp...

Criticism of Newlisp? Well, yes and no - but, the point of every Lisp is, and particularly NL is - if something is missing, add it for yourself.

Picolisp is similar to Newlips, it is really minimal, very fast interpreter, written in assembler.

Other dialects have other advantages. But I'll stop here.


Go for Clojure. It's a modernized common-lisp with access to the wealth of Java libraries. There are resources online, and you should be able to get up and running in a matter of minutes.


I love clojure, but to be fair it took me a lot longer than that to get up and running, specially considering that I had no idea where to put the dependencies and how to compile things.


Would Clojure be worth trying rather than CL or Scheme for someone who doesn't have any Java experience, though?


With Clojure 1.2.0 and the build tools Leiningen or Cake you can get very far along w/o needing to know much about Java.


Thanks for the meaningful response. I know CL (sbcl . clisp) and Scheme (Chicken . Scheme48), but haven't done much with the JVM and I've been uncertain what relevance Clojure has.


You should have gone with your favourite editor + CLISP. Would have taken you 5 minutes and it would have been more than enough to get through PCL.

If you're not already familiar with Emacs, save it and Slime for later.


I just started reading Land of Lisp today, and the first chapter has exactly this discussion. Hope Conrad Barski, the author and HN reader, doesn't mind if I repost the excerpt here.

Land of Lisp, ps 16-17:

http://landoflisp.com/

"A Tale of Two Lisps

Some deep philosophical differences exist between ANSI Common Lisp and Scheme, and they appeal to different programmer personalities. Once you learn more about Lisp languages, you can decide which dialect you prefer. There is no right or wrong choice.

To aid you in your decision, I have created the following personality test for you:

A. (drawing of a mean looking wolf)

B. (drawing of a tranquil sheep)

C. (drawing of the wolf in the sheep's clothing)

If you chose A, you like raw power in your language. You don’t mind if your language is a bit ugly, due to a lot of pragmatic compromises, as long as you can still write tight code. ANSI Common Lisp is the best language for you! ANSI Common Lisp traces its ancestry most directly from the ancient Lisp dialects, built on top of millions of programmer hours, giving it incredibly rich functionality. Sure, it has some baroque function names due to countless historical accidents, but this Lisp can really fly in the right hacker’s hands.

If you chose B, you like languages that are clean and elegant. You are more interested in fundamental programming problems and are happy to while away on a beautiful meadow, contemplating the beauty of your code, occasionally writing a research paper on theoretical computing problems. Scheme is the language for you! It was created in the mid-1970s by Guy L. Steele and Gerald Jay Sussman and involved some soul-searching about the ideal Lisp. Code in Scheme tends to be slightly more verbose, since Schemers care more about mathematical purity in their code than creating the shortest programs possible.

If you chose C, you’re someone who wants it all: the power of ANSI CL and the mathematical beauty of Scheme. At this time, no Lisp dialect completely fits the bill, but that could change in the future. One language that might work for you (although it is sacrilege to make this claim in a Lisp book) is Haskell. It is not considered a Lisp dialect, but its followers obey paradigms popular among Lispers, such as keeping the syntax uniform, supporting native lists, and relying heavily on higher-order functions. More important, it has an extreme mathematical rigor (even more so than Scheme) that allows it to hide very powerful functionality under a squeaky clean surface. It’s essentially a wolf in sheep’s clothing. Like Lisp, Haskell is a language that any programmer would benefit from investigating further.

Up-and-Coming Lisps

As just mentioned, there really isn’t a true Lisp dialect available yet that possesses both the power and flexibility of ANSI Common Lisp and the elegance of Scheme. However, some new contenders on the horizon may attain the best-of-both-worlds crown in the near future.

One new Lisp that is showing promise is Clojure, a dialect developed by Rich Hickey. Clojure is built on the Java platform, allowing it to leverage a lot of mature Java libraries right out of the box. Also, Clojure contains some clever and well-thought-out features to ease multithreaded programming, which makes it a useful tool for programming seemingly ubiquitous multicore CPUs.

Another interesting challenger is Arc. It is a true Lisp language being principally developed by Paul Graham, a well-known Lisper. Arc is still in an early stage of development, and opinion varies widely on how much of an improvement it is over other Lisps. Also, its development has been progressing at a glacially slow pace. It will be a while before anyone can say if Arc might be a meaningful contender.

We’ll be dipping our toes in some Arc and Clojure in the epilogue."


Scheme isn't really a language like CL is. Scheme's R5RS standard is pretty minimal, and last time I checked (admittedly it's been awhile) R6RS is not that widely implemented (a lot of implementers never liked it).

Each implementation has its own way of doing things. Some are simple, and some are relatively baroque. Racket is more on the baroque end, though probably less so than CL.


I had the same issues starting CL. I think which LISP you pick is less important in the long run, rather than getting into the mode of writing functional programs. At some level, writing CL and writing Erlang are not that different experiences, to me at least. I know this sounds like abstract advice, but this is going to be a long journey anyway, so the most important thing is just to start it. Get Graham's ANSI Common Lisp book, get SLIME going and write something self-contained, like a basic matrix library. Worry about libraries later.


Learn both, you will eventually. Most Lispers know CL and Scheme, and most are competent in other languages as well.

I would say devour everything you can lay your hands on; you wont be able to do much in computing unless you're competent in at least 4-6 languages, with a read-only knowledge of another 10 or so.

It's not languages that matter (usually) rather the computing models, development styles, and programming paradigms:

http://en.wikipedia.org/wiki/Comparison_of_programming_parad...


I really value long term quality of my code and I highly value simplicity and pretty looking code. In these regards Scheme is a much better choice.

There may be some libs that are in CL but not Scheme, but I actually have found nearly everything in Scheme that is in CL. Although some common real world problems are better addressed in CL related documentation.

...And you really only need emacs (or Vim, etc) and CL, Scheme, whatever installed. Setting up SLIME and all that isn't necessary to get started.


A little off topic, but I notice a lot of people new to Emacs and Lisp banging there heads trying to get Slime set up and running, when Emacs has excellent Lisp support right out of the box. Slime is excellent, but complicated (even by Emacs standards). I wouldn't recommend a user installing it until a specific need arises. I can't imagine trying to learn Lisp, Emacs, and set up Slime all at once.


Setting up SBCL+Emacs+SLIME is really easy if you use Ubuntu or some other distro that contains packages for them. All you need to do in current Ubuntu is

    $ sudo apt-get install sbcl emacs slime && echo "(require 'slime)" >> ~/.emacs
and then start emacs and press Alt+x, write `slime´ and press enter (M-x slime for the initiated).

Now using all the available features of that combination will take a lot of time, but starting isn't really hard.


I am not sure how it works in Ubuntu, but you might need also to set the `inferior-lisp-program' variable to 'sbcl' in emacs.


Scheme R6RS: LET, LET* , LETREC, LETREC* , ...

I guess you have to learn those. Once you understand what the * means, you can easily see the difference between any construct with and without * .

It's basically the question whether bindings are done in parallel or sequentially nested. That topic should be described in a beginners book when learning some Lisp dialect.


One could also argue that once you have Emacs set up, you have enough to learn Lisp. Use ielm mode as a REPL, or lisp-mode for longer code bits. Sure you don't get lexical scope standard, but more than enough to muck around... The elisp info page built in is a fine reference.


'lisp in a box' ran out of the box, pardon the cliche , for me


It didn't work for me at all, unfortunately. Example: The Allegro CL version included is so old that Allegro refuses to license it.




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

Search: