{"id":263,"date":"2008-05-31T19:01:19","date_gmt":"2008-06-01T00:01:19","guid":{"rendered":"http:\/\/www.pchristensen.com\/blog\/?p=263"},"modified":"2013-12-23T12:06:32","modified_gmt":"2013-12-23T19:06:32","slug":"lisp-basics-and-idioms-presentation-from-intro-to-lisp-workshop","status":"publish","type":"post","link":"http:\/\/pchristensen.com\/blog\/articles\/lisp-basics-and-idioms-presentation-from-intro-to-lisp-workshop\/","title":{"rendered":"&#8220;Lisp Basics and Idioms&#8221; Presentation from Intro to Lisp Workshop"},"content":{"rendered":"<p>This is an HTML version of the slides from my &#8220;Lisp Basics and Idioms&#8221; presentation at the Chicago Lisp User Group&#8217;s Intro to Lisp Workshop.  It&#8217;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&#8217;s the sneak peek (with links!).<\/p>\n<p>If you want to look at the .ppt, you can <a href=\"http:\/\/www.pchristensen.com\/blog\/wp-content\/uploads\/2008\/05\/lisp-basics-and-idioms.ppt\">download it here<\/a>, but it&#8217;s pretty bare (or ugly, depending on how charitable you are), it doesn&#8217;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&#8217;m not complaining if you want to see it!<\/p>\n<p><strong>***Lisp Basics and Idioms***<\/strong><\/p>\n<p><!--more--><\/p>\n<p><strong>Lisp Is Old<\/strong><\/p>\n<ul>\n<li>1958: John McCarthy writes an algebraic list processing language for AI work\n<ul>\n<li>Original Paper: <a href=\"http:\/\/www-formal.stanford.edu\/jmc\/recursive.html\" target=\"_blank\">RECURSIVE FUNCTIONS OF SYMBOLIC EXPRESSIONS AND THEIR COMPUTATION BY MACHINE (Part I)<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"http:\/\/www-formal.stanford.edu\/jmc\/history\/lisp\/lisp.html\" target=\"_blank\">McCarthy\\&#8217;s grad student wrote an interpreter for it<\/a><\/li>\n<li>Strongly tied to AI research during the 70s and 80s\n<ul>\n<li><a href=\"http:\/\/www.cs.umbc.edu\/331\/resources\/papers\/Evolution-of-Lisp.pdf\" target=\"_blank\">Evolution of Lisp<\/a> (pdf)<\/li>\n<\/ul>\n<\/li>\n<li>Fell from prominence during the <a href=\"http:\/\/en.wikipedia.org\/wiki\/AI_winter\" target=\"_blank\">AI Winter<\/a><\/li>\n<\/ul>\n<p><strong>Lisp Is New<\/strong><\/p>\n<ul>\n<li>Paul Graham\\&#8217;s essays \u00e2\u20ac\u201c <a href=\"http:\/\/paulgraham.com\/avg.html\" target=\"_blank\">Beating the Averages<\/a>, <a href=\"http:\/\/lib.store.yahoo.net\/lib\/paulgraham\/bbnexcerpts.txt\" target=\"_blank\">Lisp in Web-Based Applications<\/a><\/li>\n<li>Eric Raymond \u00e2\u20ac\u201c \u00e2\u20ac\u0153&#8221;LISP is worth learning for \u00e2\u20ac\u00a6 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.\u00e2\u20ac\u0153\n<ul>\n<li>This and <a href=\"http:\/\/paulgraham.com\/quotes.html\" target=\"_blank\">lots more Lisp quotes<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Me &#8211; <a href=\"http:\/\/www.pchristensen.com\/blog\/articles\/lisp-the-golden-age-isnt-coming-back-lets-welcome-a-bright-future\/\">Lisp: The Good Old Days Will Never Come Back &#8211; Let&#8217;s Welcom a Bright Future<\/a><\/li>\n<li>Recent development of open source versions<\/li>\n<\/ul>\n<p><strong>Lisp Is A Family of Languages<\/strong><\/p>\n<ul>\n<li>Common Lisp: ANSI Standard written in the 80s caused languages to coalesce, then implementations to flourish\n<ul>\n<li><a href=\"http:\/\/common-lisp.net\/~dlw\/LispSurvey.html\" target=\"_blank\">Common Lisp Implementations: A Survey<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Scheme: A conceptually cleaner variant with a smaller specification<\/li>\n<li>Proprietary: <a href=\"http:\/\/www.lispworks.com\/downloads\/\" target=\"_blank\">LispWorks<\/a>, <a href=\"http:\/\/www.franz.com\/downloads\/allegrodownload.lhtml\" target=\"_blank\">Allegro<\/a><\/li>\n<li>Open Source: <a href=\"http:\/\/www.sbcl.org\/\" target=\"_blank\">SBCL<\/a>, <a href=\"http:\/\/clisp.cons.org\/\" target=\"_blank\">CLisp<\/a><\/li>\n<li>Others: compile to C, run on JVM, etc<\/li>\n<\/ul>\n<p><strong>Lisp Is Functional, But Not Strictly<\/strong><\/p>\n<ul>\n<li>Functional is the most natural to write<\/li>\n<li>Can make sequential blocks, either explicitly or in constructs<\/li>\n<li>Can make and change values if needed<\/li>\n<li>Can build and incorporate new paradigms as necessary, i.e. CLOS<\/li>\n<li>Lisp is strongly typed, dynamic typed<\/li>\n<\/ul>\n<p><strong>Lisp Has Lots of Parentheses<\/strong><\/p>\n<ul>\n<li>&#8220;Lisp has all the visual appeal of oatmeal with fingernail clippings mixed in.&#8221; -Larry Wall<\/li>\n<li>Used to group expressions<\/li>\n<li>Makes syntax simple and consistent<\/li>\n<li>Most forms are (function args*)<\/li>\n<\/ul>\n<p><strong>But the Parentheses Aren&#8217;t a Big Deal<\/strong><\/p>\n<ul>\n<li>&#8220;Parentheses?  What parentheses? I haven&#8217;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&#8221; &#8211; Ken Tilton<\/li>\n<li>Editors indent automatically<\/li>\n<li>Emacs commands to balance and close parens<\/li>\n<li>Paredit (Emacs library) lets you manipulate sexps directly<\/li>\n<\/ul>\n<p><strong>Lisp Uses Symbols<\/strong><\/p>\n<ul>\n<li>Like variables but better<\/li>\n<li>Like pointers but less dangerous<\/li>\n<li>Assign a name to a value<\/li>\n<li>Values can be lots of things \u00e2\u20ac\u201c numbers, strings, functions, lists, other data structures<\/li>\n<\/ul>\n<p><strong>Lisp Has First Class Functions<\/strong><\/p>\n<ul>\n<li>Easy to define\n<ul>\n<li>(defun hello-world () (format t \u00e2\u20ac\u0153hello, world\u00e2\u20ac\u009d))<\/li>\n<\/ul>\n<\/li>\n<li>Can be passed as parameters<\/li>\n<li>Can be returned as values from other functions<\/li>\n<li>Anonymous functions too!<\/li>\n<\/ul>\n<p><strong>Lisp Has Flexible Parameters<\/strong><\/p>\n<ul>\n<li>Parameters can be optional, with defaults\n<ul>\n<li>(defun foo (a &amp;optional b) (list a b))<\/li>\n<\/ul>\n<ul>\n<li>(defun foo2 (a &amp;optional (b 10)) (list a b))<\/li>\n<\/ul>\n<\/li>\n<li>Parameter lists can be variable length\n<ul>\n<li>(defun + (&amp;rest numbers) \u00e2\u20ac\u00a6)<\/li>\n<\/ul>\n<\/li>\n<li>Keyword parameters\n<ul>\n<li>(defun foo3 (&amp;key a b) \u00e2\u20ac\u00a6)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Lisp Uses Pairs<\/strong><\/p>\n<ul>\n<li>Lists are chains of pairs<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-265\" title=\"list-1-2-3\" src=\"http:\/\/www.pchristensen.com\/blog\/wp-content\/uploads\/2008\/05\/list-1-2-3.png\" alt=\"\" width=\"202\" height=\"34\" \/><\/li>\n<li>Can make other trees, etc as well<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-264\" title=\"list-or-tree\" src=\"http:\/\/www.pchristensen.com\/blog\/wp-content\/uploads\/2008\/05\/list-or-tree.png\" alt=\"\" width=\"316\" height=\"148\" srcset=\"http:\/\/pchristensen.com\/wp-content\/uploads\/2008\/05\/list-or-tree.png 316w, http:\/\/pchristensen.com\/wp-content\/uploads\/2008\/05\/list-or-tree-300x140.png 300w\" sizes=\"auto, (max-width: 316px) 100vw, 316px\" \/>\n<ul>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/beyond-lists-other-uses-for-cons-cells.html\" target=\"_blank\">Beyond Lists: Other Uses for Cons Cells<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Lisp Uses Lists<\/strong><\/p>\n<ul>\n<li>&#8220;It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures.&#8221; &#8211; Alan J. Perlis<\/li>\n<li>Tons of functions for manipulating lists\n<ul>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/they-called-it-lisp-for-a-reason-list-processing.html\" target=\"_blank\">They Call It LISP For A Reason: List Processing<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Useful for recursive definitions<\/li>\n<li>Lists aren\\&#8217;t perfect so&#8230;<\/li>\n<\/ul>\n<p><strong>Lisp Has More Than Just Lists<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/collections.html\" target=\"_blank\">Collections<\/a><\/li>\n<li>Vectors \u00e2\u20ac\u201c fixed size sequences<\/li>\n<li>Arrays \u00e2\u20ac\u201c can be multidimensional, resizable<\/li>\n<li>Sequence functions on collections \u00e2\u20ac\u201c COUNT, FIND, POSITION, REMOVE, SUBSTITUTE, etc<\/li>\n<li>This is one place where syntax would help<\/li>\n<li>(aref a 5) instead of a[5]<\/li>\n<\/ul>\n<p><strong>Lisp Does Lots More<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/files-and-file-io.html\" target=\"_blank\">File and File I\/O<\/a><\/li>\n<li>Advanced object system using generic functions and message passing<\/li>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/a-few-format-recipes.html\" target=\"_blank\">Text formatting<\/a><\/li>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/loop-for-black-belts.html\" target=\"_blank\">Fancy iteration constructs<\/a><\/li>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/beyond-exception-handling-conditions-and-restarts.html\" target=\"_blank\">Conditions and restarts<\/a><\/li>\n<li>Libraries for other things<\/li>\n<\/ul>\n<p><strong>Lisp Has Lots of Free Online Resources<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/homepage.mac.com\/svc\/CommonLispFirstContact\/CommonLispFirstContact.pdf\" target=\"_blank\">Common Lisp: First Contact<\/a><\/li>\n<li><a href=\"http:\/\/www.cs.cmu.edu\/~dst\/LispBook\/index.html\" target=\"_blank\">A Gentle Introduction to Symbolic Computation<\/a> (<a href=\"http:\/\/www.amazon.com\/o\/asin\/0805304924\/pchristense03-20\" target=\"_blank\">buy dead tree copy<\/a>)<a href=\"http:\/\/www.cs.cmu.edu\/~dst\/LispBook\/index.html\" target=\"_blank\"><br \/>\n<\/a><\/li>\n<li><a href=\"http:\/\/mitpress.mit.edu\/sicp\/full-text\/book\/book.html\" target=\"_blank\">Structure and Interpretation of Computer Programs<\/a> (<a href=\"http:\/\/www.amazon.com\/o\/asin\/0262011530\/pchristense03-20\" target=\"_blank\">buy dead tree copy<\/a>)<a href=\"http:\/\/mitpress.mit.edu\/sicp\/full-text\/book\/book.html\" target=\"_blank\"><br \/>\n<\/a><\/li>\n<li><a href=\"http:\/\/gigamonkeys.com\/book\/\" target=\"_blank\">Practical Common Lisp<\/a> (<a href=\"http:\/\/www.amazon.com\/o\/asin\/1590592395\/pchristense03-20\" target=\"_blank\">buy dead tree copy<\/a>)<\/li>\n<li><a href=\"http:\/\/www.bookshelf.jp\/texi\/onlisp\/onlisp.html\" target=\"_blank\">OnLisp<\/a> (<a href=\"http:\/\/www.amazon.com\/o\/asin\/0130305529\/pchristense03-20\" target=\"_blank\">buy dead tree copy<\/a>)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This is an HTML version of the slides from my &#8220;Lisp Basics and Idioms&#8221; presentation at the Chicago Lisp User Group&#8217;s Intro to Lisp Workshop. It&#8217;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&#8217;s the sneak [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[9],"tags":[],"class_list":["post-263","post","type-post","status-publish","format-standard","category-lisp","entry"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pazgP-4f","jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":0,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}