{"id":2927,"date":"2022-10-20T09:14:01","date_gmt":"2022-10-20T03:44:01","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=2927"},"modified":"2022-10-20T09:14:01","modified_gmt":"2022-10-20T03:44:01","slug":"why-learn-lisp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2022\/10\/20\/why-learn-lisp\/","title":{"rendered":"Why Learn Lisp?"},"content":{"rendered":"<p>In the <a href=\"https:\/\/www.rangakrish.com\/index.php\/2022\/10\/06\/why-learn-prolog\/\" target=\"_blank\" rel=\"noopener\"><em><strong>last article<\/strong><\/em><\/a>, I had shared my views on why programmers should learn <em><strong>Prolog<\/strong><\/em>, preferably as the first language. What language should one learn next? I strongly pitch for <em><strong>Lisp<\/strong><\/em>, to be precise, <em><strong>\u201cCommon Lisp\u201d<\/strong><\/em>.<\/p>\n<p><em><strong>Lisp<\/strong><\/em> happens to be the second <em><strong>oldest<\/strong><\/em> (1958) programming language, only after <em><strong>Fortran<\/strong><\/em> (1957)! Initially there were several dialects of <em><strong>Lisp<\/strong><\/em>, but the <em><strong>Common Lisp<\/strong><\/em> standard was published in the year 1994. Now there are several <em><strong>Common Lisp<\/strong><\/em> implementations available.<\/p>\n<p>So, why should you learn <em><strong>Lisp<\/strong><\/em>? Before going into specifics, let me share a few delightful quotes about <em><strong>Lisp<\/strong><\/em>:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">Lisp has jokingly been called \u201cthe most intelligent way to misuse a computer.\u201d I think that description is a great compliment because it transmits the full flavour of liberation: it has assisted a number of our most gifted fellow humans in thinking previously impossible thoughts.<\/span><br \/>\n<span style=\"color: #333333;\">&#8211; Edsger Dijkstra [1]<\/span><\/p>\n<p><span style=\"color: #0000ff;\">Lisp is a programmable programming language. Not only can you program <em><strong>in<\/strong><\/em> Lisp \u2026 but you can program the language itself.\u201d<\/span><br \/>\n<span style=\"color: #333333;\">&#8211; John Foderaro [2]<\/span><\/p>\n<p><span style=\"color: #0000ff;\">\u201cThere is no real distinction between read-time, compile-time, and runtime. You can compile or run code while reading, read or run code while compiling, and read or compile code at runtime.\u201d<\/span><br \/>\n<span style=\"color: #0000ff;\"><span style=\"color: #333333;\">&#8211; Paul Graham [3]<\/span><\/span><\/p>\n<p><span style=\"color: #0000ff;\">\u201cLISP is worth learning for \u2026 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.\u201d<\/span><br \/>\n<span style=\"color: #333333;\">&#8211; Eric Raymond [4]<\/span><\/p><\/blockquote>\n<p>Let me now walk you through some key aspects of <em><strong>Lisp<\/strong><\/em>.<\/p>\n<h3>1) Easy to Get Started<\/h3>\n<p>It is quite easy to get started with <em><strong>Lisp<\/strong><\/em>. The language is built around <em><strong>\u201cS-Expressions\u201d<\/strong><\/em> and every expression has a value. Thus, the language is primarily a <em><strong>functional<\/strong><\/em> programming language and it doesn\u2019t take much effort to get the basics right. Of course, it will take a while to master the intricacies of advanced features of the language such as <em><strong>Macros<\/strong><\/em>, <em><strong>Condition System<\/strong><\/em> and <em><strong>Common Lisp Object System (CLOS)<\/strong><\/em>. Thanks to the <em><strong>\u201cRead-Eval-Print\u201d<\/strong><\/em> loop of the interactive <em><strong>Lisp<\/strong><\/em> interpreter, writing and testing the code is always a pleasure.<\/p>\n<h3>2) Homoiconic<\/h3>\n<p>The beauty of <em><strong>Lisp<\/strong><\/em> is that data is indistinguishable from code, in other words <em><strong>\u201ccode is data\u201d<\/strong><\/em>. This is possible thanks to <em><strong>S-Expression<\/strong><\/em> being the <em><strong>\u201cnative\u201d<\/strong><\/em> data structure of the language. Since both code and data are legitimate <em><strong>S-Expressions<\/strong><\/em>, code can be <em><strong>\u201cinspected\u201d<\/strong><\/em> as data and data <em><strong>\u201cevaluated\u201d<\/strong><\/em> as code!<\/p>\n<h3>3) Language of Artificial Intelligence<\/h3>\n<p>John McCarthy created <em><strong>Lisp<\/strong><\/em> in 1958 (influenced by <em><strong>Lambda Calculus<\/strong><\/em> of Alonzo Church) and since its initial days, it has been the primary language used in <em><strong>Artificial Intelligence<\/strong><\/em> research. <em><strong>Lisp<\/strong><\/em> has been successfully used in various areas including <em><strong>Natural Language Processing<\/strong><\/em>, <em><strong>Computer Vision<\/strong><\/em>, <em><strong>Planning<\/strong><\/em>, and <em><strong>Rule-based Engines<\/strong><\/em> (e.g. Medical Expert Systems). Even today, while languages such as <em><strong>Python<\/strong><\/em> are predominantly used in the <em><strong>Machine Learning<\/strong><\/em> and <em><strong>Deep Learning<\/strong><\/em> space, there are libraries and tools enabling <em><strong>Lisp<\/strong><\/em> to be used as well.<\/p>\n<h3>4) Multiparadigm<\/h3>\n<p><em><strong>Lisp<\/strong><\/em>, at its core, is <em><strong>functional<\/strong><\/em> and <em><strong>object-oriented<\/strong><\/em>. It also supports <em><strong>procedural<\/strong><\/em> paradigm like other languages. Although it is not <em><strong>declarative<\/strong><\/em> in the sense of <em><strong>Prolog<\/strong><\/em>, because of its <em><strong>homoiconicity<\/strong><\/em> and <em><strong>\u201cmalleable\u201d<\/strong><\/em> nature, it is easy to implement <em><strong>Prolog<\/strong><\/em> (with <em><strong>\u201cLispy\u201d<\/strong><\/em> syntax) and then write code in this embedded <em><strong>Prolog<\/strong><\/em>. In fact, both <a href=\"https:\/\/franz.com\/products\/allegro-common-lisp\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Allegro Lisp<\/strong><\/em><\/a> and <a href=\"http:\/\/www.lispworks.com\/products\/lispworks.html\" target=\"_blank\" rel=\"noopener\"><em><strong>LispWorks Lisp<\/strong><\/em><\/a> support such a <em><strong>Prolog<\/strong><\/em> implementation. It is really fun to take advantage of these ideas when writing non-trivial <em><strong>Lisp<\/strong><\/em> code.<\/p>\n<h3>5) Higher-Order Programming<\/h3>\n<p>Functions are <em><strong>\u201cfirst class\u201d<\/strong><\/em> objects (just as data are) in <em><strong>Lisp<\/strong><\/em>. It is possible to pass functions as parameters to other functions and also return functions from other functions. This ability allows the programmer to write <em><strong>generic functions<\/strong><\/em> whose behaviour can be fine-tuned by passing suitable execution logic. Some examples are the popular <em><strong>Map<\/strong><\/em> and <em><strong>Reduce<\/strong><\/em> operations.<\/p>\n<h3>6) Magnificent Macros<\/h3>\n<p>If there is one thing that excites most <em><strong>Lisp<\/strong><\/em> programmers, it must be the <em><strong>macros<\/strong><\/em>. <em><strong>Macros<\/strong><\/em> elevate <em><strong>Lisp<\/strong><\/em> to a <em><strong>\u201cprogrammable\u201d<\/strong><\/em> programming language. <em><strong>\u201cRead macros\u201d<\/strong> <\/em>allow code to be run at read time (allowing the syntax to be extended), while regular macros allow code to be generated and executed at run time. With such unparalleled flexibility and power, it is almost trivial to embed a complete <em><strong>Domain Specific Language (DSL)<\/strong><\/em> inside Lisp!<\/p>\n<h3>7) Powerful Condition System<\/h3>\n<p>The <em><strong>Condition System<\/strong><\/em> shares some common features with the <em><strong>Exception Handling<\/strong><\/em> model supported in modern programming languages, but it is far more elegant and powerful! The conventional approach involves two parts namely, <em><strong>\u201csignaling\u201d<\/strong><\/em> an error and <em><strong>\u201chandling\u201d<\/strong><\/em> it. No doubt, this definitely provides the much needed <em><strong>\u201cseparation of concerns\u201d<\/strong><\/em> and keeps the code reasonably clean. What is unique about <em><strong>Lisp<\/strong><\/em> is that there is a <em><strong>\u201cthird\u201d<\/strong><\/em> part in this scenario. It is called <em><strong>\u201crestart\u201d<\/strong><\/em> and gives the programmer an additional level of flexibility in recovering from the error. The details are beyond the scope of this article. I strongly recommend the book by <em><strong>Micha\u0142 Herda<\/strong><\/em> [5] to interested readers.<\/p>\n<p>What about availability of high quality implementations of <em><strong>Common Lisp<\/strong><\/em>? <a href=\"https:\/\/www.sbcl.org\" target=\"_blank\" rel=\"noopener\"><em><strong>SBCL<\/strong><\/em><\/a> is a popular open source implementation available on many platforms. <a href=\"https:\/\/franz.com\/products\/allegro-common-lisp\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Allegro CL<\/strong><\/em><\/a> and <a href=\"http:\/\/www.lispworks.com\/products\/lispworks.html\" target=\"_blank\" rel=\"noopener\"><em><strong>Lispworks Lisp<\/strong><\/em><\/a> are two respected commercial implementations. As my readers might be aware, I have been using these two for many years and I am quite happy with them.<\/p>\n<p>Is <em><strong>Lisp<\/strong><\/em> being used anywhere? The popular <a href=\"https:\/\/www.autodesk.com\/products\/autocad\/overview\" target=\"_blank\" rel=\"noopener\"><em><strong>AutoCAD<\/strong><\/em><\/a> program uses <em><strong>AutoLisp<\/strong><\/em>, a custom dialect of Lisp. Another well-known application is <a href=\"https:\/\/www.gnu.org\/software\/emacs\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Emacs<\/strong><\/em><\/a> Text Editor, which uses <em><strong>Emacs Lisp<\/strong><\/em>. <a href=\"https:\/\/opusmodus.com\" target=\"_blank\" rel=\"noopener\"><em><strong>Opusmodus<\/strong><\/em><\/a> is a powerful <em><strong>Music Composition<\/strong><\/em> system written entirely in <em><strong>Lisp<\/strong><\/em>. I have written several <a href=\"https:\/\/www.rangakrish.com\/index.php\/category\/music\/\" target=\"_blank\" rel=\"noopener\"><em><strong>articles<\/strong><\/em><\/a> on it. A list of companies\/applications that use <em><strong>LispWorks Lisp<\/strong><\/em> appears <a href=\"http:\/\/www.lispworks.com\/success-stories\/index.html\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>. Likewise, companies that use <em><strong>Allegro CL<\/strong><\/em> are mentioned <a href=\"https:\/\/franz.com\/success\/\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>. <a href=\"https:\/\/lisp-journey.gitlab.io\/who\/\" target=\"_blank\" rel=\"noopener\"><em><strong>This<\/strong><\/em><\/a> is another interesting list.<\/p>\n<p>I hope I have managed to pique your curiosity about <em><strong>Lisp<\/strong><\/em>. Needless to say, <em><strong>Lisp<\/strong><\/em> is my favourite language and I even managed to embed it in my <a href=\"https:\/\/www.kpastrosoftware.com\" target=\"_blank\" rel=\"noopener\"><em><strong>Astrology software<\/strong><\/em><\/a>, giving users the ability to write scripts to perform advanced analysis of charts.<\/p>\n<p>I can assure you that once you start, you will find programming in <em><strong>Lisp<\/strong><\/em> an exhilarating experience!<\/p>\n<p>Have a great week and a wonderful weekend!<\/p>\n<h3 style=\"text-align: center;\">References<\/h3>\n<p>1) Eugene Charniak, Christopher K.Riesbeck, Drew V.McDermott, and James R.Meehan, \u201cArtificial Intelligence Programming (2nd Edition)\u201d, Lawrence Erlbaum Associates, 1987.<br \/>\n2) Communications of the ACM, September 1991.<br \/>\n3) Paul Graham, <a href=\"http:\/\/www.paulgraham.com\/diff.html\" target=\"_blank\" rel=\"noopener\"><em><strong>\u201cWhat Made Lisp Different\u201d<\/strong><\/em><\/a><br \/>\n4) Eric Raymond, <a href=\"http:\/\/www.catb.org\/~esr\/faqs\/hacker-howto.html\" target=\"_blank\" rel=\"noopener\"><em><strong>\u201cHow to Become a Hacker\u201d<\/strong><\/em><\/a><br \/>\n5) Micha\u0142 \u201cphoe\u201d Herda, \u201cThe Common Lisp Condition System: Beyond Exception Handling with Control Flow Mechanisms\u201d, Apress, 2020.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last article, I had shared my views on why programmers should learn Prolog, preferably as the first language. What language should one learn next? I strongly pitch for Lisp, to be precise, \u201cCommon Lisp\u201d. Lisp happens to be the second oldest (1958) programming language, only after Fortran (1957)! Initially there were several dialects [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,17],"tags":[337,110,338,19,37],"class_list":["post-2927","post","type-post","status-publish","format-standard","hentry","category-lisp","category-programming","tag-autocad","tag-common-lisp","tag-emacs","tag-lisp","tag-opusmodus"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-Ld","jetpack-related-posts":[{"id":41,"url":"https:\/\/www.rangakrish.com\/index.php\/2015\/10\/08\/learning-lisp-resources\/","url_meta":{"origin":2927,"position":0},"title":"Learning LISP &#8211; Resources","author":"admin","date":"October 8, 2015","format":false,"excerpt":"During my talks on Lisp Programming, I am invariably asked to suggest good books to start learning the language. Here is a (partial) list that I readily recommend. Beginner Level: ANSI Common Lisp, Paul Graham, Prentice Hall, 1996. Common LISP: A Tutorial, Wendy L.Milner, Prentice Hall, 1988. Land of LISP:\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2200,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/11\/08\/book-review-the-common-lisp-condition-system-beyond-exception-handling-with-control-flow-mechanisms\/","url_meta":{"origin":2927,"position":1},"title":"Book Review &#8211; The Common Lisp Condition System: Beyond Exception Handling with Control Flow Mechanisms.","author":"admin","date":"November 8, 2020","format":false,"excerpt":"Title: The Common Lisp Condition System: Beyond Exception Handling with Control Flow Mechanisms Author: Micha\u0142 \"phoe\" Herda Publisher: Apress Year: 2020 Unlike with other languages, it is rare to find new books being published on Lisp. The last book on Lisp, which I purchased was \u201cCommon Lisp Recipes\u201d\u00a0\u00a0by Edmund Weitz\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/11\/Cover-page-209x300.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3312,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/01\/28\/the-hy-programming-language\/","url_meta":{"origin":2927,"position":2},"title":"The Hy Programming Language","author":"admin","date":"January 28, 2024","format":false,"excerpt":"In an earlier article\u00a0I had explained how to execute Python code from within Common Lisp using \u201cCLPython\u201d package. In contrast to that approach, \u201cHy\u201d\u00a0is a Lisp-style language (not compatible with Common Lisp) that is embedded in Python and hence provides seamless interoperability with Python code. Installation is straightforward (it is\u2026","rel":"","context":"In &quot;Hy Language&quot;","block_context":{"text":"Hy Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/hy-language\/"},"img":{"alt_text":"Hy REPL","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/01\/console-300x148.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3555,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/11\/22\/multiobjective-optimization-moo-in-lisp-and-prolog\/","url_meta":{"origin":2927,"position":3},"title":"Multiobjective Optimization (MOO) in Lisp and Prolog","author":"admin","date":"November 22, 2024","format":false,"excerpt":"Recently I came across a nice article\u00a0by Jose Crespo, where the author stresses that the future of programming revolves around the application of math concepts such as Functor, Monads, Folds, etc. In addition, he argues that familiarity with C\/C++ is essential in this modern AI age. The author goes through\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"Lisp Code for Pareto Front","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/11\/lisp-code-249x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2377,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/04\/12\/book-review-programming-algorithms-in-lisp\/","url_meta":{"origin":2927,"position":4},"title":"Book Review: Programming Algorithms in Lisp","author":"admin","date":"April 12, 2021","format":false,"excerpt":"Title: Programming Algorithms in Lisp: Writing Efficient Programs with Examples in ANSI Common Lisp Author: Vsevolod Domkin Publisher: Apress Year: 2021 It is only about 5 months since I read and reviewed\u00a0a good book on Lisp written by Micha\u0142 \u201cphoe\u201d Herda. The present book is by Vsevolod Domkin\u00a0and I purchased\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/04\/Book-Cover-209x300.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":190,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/03\/15\/book-review-common-lisp-recipes-by-edi-weitz\/","url_meta":{"origin":2927,"position":5},"title":"Book Review: Common Lisp Recipes &#8211; A Problem-Solution Approach","author":"admin","date":"March 15, 2016","format":false,"excerpt":"Last Saturday (March 12, 2016), I got my most eagerly awaited book from Amazon.com. Yes, I am talking about Common Lisp Recipes: A Problem-Solution Approach\u00a0authored by Dr.Edmund Weitz. Of course, if you have been programming in Lisp for a couple of years, you would have definitely heard of Dr.Edi Weitz,\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=2927"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2927\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=2927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=2927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=2927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}