Peter Christensen

  • Presentations
  • Contact Me

“Lisp Basics and Idioms” Presentation from Intro to Lisp Workshop

May 31, 2008 by Peter 4 Comments

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
    • Original Paper: RECURSIVE FUNCTIONS OF SYMBOLIC EXPRESSIONS AND THEIR COMPUTATION BY MACHINE (Part I)
  • 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
    • Common Lisp Implementations: A Survey
  • 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
    • Beyond Lists: Other Uses for Cons Cells

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
    • They Call It LISP For A Reason: List Processing
  • 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

  • Common Lisp: First Contact
  • A Gentle Introduction to Symbolic Computation (buy dead tree copy)
  • Structure and Interpretation of Computer Programs (buy dead tree copy)
  • Practical Common Lisp (buy dead tree copy)
  • OnLisp (buy dead tree copy)

Filed Under: Lisp

Comments

  1. Foster Lee says

    May 31, 2008 at 11:58 pm

    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!

  2. Kyle Burton says

    June 4, 2008 at 4:45 pm

    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/

Trackbacks

  1. Chicago Intro to Lisp Workshop Attendee Stats » What’s In Peter’s Head says:
    June 3, 2008 at 11:23 am

    […] put up Here’s an HTML version of my slideshow “Lisp Basics and Idioms” soon. I’m not sure what to do about the Macros presentation since it’s more in depth […]

  2. Hey Language Snobs: Don’t Pinch Pennies » What’s In Peter’s Head says:
    June 4, 2008 at 10:58 am

    […] Emacs and SLIME, how to learn Lisp, how to setup an environment, access documentation, and the right mindset for developing in Lisp. Heck, I even organized a workshop to help other people learn Lisp! Notice all the working software […]

Leave a Reply

You must be logged in to post a comment.

Categories

  • Blog
  • Book Review
  • Business
  • Clojure
  • Education
  • Emacs
  • Fun
  • iOS
  • Lisp
  • Personal Sprints
  • Pictures
  • Polyphasic
  • Presentations
  • Programming
  • Rails
  • Startups
  • Uncategorized

Copyright © 2025 · Minimum Pro Theme on Genesis Framework · WordPress · Log in