2023–24 Projects:
Scene: CMC 306, office hours, Monday afternoon, week 3. An intrepid CS professor works with a distraught Intro student.
Stu: My code isn't working and I don't know why. I tried to run my program but Python spit out all these angry-looking words at me.
Prof: Let's take a look and see what's going on here.
Stu: It's complaining about a bunch of things in cTurtle, but I didn't write that! Does that mean that cTurtle doesn't work? Why did you give us code that doesn't work? I tried to look at the cTurtle code---
Prof: No, no, don't do that. The cTurtle code is fine. See, you have to go down to the last line of the message....and that tells you the error is in line 15 of your code. Looks like a problem with how you're calling the dot() method.
Stu: (looks unconvinced) Oh. OK, well it also told me I had a syntax error in line 23, but that line just says print "hello". I can't figure out why that's wrong!
Prof: Try looking in the line before. When Python complains about a syntax error in line 23, it usually means the error's in the line before---
Stu: Oh, I'm missing a parenthesis! Man, I'm so stupid. I'll never figure this out.
Prof: (thinking to self) No, these error messages are what's stupid.
Fade to black
Python is an awesome language. Its syntax is straightforward, its libraries are easy to load and use, and it's easy to get something up and working quickly. These are just some of the reasons that beginners and experts alike use and adore Python.
But as with any language, there's a learning curve. Those learning a first computer language, whatever the language, struggle not just with learning the syntax and structure of the language, but also with fixing and debugging their own programs. Error and warning messages from a compiler and/or interpreter are the natural indicators of problems in the code and are the natural first place to look when debugging.
Yet error and warning messages are not user-friendly for beginners. Features that intermediates and experts find useful, like the stack trace format of Java and Python, are confusing and frightening to beginners. Beginners lack the experience of intermediates and experts in interpreting errors and warnings. Someone who's new to Python but fluent in another language, for instance, might be momentarily thrown by the syntax error message in the scene above, but will figure it out fairly quickly. By contrast, a true beginner might spend an hour trying out variations of the correct syntax---because why would the interpreter "lie" about where the error is?---convinced the problem is with them, not with the message itself. The language is also problematic---what exactly is a Value Error, for instance? And not enough context is given within an error message to be useful to the beginner programmer and to allow them to become self-sufficient. Finally, occasionally Python will throw an error for a module that does not affect the student's code---say, when a graphics window doesn't close cleanly. Such error messages are not only useless to beginners, they can be downright harmful to their confidence.
All of these factors make it difficult for students to become proficient in debugging their own code, and can be off-putting to students learning on their own without instructor/prefect support. If we make the error messages easier to understand and interpret, we can boost the confidence of new Python learners, make debugging less taxing for beginners and intermediates, and make the experience of learning a new language and/or a first language easier and more enjoyable for all.
Your goal for this project is to develop a learner-focused Python interpreter that makes dealing with error messages less tricky and facilitates more independent learning and exploration of the language, boosting learners' confidence.
Rather than writing an entire Python interpreter from scratch, you will write a wrapper around the existing Python interpreter. The main goal of the wrapper will be to analyze the output of the Python interpreter and "repackage" the messages presented to the user to make them more understandable and useful to new language learners. Your interpreter will also analyze the student's code to try and identify the cause of the error, in order to produce more context for the error message itself (and help the student fix his/her own code). Time-permitting, you can extend this work into designing a development environment aimed at beginners to facilitate learning Python.
Here's what this project will consist of:
You will work with a reference librarian in early fall term to identify proper resources. In the meantime, here are some resources that will be useful in thinking about how beginners think about programming and earlier attempts at facilitating language learning for beginners: