After learning the basics of programming, we learn algorithms and data structures.

I have very fond memories of implementing many algorithms and data structures in ANSI C and Java in the late 1990s.

There was something very pleasurable in implementing well-known and well-defined computational concepts and then playing with them.

Specifically, data structures like:

  • arrays
  • linked lists
  • hash tables
  • graphs
  • stacks
  • queues
  • trees
  • and on

And algorithms like:

  • binary search
  • bubble sort
  • quick sort
  • heap sort
  • breadth-first search
  • depth-first search
  • best-first search
  • a-star search
  • and on…

I don’t think I’ve implemented any of these algorithms and data structures since. But there was a time in the late ‘90’s where that is all I was doing for months and months. Perhaps years.

Developing my own extensive library of standard algorithms and data structures.

And it was very pleasurable.

A lot of my subsequent work has probably being attempts to recapture this feeling.

Anyway…

I didn’t “know” these algorithms and data structures as I do now. So, how did this go?

I think it mostly involved copying, something like:

  1. carefully reading a description from the textbook
  2. copying the implementation from the textbook
  3. filling in the gaps
  4. fixing bugs (because nothing ever works the first time)
  5. extending implementations, adding features, ec.

Maybe later peering into the Java source and the C stdlib to see how the pro’s achieved the same capabilities.

The key thing here:

Sitting in front of the PC, textbook open, typing in code copied directly from the page.

This slow and careful reading+typing+debugging resulted in a deep understanding of each algorithm and data structure.

This is learning the applied parts of computer science via copywork. The same way that many copywriters and fiction writers learn how to write. It’s how painters learned to paint.

You slowly and painstakingly hand-copy the work of a master.

Here’s a definition by our friend claude:

Copywork” is an educational practice where a student carefully copies high-quality writing, art, or other work to learn techniques and internalize patterns. It has historical roots in classical education and was commonly used to teach writing, penmanship, and art. […] The key benefit of copywork is that it provides hands-on experience with high-quality examples, allowing learners to internalize good practices through direct imitation before developing their own style.

Right-on!

With the rise of amazing code libraries and video courses/youtube I strongly suspect very few programmers (people learning to code) are doing copywork.

You can’t deeply learn a linked list by watching a summary on youtube, by reading a description on wikipedia or by copy-pasting code from an LLM. You’ve got to code it up, line by line, copied from a good pedagogical example (no from an optimized lib).

It’s boring. It’s hard. It sucks. And it also works.

I feel like this thesis is testable. Get a batch of first-year students, give each a different treatment (method of learning), then ask them to implement and compare the quality of the implementations.

Perhaps these ideas are related to “learning best by programming”, but here we are actually talking about learning the craft of programming.

Anyway, there’s an opportunity here for a well structured approach to copywork in specific modern sub-disciplines, perhaps machine learning, deep learning, llm’s, and even your classical algorithms and data structures. Perhaps delivered as an email course.

Something akin to Sam Parr’s copythat email course for learning copywriting via copywork, but for programmers interested in learning their craft the hard way.

Actually, “the hard way” makes me thin of Zed Shaw and his Python book:

The Hard Way Is Easier

With the help of this book, you will do the incredibly simple things that all programmers do to learn a programming language:

  1. Go through each exercise.
  2. Type in each file exactly.
  3. Make it run.

That’s it.

– Page xviii, Learn Python 3 the Hard Way, Zed Shaw, 2017.

And:

Do Not Copy-Paste

You must type each of these exercises in, manually. If you copy-paste, you might as well not even do them. The point of these exercises is to train your hands, your brain, and your mind in how to read, write, and see code. If you copy-paste, you are cheating yourself out of the effectiveness of the lessons.

– Page xix, Learn Python 3 the Hard Way, Zed Shaw, 2017.

The pros know.

Hmmm.

Actually, this snippet from one of Zed’s recent blog posts is insightful:

…As these tools get stronger the distance between what I do and what everyone else does grows. Right now people are using LLMs to generate their code. In 10 years those people will be asking Microsoft Visual Studio users, “Bro, why are you…typing your code? Don’t you know Code Gen 20k exists?” Those same people will be looking at what I do like I’m a renaissance oil painter…

I was thinking exactly along these lines. How antiquated and slow copying code (or writing code) from scratch is, and yet how valuable it is for the individual.

And:

…I and many of my peers didn’t get into programming because it was a job. I got into programming because it was fun and challenging. It was awesome to stay up all night banging my head on some terrible code I wrote just to make a donkey move across the screen. It was fun to get a terrible website up and running for the first time. It was fun to think of a weird idea and make it a virtual reality.

Right on!

I need to re-read Zed’s book. He really was/is onto something with his pedagogical approach and his thinking. I think I must have imbibed it in the early 2010s as it was fundamental to what I did at machine learning mastery.

I was talking this through my buddy gpt4o and he suggested I should create a site called “CodeThat” with courses teaching various complex algorithms via programming-copywork email courses. Good idea!