This is an HTML version of the slides from my “Lisp Basics and Idioms” presentation at the Chicago Lisp User Group’s Intro to Lisp Workshop. It’s also videotaped but it will take a while to transfer it to digital, edit it, etc. It was a good presentation (IMHO) worth waiting for, but here’s the sneak peek (with links!).
If you want to look at the .ppt, you can download it here, but it’s pretty bare (or ugly, depending on how charitable you are), it doesn’t have as much info as the version below (no links, fewer references), and it is missing all of the good verbal ad-libbing I did when presenting. But hey, I’m not complaining if you want to see it!
***Lisp Basics and Idioms***
Lisp Is Old
- 1958: John McCarthy writes an algebraic list processing language for AI work
- McCarthy\’s grad student wrote an interpreter for it
- Strongly tied to AI research during the 70s and 80s
- Evolution of Lisp (pdf)
- Fell from prominence during the AI Winter
Lisp Is New
- Paul Graham\’s essays – Beating the Averages, Lisp in Web-Based Applications
- Eric Raymond – “”LISP is worth learning for … the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot.“
- This and lots more Lisp quotes
- Me – Lisp: The Good Old Days Will Never Come Back – Let’s Welcom a Bright Future
- Recent development of open source versions
Lisp Is A Family of Languages
- Common Lisp: ANSI Standard written in the 80s caused languages to coalesce, then implementations to flourish
- Scheme: A conceptually cleaner variant with a smaller specification
- Proprietary: LispWorks, Allegro
- Open Source: SBCL, CLisp
- Others: compile to C, run on JVM, etc
Lisp Is Functional, But Not Strictly
- Functional is the most natural to write
- Can make sequential blocks, either explicitly or in constructs
- Can make and change values if needed
- Can build and incorporate new paradigms as necessary, i.e. CLOS
- Lisp is strongly typed, dynamic typed
Lisp Has Lots of Parentheses
- “Lisp has all the visual appeal of oatmeal with fingernail clippings mixed in.” -Larry Wall
- Used to group expressions
- Makes syntax simple and consistent
- Most forms are (function args*)
But the Parentheses Aren’t a Big Deal
- “Parentheses? What parentheses? I haven’t noticed any parentheses since my first month of Lisp programming. I like to ask people who complain about parentheses in Lisp if they are bothered by all the spaces between words in a newspaper” – Ken Tilton
- Editors indent automatically
- Emacs commands to balance and close parens
- Paredit (Emacs library) lets you manipulate sexps directly
Lisp Uses Symbols
- Like variables but better
- Like pointers but less dangerous
- Assign a name to a value
- Values can be lots of things – numbers, strings, functions, lists, other data structures
Lisp Has First Class Functions
- Easy to define
- (defun hello-world () (format t “hello, worldâ€))
- Can be passed as parameters
- Can be returned as values from other functions
- Anonymous functions too!
Lisp Has Flexible Parameters
- Parameters can be optional, with defaults
- (defun foo (a &optional b) (list a b))
- (defun foo2 (a &optional (b 10)) (list a b))
- Parameter lists can be variable length
- (defun + (&rest numbers) …)
- Keyword parameters
- (defun foo3 (&key a b) …)
Lisp Uses Pairs
- Lists are chains of pairs
- Can make other trees, etc as well
Lisp Uses Lists
- “It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures.” – Alan J. Perlis
- Tons of functions for manipulating lists
- Useful for recursive definitions
- Lists aren\’t perfect so…
Lisp Has More Than Just Lists
- Collections
- Vectors – fixed size sequences
- Arrays – can be multidimensional, resizable
- Sequence functions on collections – COUNT, FIND, POSITION, REMOVE, SUBSTITUTE, etc
- This is one place where syntax would help
- (aref a 5) instead of a[5]
Lisp Does Lots More
- File and File I/O
- Advanced object system using generic functions and message passing
- Text formatting
- Fancy iteration constructs
- Conditions and restarts
- Libraries for other things
Lisp Has Lots of Free Online Resources
Foster Lee says
Not only was the intro superb, but the now all the relevant links as well?! I thought all we’d get was a .ppt dump–wowza!
Kyle Burton says
I recently gave an intro talk in Philly PA, covering some of the same topics, my slides are available here:
http://asymmetrical-view.com/talks/lisp-presentation/