Expressions, ASTs, and Types
Instructor notes for Expressions, ASTs, and Types
These are general notes about this assignment. They primarily for course instructors. These notes may also be useful to you if you are a student, particularly if you had to miss class or if you need a reminder of what happened. However, beware:
- This is just a sketch. Actual lectures, demos, and discussions will include many details that do not appear in these notes.
- An individual instructor might decide to do something additional or even entirely different that doesn’t appear in these notes.
- There is often spontaneous discussion in class. That won’t appear in these notes.
This page is therefore not a substitute for attending class and taking your own notes.
ASTs: what and why?
(aim for ≤5 min; they only need a quick intro to get the activity started)
- Draw tree for a very simple example, e.g.
2 * 3 - 4
- Show values at each node
- 1-2 examples will suffice. No need to get complicated at the whiteboard; activities will get into it!
- AST stands for “abstract syntax tree”
- This probably feels kind of familiar / easy for simple arithmetic, but almost all code has a structure like this!
- This is about learning to analyze code
- Actual programming languages like Java construct an AST when they run the program
- Learning to see code the way the computer sees it will help you understand lots of otherwise confusing things!
- Rules of these ASTs:
- Values start at the bottom and flow up
- If you’re unsure where to start, remember: the thing at the top is the thing that happens last
- Left vs. right matters! (e.g. subtraction)
Pair programming: what and why?
(also ≤5 min, more to come in the next class)
- Programming is highly collaborative
- Software is made by teams
- Communication is a key software dev skill
- Explaining yourself is a key skill
- Asking for help and saying when you don’t know is a key skill
- Also this helps in the classroom
- Students who are confused have support, aren’t struggling alone
- Students who understand (or thing they do) can’t just speed ahead on autopilot; they have to slow down and communicate
- Key goal: make sure everyone in your activity pair/group understands each part
- It’s not a race! Nobody is impressed if you’re fast
- Quality of learning is what matters