August 5, 2018

The Dawn of Lisp

Lisp defined in terms of Lisp: Maxwell's Equations of Software

  • By Alan Kay

I am following this Youtube video called The Dawn of Lisp, or how to write Eval and Apply in Clojure. The idea of this post is to summarize my findings about the lecture, however if you need more details I highly recommend you to watch the full lecture.

Summary

  • Lisp is very concise
  • The history of the language seems pretty interesting. John McCarthy was an innovator in several regards.
  • The language is powerful and that brings the question: Why its not a mainstream language?
  • Why all of the sudden Lisp (FP in general) got so much attention from the community?

Clojure's eval & apply

  • Eval and Apply are the only two functions you need to write LISP as afunction of itself. We are going to explore more the interconnections.
  • One of the main differences of eval in Lisp comparing to other languagesis that you need to inform a valid data structure to eval:
(eval '(+ 2 2)) => 4
  • I am looking at the whole code for the Lisp 1.5 implementation in Clojure. What is intriguing is the relationship between eval and apply.
    • I still don't fully got it. I will keep visiting this implementation as I acquire knowledge of how Lisp works.

Rules for Converting the LISP 1.5 specification to clojure

  • Convert all M-expressions into S-expressions
  • Make definitions as similar as possible to the original
  • Eliminate the use of dotted pairs
  • All global identifiers have a "$" prefix
  • Added whitespace for sake of legibility

Some examples of the above rules:

  • M-expressions to S-expressions
    • F[1;2;3] to (F 1 2 3)
    • [X < 0 -> X; T -> X] to (COND ((< X 0) (-> X)) (T X))

Glossary


  1. CAR: Contents of the Address part of Register number
  2. CDR: Contents of the Decrement part of Register number
  3. Memory cell: cons cell

Register has not the same meaning as today, place in CPU to store data to fast access, the meaning at McCarthy's time is more like Memory location. The best defition of register would be word that is the natural unit of data used by a particular processor desing.

I will let a TODO mark in this post because I need to read more material about how the MEMORY works in computers. I will after update with the proper links.

Conclusion

From my academic background and all the work I did while in University, I have a good curiosity about challenging topics. Lisp is definitely one of them, I have developed a process by which I learn how my subject is working.

I need to have a good grasp of what I am looking at, why, how and where we are today? In order to answer my own questions, I need to read a lot of material, sometimes two or three times. I need to understand...

My previous experiences tells me that the beginning of every subject I had researched was very confusing, I couldn't sometimes sleep well... How can I not understand this concept? I need to read something yet more fundamental... ok, let's try something more practical now... ok. Let's start all over again.

The process is not easy, never was, but the payoff has been tremendous.

List for the future:

  1. The Roots of Lisp by Paul Graham
  2. A conversation with Alan Kay the creator of SmallTalk.
  3. History of Lisp by John McCarthy the creator of Lisp.
Tags: clojure lisp