Pushing pixels, twenty seven years ago
It must have been around 1985. I was in the sixth grade at the time. We’ve heard about computers, of course. Those were the beasts that would guide spaceships into the orbit, calculate flow fields around ballistic missiles or control high precision machinery. Nobody had a personal computer or a game console at home, at least among the kids that I knew in my school. The first three “Star Wars” movies were banned by the Soviet censorship, presumably because it would incite a grassroots rebellion against the evil empire. Somehow “The Terminator” got through the censorship blockade, and even on a small TV screen it was a magnificent experience, especially compared to the state of visual effects in the contemporary Soviet-block sci-fi movies.
One day, a teacher fell ill. They had to find something to do with a class of 11-year old boys and girls, and it so happened that a computer room was free. I never knew that our school had a computer room, and we’ve never set our foot in that computer room again. But that day has changed my life.
Three row of computers, with monochrome dot monitors. There were more of us than the computers, but not by much. And it so happened that I had a computer all to myself. The substitute teacher was a young lady and she showed us something magical. A computer game. It sounds trivial today, but back then it was truly magical. A computer, all to myself, and I can play on it? But there was a catch. There always is, at least that’s how I remember my school days.
The teacher said that she will load a game on our computers, but only after we’re done writing a computer program. A simple one, or so it would seem to all of us. A program that would get eight numbers as the input, each pair specifying a point on a two-dimensional plane, and would print out the coordinates of the intersection of two lines defined by these four points. And you know, after reading about computers guiding cosmonauts to space, running complex fluid simulations or powering a freaking robot from the future, it seemed so easy. She explained how to type a program and make it run, and how to handle user input. And then we were on our own.
I remember sitting there in front of the computer, thinking to myself that there’s supposed to be a button somewhere on the keyboard. A button that, when pressed, knows what to do with those eight numbers. How to treat them as coordinates on the two-dimensional plane, and how to output the coordinates of the intersection. Because that’s trivial. I mean, computers guide our space ships and ballistic missiles. I might not have the most powerful computer in front of me right here, but it surely knows how to compute that intersection point. Right? Right?
I eventually gave up and raised my hand. When the teacher came over, I asked her how do I make the computer do this calculation. And she told me “well, you tell the computer what you want to do.” She must have seen my completely stunned face, and then she said something that has changed my life.
Imagine that you’re a computer and you have these eight numbers. You have a piece of paper and pen. How do you compute that intersection point?
As these words tried to find their way through the make-believe model of how computers work, I struggled to not be disappointed. Here I was, so sure that computers can do any kind of computation, and here was the teacher telling me that I’m supposed to imagine myself in its place. Isn’t that why we have computers, to do those sorts of things for us, with no errors and much more quickly?
And then I had to take a piece of paper and do the math. Myself. Taking four numbers, treating them as X and Y coordinates, and computing the numbers that define a line that passes through these two points. Then solving a two-variable equation group that defines the intersection of two lines. Making sure that I got all my indexes and signs right. And then typing the long formula into the computer, making sure that I got all my indexes and signs right. All the time refusing to believe that I actually had to do it. Me. Not the computer.
When I was done, I raised my hand again and the teacher came over. She had a piece of paper in her hand, and she typed the first eight numbers. The result was correct. Then she typed the next eight numbers. And my program crashed. She copied those eight numbers to my piece of paper and stepped away. And that was my first debugging session. On a piece of paper. Because after typing the same numbers into my program it crashed again. And again. And that’s not how it was supposed to happen. Because, well, in my make-believe world of how computers work, they didn’t crash.
As I put those eight numbers into my scribbled formula, it came out that the denominator was zero. How could that happen, if my program printed the right result for the first input? Frustrated, I drew a two-dimensional plane with X and Y axes, put the four points and connected the line ends. Of course. The lines were parallel. A corner case, if you will. My first corner case. Back to the program. I now extracted the computation of the denominator into a separate line and tested for zero. If it was zero, the program would print a special message and stop. I was ready to call the teacher back. But then a thought crept up. She caught my program with a special case. Is there another one? And it turned out, there was, and her next group of input numbers would test just that. The case where one of the lines was parallel to one of the axes. In that case, my denominator was still zero, but there was another way to solve the equation group.
And then I was done. And I played that computer game for the rest of the session. I don’t remember how the other kids did. Some of them sat there until the end and didn’t know what to do, and some of them were playing the same game by the end of the session. I was so completely engrossed by the game that I’ve hardly noticed anything around me. But that was the day that has changed my life. The day that has showed me that computers have to be told what to do. They can do any kind of computation, much faster than any human being. But there is no magic button to press to make the computer program itself.
Later, I would devour A. K. Dewdney‘s monthly columns in “Scientific American”, from Mandelbrot set to Game of Life and much more. Later, my parents would buy me one of the first Soviet micro-computers. Later, my brother-in-law would lend me his Commodore and I would program both computers in Basic, even if there was no way to save what I wrote. And later, my school would have a special program that would have us spend one day every week in an external computer facility, tackling problems of various size with only one problem defeating each and every one of us. But that is a story for the next time.
I wish I remembered the name of that teacher. The one that opened my eyes and guided me without force-feeding me the answer. You have my undying gratitude. Thank you from the bottom of my programmer’s heart.