
Lisp Quickstart - macco
http://cs.gmu.edu/~sean/lisp/LispTutorial.html
======
SeanLuke
Oh my goodness. My old lisp tutorials are on HN again.

Before anyone takes potshots, please understand that these tutorials have a
_very_ specific purpose: to get our AI students up and coding AI projects as
quickly as possible given what they know (C++/Java). So instead of talking up
front about the things that make Lisp special, I'm basically talking about how
to write C in Lisp. Hence, the tutorials don't ever discuss CLOS, macros,
advanced packages, conditions, streams, the type lattice, SLIME, ASDF,
Quicklisp, indeed any installable packages at all. Because we get to many of
those things, and the wonders of Lisp, later in the class.

~~~
triclops200
I don't think I remember us covering quicklisp or ASDF, professor. :p

~~~
SeanLuke
:-) Did both of them last year but not for 480.

------
TurboHaskal
Just print this, even if you won't ever use CL
[http://clqr.boundp.org/](http://clqr.boundp.org/)

It is a quick reference guide consisting on a set of pages that can be stacked
together to form a little booklet. Beautiful to look at.

I wish I had this for other languages and cannot recommend it enough.

~~~
walabaloo
That's really interesting, I've always loved the thought of hand bound books,
especially "homemade". Are you aware of any other projects like this?

~~~
Arcsech
There's Julia Evans' Zines[0], although they're a different style than the
linked guide. I have them printed and pinned to my cube wall.

[0] [http://jvns.ca/zines/](http://jvns.ca/zines/)

------
klibertp
> Closures are examples of powerful things which C++ simply cannot do.

Not true anymore. This article seems rather old, considering it refers to
Racket as "PLT Scheme" here:
[http://cs.gmu.edu/~sean/lisp/](http://cs.gmu.edu/~sean/lisp/), so it's at
least 7 years old, possibly older.

~~~
hellofunk
Closures in the functional programming sense don't really exist in C++.
"Closing over" a value means something quite specific, and C++ captures don't
do this; they merely copy by value or reference an outside entity. The only
way to get _close_ to it is if your C++ lambdas exclusively capture and thus
increment the reference count of shared pointers only, and no other types. Not
exactly idiomatic.

~~~
ezy
I don't think this is correct. I'm not sure there are many people that would
argue that C++11 doesn't have lexical closures just because its closures need
to take into account the semantics of C++ itself. Anyone who says that,
doesn't really understand how C++ is used, frankly.

You said it yourself, if you specify generic close by value, you will get the
behavior you want. If you know your closure won't outlive the stuff it closes
over, you can capture by ref. If you need some other behavior, you use smart
pointers and capture by value or mix and match based on what you're capturing.

Just because C++ doesn't automatically figure it out for you isn't an argument
against it having closures, any more than not a having bignum or rational
built in means it can't do arithmetic.

~~~
hellofunk
It's better to call them what they are in C++, lambdas, rather than closures,
in my opinion. The flexibility that proper closures provide in functional
languages just cannot exist in C++ and mixing the terms freely only confuses
the matter.

------
agentultra
I like the early introduction of the debugger. One of the more interesting
features of CL, in my experience, is the conditions and restarts system... and
built in debugger.

One approach to development in CL is to evaluate a form you would like to
have. You end up in the debugger. You write the implementation until the error
goes away. Repeat until you have a working system... interactive, hate-driven
development at its finest.

In fact that's one of my favourite things about CL: it's so interactive that
it almost never crashes. You can still interact with your program, see all of
the data, debug it, and _continue_.

~~~
brudgers
In Common Lisp users use Common Lisp rather than users using programs written
by programmers in <language x>. I think it comes directly from the idea of
Lisp Machines where typing s-expressions was how users used the computer.

That's radically different from Smalltalk and the Dynabook. Part of its
mandate was to be used by children which by definition meant there was an
assumption of substantial difference in cognitive capacity between end users
and programmers.

That's the intellectual model that's mostly won. It's distinct from a model in
which the causal premise for differences in knowledge is expertise and
experience.

~~~
tdeck
Incidentally, this is one of the most interesting aspects of the "crank"
operating system Temple OS, every program in the language is written in a
variant of C that's compiled on the fly, and the shell itself is just a C
REPL. I've never used it but found this article very interesting:

[http://www.codersnotes.com/notes/a-constructive-look-at-
temp...](http://www.codersnotes.com/notes/a-constructive-look-at-templeos/)

~~~
brudgers
Davis' work is an awesome intellectual achievement.

~~~
tdeck
Yeah it really is pretty great. I have a soft spot in my heart for PC speaker
music and rough-looking screen 12 user interfaces.

------
WhitneyLand
Does Lisp Suck?

If HN had a FAQ this might be near the top. As new people go into CS they seem
to be aesthetically drawn to, or repulsed by, Lisp. The irony is there is no
objective truth so these two groups of people spend a lot of time supporting
their arguments (google search will amaze you, even Paul Graham has been
sucked into this) but it's not very common for people to change sides after
their initial indoctrination.

I have come to view this as one of few (only?) metaphysical topics seriously
discussed in computer science.

Someone on SO once said: 'the correct Lisp answer is more gnomic. Something
like: "If you have to ask, you are not ready." Then if anyone questions
further, the correct answer is either "yes" if it's an either/or question or
"You are not ready."'

~~~
acalderaro
I've always wondered why LISP was such a hot-topic of discussion for CS
people. I'm not technical myself, but the idea of different computing
languages being more/less efficient in certain tasks is interesting.

I don't know how valid this is, since I've only spoken with a handful of
Lispers, but it seems that they appreciate the freedom and lack of
boundaries/rules/limits that Lisp provides. They talk about it like a language
that can do anything, because it has no rules on what it can or cannot do.

But at the same time, my friends also remind me that the lack of limits means
that they are more accountable for every line of code, and that as a beginner,
it'd be best for me to use something more structured (they always say Python)
until I'm comfortable taking off the training wheels.

Can anyone share their thoughts?

~~~
kazinator
> _I 've always wondered why LISP was such a hot-topic of discussion for CS
> people._

Because in a discussion with five CS people, only one has actual real Lisp
programming experience, one has some freshman experience in some professor's
one-weekend Lisp-like dialect where a run-time type error segfaults, and the
other three have different misconceptions about what Lisp is.

~~~
aidenn0
The number of times I've mentioned common lisp and gotten "Oh yeah, that's the
language with no loops, just recursion, right?" does sadden me a bit.

To clear it up for anyone reading this:

Scheme has tail-call elimination as a requirement of the language; common lisp
does not, and even includes an (overly?) sophisticated DSL for iteration in
the standard library.

Also 95% of what you learned about lisp in your "Survey of programing
languages" course was wrong.

~~~
taeric
The loop macro may be described as overly sophisticated. However, I can't help
but get a chuckle with how much all of the new "stream" based mechanisms in
java[1] mimic it. Ironically, with what appears to be more parens.

[1]
[https://docs.oracle.com/javase/8/docs/api/java/util/stream/C...](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html)

~~~
aidenn0
python's list comprehensions and generator expressions can get pretty complex
too.

~~~
taeric
To be fair, the LOOP facilities are ridiculously complex. Similarly so are the
FORMAT facilities.

I regret not knowing more about them as a younger programmer. Most of the
"power" of lisp is always shown in the ability to compose programs out of
forms. It is amazing how much code you can avoid writing by just using either
loop or format. Or both.

------
daliwali
If you are really in a hurry and can't commit to learning the hundreds of
forms in Common Lisp, Scheme is a minimalist alternative. The entire language
has only a few forms on which make up everything else.

~~~
chrismealy
Is scheme a suitable replacement for perl or ruby for everyday small-scale
programming?

~~~
m-j-fox
Perl and Ruby want to be suitable replacements for Scheme, not the other way
around. The authors of these languages were well aware of Lisp and many
features and aspects are imported wholesale. These systems amount to the
author's critique of Lisp -- what they felt was lacking in syntax or style or
hygiene or principles. Ruby says, Scheme is okay but why not more convenient
syntax for objects? Perl says, Lisp is cool but why not a maddening assortment
of wingdings?

Scheme and CL bicker over whether an empty list embodies the concept of
falsehood. JavaScript says wat? And Haskell is like, lol.

------
weavie
I wish there was a tutorial on how to navigate through the endless sea of
broken and undocumented third party libraries.

~~~
nerdponx
Seriously. I just started looking into Common Lisp last weekend, and if it
weren't for the active communities on Reddit and IRC, you'd get the impression
that the language was abandoned some time in 2012.

~~~
juki
Common Lisp is a very stable language. The standard hasn't changed in twenty
years, so (unlike many other languages) old code is still perfectly good.
Libraries that haven't been updated in a decade still work just as well as
they did a decade ago.

~~~
nerdponx
This is nice to know. Do Quicklisp packages typically come with test suites?
At least then I can check if a package will work before I commit to using it.

~~~
felideon
You can also check out cl-test-grid[1] and its results[2]. It shows every
quicklisp library tested against every (?) CL distribution.

[1] [https://github.com/cl-test-grid/cl-test-grid](https://github.com/cl-test-
grid/cl-test-grid) [2] [https://common-lisp.net/project/cl-test-
grid/library/](https://common-lisp.net/project/cl-test-grid/library/)

------
plg
What are some compelling examples of Lisp languages in use today in
apps/situations/use-cases that we might all know about?

A lot of people (likely mistakenly) think that it's just a language you learn
in CS classes and then leave behind.

~~~
lispm
If you use microprocessors from companies like AMD and Intel, there is a good
chance that parts of their design were checked with large amounts of Lisp
code.

Example:
[https://github.com/acl2/acl2/tree/master/books/rtl/rel11](https://github.com/acl2/acl2/tree/master/books/rtl/rel11)

> This directory contains an ACL2 library of register-transfer logic,
> developed at AMD from 1995 to 2011, and at Intel from 2012 to the present,
> in support of the mechanical verification of the floating-point arithmetic
> units designed during those periods by the respective companies.

~~~
kazinator
So, Lisp provides static checking that is so early, it precedes your CPU being
taped out.

------
unknownsavage
The lisp quickstart is indeed one of the key advantages of lsip:

    
    
        $ time sbcl --script hello.lisp 
        Hello World!
    
        real	0m0.026s
        user	0m0.009s
        sys	0m0.013s
    

Compared with languages with a much bigger starting curve:

    
    
        $ time node hello.js 
        Hello World!
      
        real	0m0.113s
        user	0m0.052s
        sys	0m0.022s

~~~
pjmlp
And you can AOT compile your Lisp code to pure native code, try that with
JavaScript.

~~~
TeMPOraL
Maybe a stupid question, but is AOT a new name for what just few years ago we
used to call "normal" compilation?

~~~
nickpsecurity
No, lol, it's exactly normal compilation. It's a buzzword that differentiates
languages without normal compilation (esp using VM's or interpreters) from
special implementations of them that do support that. The latter have "AOT"
compilation. Wikipedia states the difference is AOT compiles the bytecode of
an existing VM. It's still just a compiler, though, given the end result is
mostly the same.

------
mark_l_watson
An old write up, but it shows the style of repl programming. I have been using
Common Lisp since the 1980s, and for me it is all about using a bottom up
interactive programming style - same as programming in Haskell, Ruby, Python,
Scala, etc.

------
acheron
The author posts to HN sometimes:
[https://news.ycombinator.com/user?id=SeanLuke](https://news.ycombinator.com/user?id=SeanLuke)

(I was a grad student in one of his classes many years ago.)

------
muterad_murilax
Why does CL feature an ascii rendering of the golden menorah?

~~~
junke
Not all CL implementations, just CLisp.

[http://www.clisp.org/impnotes/faq.html#faq-menorah-
why](http://www.clisp.org/impnotes/faq.html#faq-menorah-why)

------
bitwize
Since Lisp flamewars are to the average Hackernews what catnip is to a cat,
Hackernews pounces on a years-old quick-start guide to Lisp for university
students who took AI as an elective to meet their major requirements, and who
will likely end up hating Lisp with the fury of a thousand suns by the time
they graduate.

The Clojure Inquisition stops by to remind everybody that what really matters
in programming languages is how many hipsters you can attract into your fan
base.

~~~
dang
Would you please stop making up generalizations about Hacker News to score
rhetorical points? It indulges the desire to feel better than everybody else,
which gets upvotes since (ironically) everybody loves having that indulged.
Nevertheless it makes for a bad HN comment because its underlying message is
just "Look at me." I recommend listening to
[https://www.youtube.com/watch?v=mmb7TU0OrOI](https://www.youtube.com/watch?v=mmb7TU0OrOI)
instead.

I emphasize this because you posted
[https://news.ycombinator.com/item?id=13943374](https://news.ycombinator.com/item?id=13943374)
a few days ago, which was a particularly dismaying example. Comments like that
basically activate a bug in human firmware to the detriment of substantive
discussion.

~~~
bitwize
Oh please. My goal was not to score rhetorical points but to make HNers crack
a smile in the style of
[http://n-gate.com/hackernews/](http://n-gate.com/hackernews/)

If you think I'm being overbroad in my generalizations, of course I am. As
they say, "That's the joke."

I'll stop but only under protest, and with the note that I think HN
administration is misreading the effect this has on people. (Hint: it's funny
because the average Hackernews _sees a little of themself_ in the n-gate
posts, not because they feel smugly superior.)

~~~
dang
Ok, I obviously read your motive wrong (sorry!). Not sure I'm wrong about the
effects on the threads, though.

