In Your Bones
I wonder how we will grow and learn together.
Eric Zhang•December 4, 2022
Note: I wrote the original draft for this post in August.
It’s March 2020, and I’m a teaching assistant for an algorithms class at Harvard. I sit in a packed seminar classroom in the evening with 40 students; the room only fits 15. People are frantically trying to sign up and get time to ask questions about their homework. (The logistics and organizational incentives are set up poorly, so students typically don’t have the resources they need.) The assignment is due tomorrow night.
We’re learning about RSA. RSA is an algorithm whose core you can implement in 4 lines of code. This isn’t busy work like most assignments; if you understand the algorithm well, it takes 5 minutes. The conceptual scope of the entire project is roughly to write this on your own:
def encrypt(message, n):
return pow(message, (1 << 16) + 1, n)
def decrypt(cipher, d, n):
return pow(cipher, d, n)
However, most students in the class don’t have much computer science background. That makes the problem difficult.
A student asks me a question:
How do I convert this decimal number to binary? I see that I can read a binary number to decimal form. However, I need to put the number in binary again so I can bit-shift it like it says in the problem set PDF.
It’s not just them. Variants of this question are repeated over and over again throughout the evening. And that’s stressful because it is really hard to answer as a teacher. The way it works is, computers are already expressing numbers in binary. When you assign an integer variable, it’s already binary; and that’s how all operations are processed. But it’s hard to decouple people’s mental model of “number” ~ “decimal number” with the actual essence of “number” as “object that you can do arithmetic and math operations on.”
So they show me their code, and I see they’re converting from number to string,
and back again, fruitlessly trying different things like eval("0b01101")
to
get numbers to binary, and they have 10 lines of code trying to convert back and
forth between formats because their mental model is not working. Likely, my job
as a teacher would be to somehow convey this idea / perspective: that numbers
are not inherently “decimal” and that 0-9 are just digits, but they are hold no
fundamental weight to the essence of arithmetic. Which then allows you to
understand that computers store numbers in binary.
This is difficult though. When you print out a number in high-level
programming languages, the number prints as decimal because the function does an
implicit base conversion. But print()
is exactly people’s mental understanding
of what a number is; its identity; the physical being of a virtual
non-existence. And people have been using decimal systems for their entire
lives. So there is a deep-seated mental confusion linking the abstract concept
of “number” with its reification as “thing with a bunch of 0-9 digits that I can
add/multiply with pen and paper.”
It seems like the right way to help the student is to slowly ease their way to helping them see a new perspective by unlinking “number” ~ “decimal number” in their minds. Otherwise, they will run into the same issue over and over again.
Conversation
But this is hard. My typical conversation goes something like this:
E: “I see you’ve done a lot of work on this problem. Great job persisting on it so far! Can I just ask you a conceptual question though to check our mutual understanding? This is just to help you out.”
S: “Okay, can you make it quick though?”
E: “Yes, of course… So, when you store an integer in your program, like x = 5, what numerical system is it stored in?”
S: “Well… wait, what do you mean numerical system — like codewords? … I don’t know?!”
E: “Specifically it would be nice to think about: what base is the number represented as, since we’re talking about base conversions right now.”
S: “Oh, well yeah, it’s base 10. That’s why I have to convert it to binary now.”
E: “… Okay, very good. Are you sure it’s in base 10 though?”
S: “Yes, it’s in base 10.”
E: “Thanks, that’s great. Actually it’s not quite in base 10; all numbers
you write in your program are stored in the computer in binary. So to do a
binary base conversion there’s nothing to convert. And when you converted the
integer from hexadecimal string to a number with int(x, 16)
, you’re actually
converting from hexadecimal to binary; not hexadecimal to decimal. The print()
statement implicitly does a decimal conversion. And”—
S: (unconvinced and doubtful) “Oh… ok… wait, what? I don’t follow. What does this have to do with the problem anyway? Are you sure they’re stored in binary? Can you point out where in the lecture notes it says that?”
E: “Yes, well it’s not in the lecture notes because this is an algorithms class, so we focus on theory, but if you look…”
S: “Look, I just want to solve my pset problem. I don’t want to listen to you lecture me about concepts, I just want you to tell me what code to insert here. The problem set is due tomorrow, I’ve been stressed out about this for over 10 hours this week, and I’m tired. Can you just help me out?”
E: internal sigh that I can’t show “Okay, just insert this line of code. Good luck.”
Then I put a smile on my face, so I can move on to the next student in the queue.
Reflection
Take from this what you will. For me, experiences like this are why I find teaching beginners so incredibly difficult.
When you can already run, tweaking your performance and planning to achieve new heights is one thing. But when you’re just taking your first steps toward a goal, mentorship is even more taxing on both the educator and the student. Plus, the stress and competitive, career-oriented nature of universities doesn’t provide a healthy environment for many students to grow.
For what it’s worth, I’ve had great experiences teaching upper-level CS electives at Harvard. Introductory classes have been much more stressful though. Beginner material is far from being easy; it’s the first impression of many learners to a field, which sets the tone of their journey over years. There needs to be attention to detail and empathy on both sides. It’s a miracle that we’re able to learn at all! I admire teachers who are able to make those miracles happen.