Lisp
Lisp (LISt Processing) was created by John McCarthy in 1958, and it is the language that introduced most ideas we now call functional: functions as values, recursion, garbage collection and conditional expressions. Its unusual syntax is a direct consequence of one design choice: programs are written as lists.
Paradigm: Functional Programming
What Makes Lisp Special
- S-expressions. Everything is a list in parentheses.
(+ 1 2 3)means "call+with three arguments". Function call and data share one notation. - Code is data (homoiconicity). A program is a list a program can build and transform. That makes macros natural.
- Macros. A macro receives code as data and returns new code before evaluation, so you can add new control structures to the language yourself.
- Interactive development. The REPL lets you define and change functions in a running program, and Common Lisp systems keep that workflow for years-long sessions.
- A family of dialects. Common Lisp is large and industrial, Scheme is small and elegant, Clojure targets the JVM, and Emacs Lisp scripts the Emacs editor.
Example: Recursion, higher-order functions and a macro
;; A recursive function
(defun factorial (n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
(print (factorial 20)) ; 2432902008176640000
(print (mapcar #'factorial '(1 2 3 4 5))) ; (1 2 6 24 120)
;; A macro: new syntax built from ordinary list operations
(defmacro my-unless (test &body body)
`(if ,test nil (progn ,@body)))
(my-unless (> 1 2)
(print "one is not greater than two"))
How It Works
factorialis defined with oneifexpression that returns a value, with no statements or loops.mapcarapplies a function to each element of a list.#'factorialpasses the function itself as a value.- The
my-unlessmacro builds the list(if test nil (progn ...))using the backquote template and returns it as code. - A user-written macro looks exactly like a built-in form, which is the practical meaning of "programmable programming language".
History and Where It Is Used
Lisp dialects power Emacs, AutoCAD extensions, symbolic AI research, and quantitative finance, while Clojure runs large data-driven services. Common Lisp implementations such as SBCL are fast, and Practical Common Lisp is a free book that teaches the language with real projects.