Beginning programming

Created by: Roger Grosse, Colorado Reed
Intended for: beginners

In Metacademy, we're trying to build a dependency graph of knowledge to help you find the most direct path to learn about a topic. But some topics are so important and fundamental that they're simply used everywhere. If you do any sort of programming, there are some basic concepts you'll simply have to be familiar with: control structures, functions, arrays, and so on. These are the air you breathe, the water you drink. Trying to list all the things that depend on them would be hopeless.

If you have already taken a university level programming course, or AP Computer Science, or have taught yourself enough programming to write simple programs (e.g. games), then you know enough to use Metacademy. You can skip the rest of this roadmap. If not, then read on.

What language to start with?

Really, you can start with any general-purpose programming language, such as Python, Ruby, Java, C, C++, C#, Go, JavaScript, etc. Most of the topics covered here will be similar enough in all of these languages that if you learn them in one language, you can quickly pick them up in any other.

All the languages I just listed are procedural programming languages, where statements are executed in order, and programs are structured in terms of procedures. At some universities, the introductory courses are taught in a functional programming language, such as Scheme or Haskell. You're free to follow this path as well, and being comfortable with functional programming ideas will pay off even in imperative programming languages. But be warned that this road can be more difficult, since the mapping between programs and algorithms is less obvious. Also, since functional and imperative languages are very different, it will be more work to translate what you've learned from one setting to the other. (Introductory college courses which use Scheme or Haskell are typically intended for students who have already done some programming in an imperative langauge.)

If you don't have a reason to want to learn a particular language, our recommendation is to start with Python. Here are some of the advantages:

  • The core language is clean and simple, and presents fewer hurdles to beginners compared with some of the alternatives
  • It is "batteries included," i.e. a lot of important functionality is included in the standard libraries
  • It is one of the most popular languages for introductory college courses, so there are lots of materials out there
  • It is an interpreted language, so you can quickly experiment in an interactive shell
  • It is a very widely used language, with among the best software platforms for web development, data science, scientific computing, etc.

If you are impatient to get started, try one of the JavaScript tutorials listed below. The advantage is that JavaScript runs in all modern web browsers, which makes it easy for web sites to provide interactive exercises. You can start programming without having to install anything. The downside is that JavaScript has lots of gotchas which will bite you once you start writing programs of any significant size. On the balance, you'll probably save yourself time by starting with a language like Python.

What to learn?

You should be comfortable with all the things we use on a daily basis when programming. In particular:

  • Know the basic syntax of the language: statements and expressions, comments, etc.
  • Know what variables are and what it means when you assign to a variable
  • Be familiar with basic data types like integers, floating points, and strings, and the operations you can use to manipulate them
  • Know and be able to use the basic control structures: conditionals and loops
  • Be able to decompose your code into functions (or methods or procedures, depending on the language) and understand why it is a good idea to do so
  • Be able to use some basic data structures (for the purposes of this roadmap, you don't need to understand what's going on beneath the hood)
    • an array or list type (e.g. arrays in C or Java; lists in Python)
    • an associative array (e.g. HashTables in Java; dictionaries in Python; objects in JavaScript)
    • a record data structure (e.g. structs in C; classes in Java and Python; objects in JavaScript)
  • Know the language's common idioms for iterating over arrays and associative arrays
  • Know the language's paradigms for reading and writing from files
  • Be able to use a debugger
  • Know the basic guidelines of good coding style

[TODO: suggest a few fun little projects to practice/test your skills]

Where to learn?

There are hundreds of textbooks, online courses, tutorials, and other kinds of introductions to programming out there. Any of them will probably cover all or most of the topics listed above. We list here a few free online resources which we happen to know about.

Option 1: online programming course

Do one of the following:

  • The EdX course CS50, Introduction to Computer Science, is Harvard's introductory programming course, aimed at non-majors. This has a light-hearted style, with high production values. The course covers several languages, but the relevant parts are taught in C. You should watch the videos for Weeks 0 through 3, and do problem sets 1 and 2.
  • 6.00sc, Introduction to Computer Science and Programming, is MIT's introductory computer science course, taught in Python. You should watch the lecture videos for Unit 1, which corresponds to about 1/3 of a semester course. Try the Unit 1 Quiz at the end.
  • The EdX course 6.00.1x, Introduction to Computer Science and Programming using Python, is a more polished version of MIT's introductory course. Watch the lectures for Weeks 1-4 (i.e. up to the halfway quiz) and do the problem sets.
  • Coursera's Learning to Program: The Fundamentals, which is based on the University of Toronto's introductory course and is taught in Python. Watch all of the lectures and do all the assignments.
  • CS106A: Programming Methodology, Stanford's introductory programming course, taught in Java. Watch Lectures 2 through 19, except that Lectures 10 and 11 are optional. (This corresponds to about half a quarter-long course.)

Option 2: textbook

Here are some free online programming textbooks. Work your way through any one of them, doing the exercises as you go.

If neither of these suits you, here is a comprehensive list of free online programming resources.

Option 3: JavaScript tutorial (for the impatient)

Do one of the following: