Image credit: 株式会社タカラ / サンライズ
Type Modeling
This assignment asks you to
- implement a simplified model of Java’s static type checking in Python, and
- implement a simplified model of Python’s object attribute lookup in Java.
Please note the important difference between the two parts of this assignment. In the first part, you are simulating how the Python interpreter handles individual objects at runtime. In the second part, you are simulating how Java checks types and resolves method calls in expressions at compile time, i.e. for all possible values that might actually show up in that expression whenever the code actually does run.
In both cases, I have given you a starting structure and tests that show you what you need to implement. You should not modify any of the existing tests in this assignment. (Do let me know if you find a mistake, however!)
Learning goals for this assignment:
-
Deepen your understanding of the differences between dynamically and statically typed languages. Implementing something in code is a great way to think through it in detail!
-
Practice switching between languages often. In this class, we look at many languages side by side. As we do, note the differences not just in the features, but in their aesthetics, their taste and texture, the kinds of programming and thinking habits they favor. Getting used to switching languages is also good practual for software development out in the wild.
-
Gain insight into what types are. The two halves of this assignment are very different in the kind of algorithms they ask you to implement. Yet in both halves, you are creating a notion of “type.”
You may use external resources, such as online documentation, blog posts, and Stack Overflow, to learn about the Java and Python languages — both the things this assignment asks you to model, and the syntax and language features you’ll need to do the modeling.
For example, if you don’t know (or have forgotten) the syntax for a loop in these languages, then go ahead and look up the answer online. That’s fine!
You may not use external resources, including AI, to copy or generate code that solves the specific problems this assignment poses. Puzzling over each detail for yourself is the point! You should find and turn off any AI assistant in your development environment before you start coding, because it stands a very high chance of robbing you of your learning here.
Please study the academic integrity section of the syllabus if you haven’t already done so.
The assignment
- Make sure you follow the general produce for homeworks in this class.
- Part 1: Simulating Python’s object attribute lookup in Java
- Part 2: Simulating Java’s static type checker in Python
- Part 3: Do a small reflection
⚠️ WARNING ⚠️ This is a big assignment, and part 2 is much larger than part 1. Start early!