madhadron

Sketch of a programming curriculum

Status: In progress
Confidence: Very likely

This is a guide and a set of exercises to getting the very basics of programming down. You will need to search the Internet to learn how to solve the exercises in whichever language you choose, but they are a good starting point.

Pick a language

Programs are written in various different languages. Exactly which language you learn in doesn’t matter very much. If you don’t want to deal with walls of text, consider Scratch. Otherwise,if you don’t have any reason to choose differently, Python is a not-wrong answer. If you want to be really esoteric, you could try Oberon.

Evaluating expressions

Learn how to add two numbers in the language you picked. Read your language’s documentation and search the Internet to figure out how to write an expression in the language and how to get the computer to evaluate it and give you the answer.

Numbers are single terms in a language. There aren’t subpieces of a number. We call this kind of thing atomic (that is, it cannot be split). There are other atoms in languages, such as characters, or true and false. Find some other types of atoms in the language you picked and write some expressions with them.

Insert the notion of types here, and how they are represented in memory? That they are all binary patterns.

Example tasks:

Variables

Often we will want to give a name to some intermediate state in a program. We do this by creating a name called a variable in the program that we can use anywhere we would use the value we set it to. Look up how to define variables in your language.

Example tasks:

Define functions

Using our computer as a calculator isn’t very exciting. To go farther, we need to be able to extend it with new things we can do. We do that by defining functions. Functions encapsulate a set of steps and can perform them on different inputs to produce outputs.

In your language, read how to define a function.

Example tasks:

(Concern: what generic exercises would introduce scope usefully?)

Conditionals

The structure “if X then Y else Z” is ubiquitous in programming. It lets programs behave differently depending on their inputs.

Look up how to do a conditional (sometimes called an “if statement”) in your language.

Example tasks:

Variables, conditionals, and functions are the patterns of working with fixed numbers of atoms. Next we consider what to do when the number varies.

Looping over lists

Lists (or their cousin, arrays) contain a sequence of values. It can be zero values. It can be one, or two, or thirty six. The values can be atoms, or other lists.

Look up how to make lists in your language.

Example tasks:

Unlike for fixed numbers of values, we need a new construct to be able to deal with lists. This construct is called a loop, and it repeats a fragment of program for each value in the list. Look up how to write a loop in your language.

Example functions to write: - Sum a list of numbers. - Sum all the even numbers in a list. - Calculate the length of a list. - Return a new list containing only the even numbers in a list of numbers. - Take a list of lists and return a new list containing the length of each list in the original list. - Concatenate two lists. - Concatenate a list of lists.

At this point you have all the basic constructs of structured programming: variables, conditionals, loops, and functions. These are the fundamental tools that most of your programs will be made of.

Next steps:

Input and output

There are four main channels that your program will use interact with the outside world:

Abstract data types

TODO

Dictionaries, trees, and graphs

TODO

Program correctness

TODO

Also:
learning to program
more programming | explore everything