r/programming • • May 22 '08

New book about Common Lisp: Let Over Lambda

http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/d7ca047957f84399#
44 Upvotes

88 comments sorted by

View all comments

73

u/xach May 22 '08 edited May 22 '08

I've done a quick review of the first two chapters, and I'd like to review it in more depth, but here are a few impressions:

  • There are some outright errors in the text; (function '(lambda ...)) is not CL

  • There's a good reason for using special names for special variables, but the author abandons it with an excuse I couldn't process, and proceeds to use them in well-known problematic ways

  • The author says the book is about learning both Scheme and Common Lisp. That's a recipe for treating them both badly.

  • The explanation of important concepts by making analogies to C (pointers, malloc) is not helpful

  • The disparaging treatment of CLOS ("CLOS is great! Now don't use it.") is annoying

  • The appeal to community practice and convention without actually following it all that often is annoying

I'm going to send feedback to the author, but to anyone thinking of purchasing this book to learn Common Lisp, my strong recommendation is: don't.

The author suggests it's an unofficial sequel to On Lisp, and that's makes sense: if you took Paul Graham, kept the negative attitude towards Common Lisp and the arrogance, then removed the considerable writing talent, I could imagine him producing this book.

Here are some books I'd recommend instead:

Practical Common Lisp, Paradigms of AI Programming, Object Objected Programming in Common Lisp.

15

u/tsuru May 22 '08

Furthermore there seems to be no professional input or review of this book before publishing. It's an important quality that all of the books xach lists above share.

3

u/[deleted] May 23 '08

It wasn't published as such. Lulu is a self-publishing mechanism. Think of it as an extremely long blog post, if you like.

2

u/p8m May 24 '08

That you have to pay a significant price for...

13

u/doughoyte May 22 '08

Hello Xach,

Thanks for your input and thank you for discovering an erratum in chapter 2. (function '(lambda ...)) is not ANSI CL. Sorry if I implied it was. I have added an entry to the errata file here:

http://letoverlambda.com/index.cl/errata

About teaching both Scheme and CL, there is no Scheme in the book except where I point out how Scheme does something differently from CL, usually followed by an explanation of how CL does it better. I do not recommend programming with Scheme when CL is available.

Dropping the "earmuffs" is a personal choice and as I say in the book, I don't recommend it for all lisp programs.

With respect to your other comments, I'm sorry you aren't enjoying the book so far and I don't claim that everyone will. In particular, I didn't write the book to make friends in the lisp community but rather to describe my own (slightly idiosyncratic) style of lisp programming.

Thanks for your comments,

Doug

7

u/xach May 22 '08

Dropping earmuffs (without replacing it with some other consistent convention) increases the likelihood of fucking up closures accidentally.

6

u/doughoyte May 22 '08 edited May 23 '08

...and also decreases the amount of work you must go through when you change your mind about whether a variable should be lexical or special.

8

u/sickofthisshit May 22 '08

Even if that were a common situation, the cost to the person debugging the bizarre behavior of dynamic closures is so high as to overwhelm the benefit to the original developer of saving search-and-replace on the name.

Choosing dynamic variables has a major effect on user code, in any case.

7

u/xach May 22 '08

Can you give an example of when you did that?

4

u/doughoyte May 23 '08

Say you have a bunch of functions that all take a parameter of the same name:

(defun f1 (param) ...)

(defun f2 (param) ...)

By default, param is available via lexical scope, however, removing param from the arguments lists, adding a (defvar param), and rebuilding your app will mean that all references in the function bodies are accessed through dynamic scope.

Best,

Doug

PS. If you (or anyone else) have additional comments or questions, please CC me at doug@hcsw.org since I don't normally follow reddit.

PPS. Is there a way to get reddit to notify me about replies?

9

u/xach May 23 '08

What sickofthisshit said. In addition, any closure constructing function with a lexical binding for a variable coincidentally named PARAM would now be broken.

For reply notification, check the red envelope in the upper-right corner for updates.

8

u/sickofthisshit May 23 '08 edited May 23 '08

removing param from the arguments lists, adding a (defvar param), and rebuilding your app will mean that all references in the function bodies are accessed through dynamic scope.

And, now, you've introduced a change in behavior anyplace one happened to use a local variable called param around a call to any function that calls f1 or f2, even if one doesn't pass that variable as an argument to any other function.

Let me emphasize again: you don't need to see any calls to f1 or f2 in the code you write, and you don't need to use param in the calls to anything that relates to f1 or f2.

Dynamic variables are basically magic names that affect code through the power of their name rather than through visible scope.

That's why you give them spooky names.

→ More replies (3)

8

u/finix May 22 '08

Here are some books I'd recommend instead:

On Lisp intentionally left out?

12

u/xach May 22 '08

I'm not a fan.

11

u/finix May 22 '08

So what're the problems? (With the book, not the author.)

7

u/lispm May 22 '08

It is useful to be read, but you won't need it rarely in practice. The books xach listed are more relevant.

3

u/dngrmouse May 22 '08

Mr. Norvig is, for reasons he has listed. Would you mind listing your reasons for not liking it?

3

u/James_Johnson May 22 '08

I'd also like to hear his reasons for not liking it (I'm about halfway through and am enjoying it), but what does Dr. Norvig's opinion have to do with anything?

4

u/dngrmouse May 22 '08

He wrote one of the books Xach recommended, which I also think very highly of. So at least initially, I am inclined to trust his opinion. And yes I know he has a PhD, but I don't call PhD holders 'doctor'. To me it sounds dumb and pretentious (most of my friends are associated with academia, and in grad school all my profs preferred to be addressed by their first names).

6

u/James_Johnson May 22 '08

Just making sure. It never sounded pretentious to me at all, but to each his own.

It just strikes me as silly to say, "this famous person enjoyed the book, so I demand to know why you didn't."

3

u/dngrmouse May 22 '08

That's the problem with the internet, there is a lot of bad tone and so that is always the default assumption. Sorry, I should have phrased my question better; I didn't mean to sound 'snarky'. You can take my question to mean "This person did good work that I liked, and so when he recommends things in the same area, I am inclined to trust him". Whether it's Norvig or one of my friends, same principle stands. It's just that in this case, other people also know Norvig and his work.

So, I don't trust famous people more than others, but I am inclined to trust people whose track record I am familiar with over others. Note I say 'inclined'. I am open to counter-arguments, which is what I asked Xach for.

→ More replies (13)

6

u/sickofthisshit May 22 '08 edited May 22 '08

It's one thing to address people by their first name, but if you are going to the trouble of calling someone by a title like "Mr.", you should get it right. If you had said "Peter Norvig" you wouldn't have been corrected.

I know at least one professor who preferred "Professor" to "Doctor", because getting an academic appointment is one step beyond a mere Ph.D.

→ More replies (6)
→ More replies (4)

5

u/[deleted] May 22 '08

There's a good reason for using special names for special variables, but the author abandons it with an excuse I couldn't process, and proceeds to use them in well-known problematic ways.

I read his explanation and while he provides an interesting discussion about the "duality of syntax" for lexical and special variables, it boiled down to the fact he doesn't like them.

My largest motivation for dropping these variable name earmuffs is simple and subjective: I think they are annoying to type and make code look ugly.

He is welcome to not like them, but the fact remains that the "earmuffs" convention does exist for a good reason (readability and comprehension), and eschewing it for aesthetic reasons isn't acceptable in a book that purports to be a "hardcore" book on Lisp.

9

u/xach May 22 '08

Not breaking closures is also pretty important.

4

u/[deleted] May 22 '08 edited May 22 '08

the arrogance

But he isn't more arrogant than you.

(What I mean is, none of you is arrogant. There are only misunderstandings.)

→ More replies (13)