Lesson plan
Code as data
In computer science, the expression code as data refers to the idea that source code written in a programming language can be manipulated as data, such as a sequence of characters or an abstract syntax tree (AST), and it has an execution semantics only in the context of a given compiler or interpreter. The notion is often used in the context of Lisp-like languages that use S-expressions as their main syntax, as writing programs using nested lists of symbols makes the interpretation of the program as an AST quite transparent (a property known as homoiconicity). These ideas are generally used in the context of what is called metaprogramming, writing programs that treat other programs as their data. For example, code-as-data allows the serialization of first-class functions in a portable manner. Another use case is storing a program in a string, which is then processed by a compiler to produce an executable. More often there is a reflection API that exposes the structure of a program as an object within the language, reducing the possibility of creating a malformed program. In computational theory, Kleene's second recursion theorem provides a form of code-is-data, by proving that a program can have access to its own source code. Code-as-data is also a principle of the Von Neumann architecture, since stored programs and data are both represented as bits in the same memory device.…
Article summary
In computer science, the expression code as data refers to the idea that source code written in a programming language can be manipulated as data, such as a sequence of characters or an abstract syntax tree (AST), and it has an execution semantics only in the context of a given compiler or interpreter. The notion is often used in the context of Lisp-like languages that use S-expressions as their main syntax, as writing programs using nested lists of symbols makes the interpretation of the program as an AST quite transparent (a property known as homoiconicity). These ideas are generally used in the context of what is called metaprogramming, writing programs that treat other programs as their data. For example, code-as-data allows the serialization of first-class functions in a portable manner. Another use case is storing a program in a string, which is then processed by a compiler to produce an executable. More often there is a reflection API that exposes the structure of a program as an object within the language, reducing the possibility of creating a malformed program. In computational theory, Kleene's second recursion theorem provides a form of code-is-data, by proving that a program can have access to its own source code. Code-as-data is also a principle of the Von Neumann architecture, since stored programs and data are both represented as bits in the same memory device.…
Key claims
No claims recorded.
Discussion questions
- Summarise the article in your own words. Which single claim would you verify first, and why?
- Which claim in this article is most likely to be revised as the sources update? How would you check its current status?
- If two sources disagreed about one of these facts, what would you need in order to trust one over the other?
Bibliography
No sources recorded.
Key claims and bibliography are generated from the same tracked claims and sources as the article page.