Gerald Jay Sussman: We Really Dont Know How To Compute! 12/06/22
As noted by Sussman, Lisp is great because it has uniform representation of programs as data.
Abstract Syntax Trees are in fact a representation of a program as a tree data structure.
JS libraries like acorn or astring make you realize that one can generate code and create Domain Specific Languages in very straightforward manner. Our languages have become quite broad, multi-purpose and general to accommodate various needs.
Today, what we're missing is not better tooling and more language features, but more domain-specific languages (Martin, 2018).
A few things are needed to write a programming language:
- A grammer for the language.
- A Lexer and Parser
- Functions which tell the parser how to turn grammer into an Abstract Syntax Tree (AST)
- For an interperted lanauage, an interperter is needed.
- For a compiled language, one can generate Intermediate Representation (IR) and use LLVM for compilation.
Then, to compile some source code:
- The lexer turns my source into tokens
- The parser turns tokens into AST
- The compiler turns AST into IR, and dumps it to a file
- I use the
llc
tool to compile from IR to an object file - I use
gcc
to compile that file into an executable
References:
- Martin, Robert Cecil. Clean Code. Apogeo, 2018.
Notes from Sussman's lecture:
- Computing is now cheap (7:04).
- Human genome weighs less than a 1GB.
- Decisions we made early on prevent us from changing the system.
- Lisp is great because it has uniform representation of programs as data (14:59)
- Math notation is awful and impressionistic
- Lambda calculus works for electrical engineering too (28:50)
- If you have the name of the spirit - you have power over it.
- The propagator idea.
- Truth Maintenance System.
- Our problem as engineers is not correctness but evolvability.
- Degeneracy is the ability to do something in various ways (e.g. if you're allergic to peanuts, there are other means to acquire your calories, by eating different types of food).