What Made Lisp Special

«The greatest programming language ever created«
— Alan Kay, "on Lisp"

What Made Lisp Special

When McCarthy developed Lisp in the late 1950s, it was radically different from existing languages, the most notable of which was Fortran.

Lisp embodied nine new ideas:

1. Conditional statements (Conditionals). Conditional statements are the if-then-else constructs. We take them for granted now. They were invented by McCarthy during the development of Lisp. (At that time, Fortran only had goto statements, closely tied to the branching instruction on the underlying hardware.) McCarthy, being on the Algol committee, introduced conditional statements to Algol, from which they spread to other languages.

2. Functional types (A function type). In Lisp, functions are first-class objects — they are a data type, just like numbers, strings, etc., have a literal representation, can be stored in variables, can be passed as arguments, and so on.

3. Recursion (Recursion). Recursion, of course, existed as a mathematical concept before Lisp, but Lisp was the first programming language to support it. (This is possibly implied in the creation of functions as first-class objects.)

4. A new concept of variables (A new concept of variables). In Lisp, all variables are effectively pointers. Values are what types have, not what variables have, and assigning or binding variables means copying pointers, not what they point to.

5. Garbage collection (Garbage-collection).

6. Programs composed of expressions (Programs composed of expressions). Programs in Lisp are trees of expressions, each returning a value. (Some Lisp expressions can return multiple values.) This contrasts with Fortran and many other successful languages that distinguish between "expressions" and "statements."

It was natural to have such a distinction in Fortran because the language was linearly oriented (not surprising for a language where the input format was punch cards). You could not have nested statements. And while you needed mathematical expressions to work, there was little sense in forcing anything else to return a value because there might not be anything that expected a return.

The limitations were lifted with the advent of block-structured languages, but by then it was too late. The distinction between expressions and statements had already been established. It transitioned from Fortran to Algol and then to their descendants.

When a language is made entirely of expressions, you can compose expressions as you wish. You can write either (using the syntax Arc)

(if foo (= x 1) (= x 2))

or

(= x (if foo 1 2))

7. Symbol type. Symbols differ from strings; in this case, you can check for equality by comparing pointers.

8. Notation for code using trees of symbols.

9. The whole language always available. There is no explicit difference between read time, compile time, and run time. You can compile or run code while reading, or read or run code while compiling, or read or compile code during execution.

Running code while reading allows users to reprogram the syntax of Lisp; running code during compilation is the basis for macros; compiling at runtime is the foundation for using Lisps as an extension language in programs like Emacs; and finally, reading during execution allows programs to interact using s-expressions, a concept recently reimagined in XML.

Conclusion

When Lisp was first invented, all these ideas were far from the standard programming practices dictated by the hardware available in the late 1950s.

Over time, the default language, embodied in the success of popular languages, has gradually evolved towards Lisp. Points 1-5 are now widely spread. Point 6 is beginning to appear in the mainstream. In Python, there is some form of point 7, although there is no suitable syntax. Point 8, which (with point 9) makes macros possible in Lisp, still exists only in Lisp, perhaps because (a) it requires those parentheses or something equally cumbersome, and (b) if you add this last power increase, you can no longer claim to have invented a new language, only to have developed a new dialect of Lisp; -)

While it's useful for modern programmers, it's strange to describe Lisp in terms of its differences from random practices adopted in other languages. Perhaps this is not what McCarthy intended. Lisp was not designed to correct Fortran's errors; it emerged more as a byproduct of an attempt to axiomatize computation.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster