Create Your Own Programming Language (Allie Duncan)

Lecture PowerPoint (with in-class activities included):

Lecture.pptx
Lecture Notes

*Lecture notes:

Readings:

How To Create Your Own Freaking Awesome Programming Language by Marc-André Cournoyer

Reading Questions:

(Focuses more on the esoteric points of the reading while the lecture covered the bread-and-butter understanding)

Why do most languages write their own parser?

    1. What does the lexer produce?

    2. In our framework, what does the parser output?

    3. What is the most widely used parser?

    4. When creating a parser, what is easy to err?

    5. What three factors must be considered when designing a runtime?

    6. What is the name of the compilation method used in most dynamic languages today (hint: the source code is compiled to machine or byte code on the fly)?

    7. Why would we use a VM?

    8. What does byte-code consist of?

    9. What does homoiconicity mean?

    10. Why is homoiconicity important?

    11. What is self-hosting?

Reading Solutions:

    1. The parser yields a tree of nodes.

    2. The lexer outputs tokens.

    3. YACC is the most widely used parser.

    4. A dangerous snare of parsers is operator precedence.

    5. Language designers write their own parsers becuase the resulting language is not only faster but also has improved error reporting.

    6. Speed, Flexibility, and memory footprint are main factors in runtime design.

    7. This is called JIT (Just In Time) Compilation.

    8. Using a VM makes the program run faster.

    9. Byte-code consists of instructions: opcode followed by operands.

    10. Homoiconicity means that the primary representation of your program is accessible as a data structure inside the run time of the language.

    11. Homoiconicity is important because it lets us inspect and modify the program as it's running.

    12. Self-hosting is where the interpreter is implemented in the target language itself.

Quiz Questions:

    1. What are the four parts that compose most dynamic languages?

    2. Tokenize the statement "if 1"

    3. How does the functional model, used by Lisp and Racket, treat computations?

    4. What is the downside of self hosting?

Quiz Solutions:

    1. Dynamic languages are composed of a lexer, a parser, an interpreter, and a runtime.

    2. [ID if][variable x]

    3. The functional model treats computation as the evaluation of mathematical functions and avoids state and mutable data. This originates from Lambda Calculus.

    4. Because self-hosting implements the interpreter in the target language, there is a circular dependency. Therefore, if one small local change occurs, it can cause a domino effect throughout the whole system.

Homework Exercise:

From your understanding of the lecture and readings, create your own programming language.

(This assignment would require the use RACC, which is not provided).

Homework Solution:

I created my own language: Leaf

View an overview at: https://sites.google.com/site/leafprolang/