If you are the kind of programmer who loves to get a lot done with computer coding, Lisp programming is going to be one of the most enjoyable experiences you’ll ever have with a computer.
With Common Lisp, you will do more with less effort than you would with other programming languages out there. Some computer geeks jokingly refer to Lisp as “the most brilliant way to abuse a computer”.
In order to understand what Lisp is all about, you need to know what a programming language is.
What is a Programming Language?
A programming language is a unique coded language that programmers use to create scripts and software programs. These scripts or programs are merely a set of instructions that direct a computer to do what the user wants.
For the programmer to feed these instructions to their computer, they need a medium of communication that both the user and the computer can understand – and a programming language is that medium.
The simplest programming language is the binary code which most computers can execute even in the absence of a translator program. However, programming with binary codes is quite tedious and complicated, hence the need for better computer languages such as Lisp.
What is Lisp?
The common Lisp definition is that it is a speech defect where individuals pronounce “s” as “th” and “th” as “z”. Interestingly, the dictionary Lisp meaning has got nothing to do with the naming of the programming language, which is a short form of List Processing.
In the programming world, Lisp refers to a genre of coded computer language that’s founded on functional calculus. It’s the best language for meta-programming apps since it stores and controls programs just like normal data.
Lisp Building Blocks
The first step in learning Lisp is understanding its building blocks. In a lisp program, there are three fundamental building blocks. These are an atom, string, and list.
An atom represents a chain of adjacent characters. These characters can be numbers, letters, or other unique characters such as # and *. A list refers to a series of atoms that are confined in parentheses, while a string is basically a cluster of characters inside double quotation marks.
How to Add Comment Lines
When adding a comment, use a semicolon to indicate it. For example,
(write-line “Hey everyone”) ; say Hi to everybody
; tell them where you are
(write-line “I’m in Washington”)
After adding the comment, press Ctrl+E to execute. You will get something like this:
I’m in Washington
Before you proceed to the next level, you should take note of the following points:
- Phrases in Lisp are case-sensitive.
- +,-,* and / are the most basic operations you can perform on numerical values.
- Lisp portrays function calls differently. For instance, f(x) will represented as (f x)
- Everything is evaluated in Lisp, except ”nil”, “t” and numbers. Letter “t” represents logical true, while “nil” represents an empty list or logical false.
Lisp code is evaluated in the following process:
1. Character strings are translated by the reader into s-expressions.
2. The structure of Lisp forms is defined by the evaluator. It is important to understand that Lisp forms are derived from s-expressions.
Lisp forms exist as atoms, empty lists, or any other lists whose first element is a symbol. Since the evaluator treats Lisp forms as arguments, you need to enclose your expressions in Parenthesis to get the right value.
In Lisp, a name can have any alphanumeric elements except a white space, quotation marks, semicolon, comma, parentheses, colon, backslash, and a vertical bar. If you want a name to have any of these characters, you must use the escape character (\).
You can also use digits in your name, but they must be accompanied by alphabets. Otherwise, your name will be treated as a number. Likewise, you can use periods, but they must be accompanied by alphanumerics.
Using Single Quotation Marks
Lisp doesn’t discriminate list elements or function arguments during evaluation. Therefore, whenever you don’t want your lists or atoms to be evaluated as function calls, ensure that they are preceded by single quotation marks.
Lisp is Always Changing with Time
Lisp is among the oldest programming languages. However, it has remained relevant by evolving into different dialects such as scheme and common Lisp.
Today, it remains an indispensable programming tool, especially in artificial intelligence (AI) coding.