Image credit: Senna Diaz
Wordy
Wordy is a toy-sized programming language. We will do science to it.
Here is a sample of Wordy code:
Set x to 3.
Set y to 4.
Set r to (x squared plus y squared) to the power of 0.5.
The starter code contains a more detailed description of the Wordy language, and the beginning of a Wordy implementation in Java: a parser that translates Wordy source code into an AST. You will use that AST to implement an interpreter and a compiler for the language.
Learning Goals
- Understand the difference between interpreters and compilers.
- Understand how AST data structures relate to source code.
- Practice writing code that processes code.
- Think in detail about the semantics of basic language constructs.
- Get a taste of the work involved in implementing a programming language.
Outside resources
The heart of this assignment is you puzzling out for yourself exactly what you need to do to solve each little step.
You may use the web, material from previous courses, and any other general reference to answer questions about Java syntax. If you can’t remember the syntax for a Java for loop or method declaration, just look it up!
You may not use any outside resources to find the solution to the specific questions each step of the assignment asks you to puzzle out.
You should turn off any “AI” coding assistant you might in your development environment (instructions: IntelliJ, VS Code). This assignment is asking you to do very common, very standard things that will be in the training data of any LLM; the system will dutifully copy the (maybe) correct answer straight out of that training data, leaving you no room to puzzle.
Project setup
You can choose any of several different Java development environments to do this assignment:
Any one of these tools will work fine — or if it doesn’t, contact Paul! Pick the one you are most comfortable with, or the one you most want to learn more about.
The assignment
- Part 0: Understand your starting point
- Part 1: Implement an interpreter
- Part 2: Implement a compiler
- Part 3: Reflect on your solution
- Bonus challenges