So, You Want to Learn Programming?
2022-02-12: Reorganized and updated
Many people I know have said they’d like to learn programming. Here is some information for anyone who’s interested:
Resources
Online Logo at Transum
An online version of the programming language Logo, which was designed to teach programming concepts. This site splits the language into “levels,” so you can get comfortable with a simpler tool at first. It also focuses on trying out specific tasks and has a retro feel.
Eloquent JavaScript by Marijn Haverbeke
This book has some of the best explanations I’ve seen of general programming concepts. The online version is free and has interactive exercises.
Non-Programmer’s Tutorial for Python 3 at Wikibooks
This one gets down in the trenches and teaches you how to write and run programs on your own computer, not in a sandbox on a website. It also covers topics that many introductions omit, such as figuring out what’s wrong with a program, splitting a large program into parts, and working with data files.
Introduction to Computer Science and Programming from MIT OpenCourseWare
You can’t learn programming from a lecture, but if you’re stuck on any of the other resources because you don’t have enough context, the first lecture or two in this series might help. It takes a big step back and asks, “What is knowledge?” then eventually works it’s way to things that are covered in the beginnings of the tutorials listed above.
Tips from Me
- Use Google. Type in descriptions of what you want to do, paste in error messages, and paste in names of built-in pieces of code that you want your code to work with.
- How hard something is will depend mostly on the context (language, environment, code already in the program, etc.) and the details. Goals with the same basic description in English can differ wildly in difficulty.
- If you don’t understand what your program is doing, try adding more output earlier. Put intermediate values and earlier versions of data in the output to get clues.
- Try variations. Once you’ve got a program working exactly as it is in the instructions, think of something slightly different it could do instead and change the program to do that.
- Find a way to run just one part of a program. There are usually several ways to do this, depending on the language. You won’t necessarily be able to grab just any old part of a program and have it make sense when run on its own, but most languages have ways of organizing the program into chunks that can make sense on their own.
Follow-Up Information
Test-Driven Development and Fuzz Testing on Wikipedia
These are both about having one piece of code automatically test another, to check whether it’s doing what you expect (which it usally isn’t). Also check out “In praise of property-based testing” by David MacIver. I’ve also written some thoughts on the difference between fuzz testing and property-based testing, which are not quite the same as MacIver’s thoughts.
Debugging and Testing by Gary Shute
A collection of tips for figuring out why your program isn’t doing what you expect. This often takes more time than everything else put together.
Exercism
A site with many practice problems in different languages which will test your answers for you. They make an effort to be friendly and provide a “mentoring” system, but you’ll probably need to already know how to program and use their site for practice or learning a specific language.
Programming Principles on Wikipedia
A collection of famous and semi-famous ideas and strategies for organizing code and deciding what it should say. You don’t need any of these to program, but they might offer inspiration.