The limits of my language are the limits of my world

This week I got a question from a student:

Is it bad that I look at other peoples code when I try to solve problems with concepts I don't quite understand?

This is a great question, and I'm glad that he felt safe to ask it. I wanted to write something about it, and in doing so, to try and alleviate the guilt that underlies his phrasing.

Those that have spent much time programming with me will already know that I'm a huge proponent of reading code, both code you've written (and probably forgotten), but also, and more importantly, code written by other people. I think good programmers read more code than they write.

The first thing to understand about code is that it is not designed for a computer. While I think we know this, it's easy to forget. The computer always requires some step, that our code be compiled or interpreted for example, before it can be executed. The code we write, and the code the computer runs, are not the same. Programming is about abstracting human intent, and program code is that abstraction.

It's also really easy to get lulled into thinking about programming as a kind of unmediated interaction with technology, something we do with machines vs. each other and therefore something fundamentally write-only. We can confuse a programming language's use of complex syntax with the idea that we are somehow talking to the computer. As is so often the case, the speed of modern hardware hides the reality of how things really work. I think the thing that's helped me overcome this best has been working on really large code (e.g., Firefox), and having a long re-build cycle: you become aware of just how huge the gulf is between what you've written and what the computer eventually needs to ingest. When we code, we are not talking to computers.

I think it's more helpful if we force ourselves to look at programing languages as human creations meant to mediate human intent with machines. Doing so helps to pave the way for a more human understanding of the different uses of source code. A program's source code is where we work with one another, the text around which we gather, the corpus of our beliefs, hopes, and law. It's also where we learn from one another.

If we're willing to be humble and go and read each other's code, the sheer volume of good material for study is staggering. I've written before about how much I like GitHub's Trending page, and if you visit it today, you'll find one of my favourite programmers firmly installed in the #1 spot.

What is this repo that people are so excited about and starring most right now? A new UI framework? A new operating system? No. The top spot today is held by Peter Norvig and his pytudes project. From the README:

"An étude (a French word meaning study) is an instrumental musical composition, usually short, of considerable difficulty, and designed to provide practice material for perfecting a particular musical skill." — Wikipedia

This project contains pytudes—Python programs for perfecting programming skills.

The #1 trending project on GitHub right now is a repo full of sample code to "perfect programming skills." Is it OK to "read other peoples code when I try to solve problems with concepts I don't quite understand?" Norvig seems to think so, and GitHub's users clearly agree with him.

And this isn't the first time he's said it. Long ago in his Teach Yourself Programming in 10 Years he wrote this advice for people wanting to learn how to program:

Talk with other programmers; read other programs. This is more important than any book or training course.

We need to make it clear to the people learning to program today, to our students, colleagues, and employees, that it's not a failing when they consult someone else's code in order to figure out how something works. Experienced programmers do this all the time, and don't think anything of it. Code is a human activity, and as with other human activity, you get better at it by observing other people doing it, especially those who have mastered skills you're still learning.

I've made it a habit to always try and work with programmers who are better than I am, with the explicit belief that seeing their code and how they write it will help to improve my own. I've learned more from code I didn't write than I ever have from code I did.

Assuming the license allows it, and you're not in some context where "cheating" specifically prohibits you to look anything up, I will always encourage my students to go and read widely in other people's code. In doing so you're engaging with the culture and history of our craft, and helping to keep yourself from falling into isolated patterns of thinking and writing, which will begin to close you off from the future.

Is it bad that I look at other peoples code when I try to solve problems with concepts I don't quite understand?

No, it's a brilliant technique, and a super power. Use it frequently, and be proud that you did.

Show Comments