Why is Lisp such a good language for AI?



I've heard before from computer scientists and from researchers in the area of AI that that Lisp is a good language for research and development in artificial intelligence. Does this still apply, with the proliferation of neural networks and deep learning? What was their reasoning for this? What languages are current deep-learning systems currently built in?

J. Antonio Perez

Posted 2016-10-31T03:38:07.027

Reputation: 559



First, I guess that you mean Common Lisp (which is a standard language specification, see its HyperSpec) with efficient implementations (à la SBCL). But some recent implementations of Scheme could also be relevant (with good implementations such as Bigloo or Chicken/Scheme). Both Common Lisp and Scheme (and even Clojure) are from the same Lisp family. And as a scripting language driving big data or machine learning applications, Guile might be a useful replacement to Python and is also a Lisp dialect. BTW, I do recommend reading SICP, an excellent introduction to programming using Scheme.

Then, Common Lisp (and other dialects of Lisp) is great for symbolic AI. However, many recent machine learning libraries are coded in more mainstream languages, for example TensorFlow is coded in C++ & Python. Deep learning libraries are mostly coded in C++ or Python or C (and sometimes using OpenCL or Cuda for GPU computing parts).

Common Lisp is great for symbolic artificial intelligence because:

  • it has very good implementations (e.g. SBCL, which compiles to machine code every expression given to the REPL)
  • it is homoiconic, so it is easy to deal with programs as data, in particular it is easy to generate [sub-]programs, that is use meta-programming techniques.
  • it has a Read-Eval-Print Loop to ease interactive programming
  • it provides a very powerful macro machinery (essentially, you define your own domain specific sublanguage for your problem), much more powerful than in other languages like C.
  • it mandates a garbage collector (even code can be garbage collected)
  • it provides many container abstract data types, and can easily handle symbols.
  • you can code both high-level (dynamically typed) and low-level (more or less startically typed) code, thru appropriate annotations.

However most machine learning & neural network libraries are not coded in CL. Notice that neither neural network nor deep learning is in the symbolic artificial intelligence field. See also this question.

Several symbolic AI systems like Eurisko or CyC have been developed in CL (actually, in some DSL built above CL).

Notice that the programming language might not be very important. In the Artificial General Intelligence research topic, some people work on the idea of a AI system which would generate all its own code (so are designing it with a bootstrapping approach). Then, the code which is generated by such a system can even be generated in low level programming languages like C. See J.Pitrat's blog, which has inspired the RefPerSys project.

Basile Starynkevitch

Posted 2016-10-31T03:38:07.027

Reputation: 577

1I'd like to add here, that tensorflow and theano are based on computational graphs, which is actually symbolic programming, but within imperative language. – Maxim – 2017-10-09T09:50:43.367


David Nolen (contributor to Clojure and ClojureScript; creator of Core Logic a port of miniKanren) in a talk called LISP as too powerful stated that back in his days LISP was decades ahead of other programming languages. There are number of reasons why the language wasn't able to maintain it's name.

This article highlights som key points why LISP is good for AI

  • Easy to define a new language and manipulate complex information.
  • Full flexibility in defining and manipulating programs as well as data.
  • Fast, as program is concise along with low level detail.
  • Good programming environment (debugging, incremental compilers, editors).

Most of my friends into this field usually use Matlab for Artificial Neural Networks and Machine Learning. It hides the low level details though. If you are only looking for results and not how you get there, then Matlab will be good. But if you want to learn even low level detailed stuff, then I will suggest you go through LISP at-least once.
Language might not be that important if you have the understanding of various AI algorithms and techniques. I will suggest you to read "Artificial Intelligence: A Modern Approach (by Stuard J. Russell and Peter Norvig". I am currently reading this book, and it's a very good book.


Posted 2016-10-31T03:38:07.027

Reputation: 1 890


AI is a wide field that goes far beyond machine learning, deep learning, neural networks, etc. In some of these fields, the programming language does not matter at all (except for speed issues), so LISP would certainly not be a topic there.

In search or AI planning, for instance, standard languages like C++ and Java are often the first choice, because they are fast (in particular C++) and because many software projects like planning systems are open source, so using a standard language is important (or at least wise in case one appreciates feedback or extensions). I am only aware of one single planner that is written in LISP. Just to give some impression about the role of the choice of the programming language in this field of AI, I'll give a list of some of the best-known and therefore most-important planners:

description: the probably best-known classical planning system
URL: http://www.fast-downward.org/
language: C++, parts (preprocessing) are in Python

description: together with Fast-Downward the classical planning system everyone knows
URL: https://fai.cs.uni-saarland.de/hoffmann/ff.html
language: C

description: one of the best-known partial-order causal link (POCL) planning systems
URL: http://www.tempastic.org/vhpop/
language: C++

description: the best-known HTN (hierarchical) planning system
URL: https://www.cs.umd.edu/projects/shop/
language: there are two versions of SHOP and SHOP2. The original versions have been written in LISP. Newer versions (called JSHOP and JSHOP2) have been written in Java. Pyshop is a further SHOP variant written in Python.

description: another well-known HTN (and hybrid) planning system
URL: http://www.uni-ulm.de/en/in/ki/research/software/panda/panda-planning-system/
language: there are different versions of the planner: PANDA1 and PANDA2 are written in Java, PANDA3 is written primarily in Java with some parts being in Scala.

These were just some of the best-known planning systems that came to my mind. More recent ones can be retrieved from the International Planning Competitions (IPCs, http://www.icaps-conference.org/index.php/Main/Competitions), which take place every two years. The competing planners' codes are published open source (for a few years).


Posted 2016-10-31T03:38:07.027

Reputation: 190