I took CS50

CS50 is Harvard University’s “Introduction to the intellectual enterprises of computer science and the art of programming”.

Professor David Malan delivering a CS50 lecture

I took CS50 in 2015, and it was my first real introduction to studying computer science. As an undergraduate back in the day I studied physics, and although I did some Matlab programming, it wasn’t until I took CS50 that I really started to seriously study computer science and programming.

Although it’s billed as an an introduction, CS50 is notorious amongst Harvard students for its overall difficulty and steep learning curve. It’s been described as ‘the world’s most elite computing course’, and is popular with people from all levels of the tech industry. YouTube CEO Susan Wojcicki says that CS50 changed her life.

I can certainly say the same as Susan Wojcicki, although I haven’t quite reached her level yet. After graduating I was a police officer for six years, and then a UK Civil Service investigator, before I decided to completely change careers and learn to program. CS50 was my first taste of computer science, and I’m really glad that it was my first port of call.

The sheer number of resources out there for learning programming these days can be overwhelming. I’m not complaining — it’s a little realised fact that anyone can learn anything they want to at this moment, to any degree of expertise, as long as you have enough time to spare. If you have a computer and an internet connection today, you have access to more information and accumulated knowledge than anyone that has ever lived. That being said, the paradox of choice can be at play here.

You could choose to learn from a textbook, YouTube videos or online tutorials. You could take a short course in a specific langauage or technology with providers such as Udacity or Codecademy. I’ve used all of these resources at some point, and they each have their own place and value, but for your first stop nothing compares to a course like CS50.

For a start, this is a ‘proper’ academic course. It forms part of an undergraduate degree at one of the most prestigious universities in the world, and as you would expect the course’s academic standard is rigorous. Other resources may teach you how to write a simple program, but CS50 will show you why you’re writing a program in such a way. It’ll teach you what a program is, how a computer essentially works, and what is going on “under the hood” of your machine.

Some people will argue that knowing these things isn’t necessary if you just want to be a programmer. This is true to an extent; you could learn how to program, how to make things in different languages, simply by studying programming directly. It’s certainly true that the best way to learn programming is by doing, not just by reading. But if you ever want to reach a certain level of ability, if you want to learn to solve abstract problems, if you want to squeeze the last drops of performance out of a system, you need to know not just how to tell the computer to do things, but what the computer is really doing behind the scenes. Even if you never go further into the academic study of computer science, CS50 will teach you a lot of the fundamentals, and equip you with enough knowledge in order to learn more if you ever need to.

Another reason CS50 is a great introduction is the fun and modern atmosphere generated by the course staff. It’s not an exaggeration to say that CS50 has the feel of a Silicon Valley startup, rather than a stuffy academic lecture hall. The course professor, David Malan, is an extremely engaging and modern lecturer, and a also must-see for anyone remotely interested in methods of education.

CS50: Not your average computer science class

CS50 also introduces the student to the culture of programming. This includes not only ‘hacker’ slang and sense of humour, but practical introductions to GitHub, Stack Overflow, and XKCD (okay, the last one isn’t that practical). I know that when I applied for my first programming job, just having a GitHub profile put me ahead of most of the local competition.

The course uses C as its primary language, before switching towards the end of the course to PHP (now replaced with Python I believe) and touching on Javascript and general web programming. It isn’t a course in C per se, it just uses C as the language with which to introduce computer science principles; including data structures, algorithm complexity, memory allocation and internet protocols, to name just a few.

C may seem a strange choice for beginners. It’s often cited as a bad “first language”, but CS50 takes the opposite approach. Speaking as someone who started with C before moving on to ‘higher level’ languages, I can absolutely say that it’s the correct approach. Programming in C means that you are closer to the metal of your computer, by which I mean that you have more control over what your computer is doing. If you want to add an element to the end of your array you first have to allocate the correct amount of memory. If you want a linked list you have to make it yourself, using pointers to memory addresses. On the notoriously difficult weekly problem sets (which I would estimate average 15 hours a week) you struggle with memory leaks and buffer overflows, but once you make the breakthrough and gain a detailed mental model of what the computer is doing, the benefits are worth all the pain.

An important thing to point out is, at this point in the course, you have no idea that there is any alternative. You think that this is what all programmers have to do every time they program. In that sense you’re going back in time to when programmers did have to allocate memory themselves (some of course still do, but it’s true that C is not used as much as other languages these days). When week 8 comes, and David Malan reveals that a language like PHP does all this stuff for you, and that one line of PHP does what eight lines of C does, you are genuinely amazed. It seems like magic — and that is the important point: learning C shows you that it isn’t magic. When you use something like array_push() in PHP, you now know what is going on behind the scenes: your mental model is more complete. This is the beauty of learning C first, and its benefits come up time and time again as you continue your programming journey.

I enjoyed every minute of CS50, and I’m very fortunate to have stumled across it at the start of my programming career. Unless you have a solid computer science degree under your belt, I’d recommend it for programmers at all levels. If you’ve taken CS50, let me know what you thought of it on Twitter.

Originally published at andydavi.es on April 13, 2017.