When learning to program, or when learning a new programming language, framework, or other tool, it is good write some practice programs to start with. These can be any programs one is interested in, and do not need to be meant to be used for real. Sometimes one can't think of anything. Here's a list of ideas.

  • The very basics:
    • hello: a program that just shows the message "hello, world" to the user. This is useful, because it means you can write the source code file, compile (if it's that kind of language), and run the program, and see the output.
    • Simple Unix-style commands: echo, cat, sort, sed. These can be made as hard as one wants, but the simplest versions are often quite simple.
  • System software:
    • find: Look for files based on names or metadata.
  • Data structures and algorithms:
    • Word frequencies: Read input, count the number of times each word in the input occurs, and write the 20 most common words.
    • Data compression: in its simplest form, this is run-length encoding, but can be as sophisticated as one wishes. Data compression algorithms can be quite tricky.
    • Lisp: implement a version of the Lisp programing language. Lisp has a very simple syntax, but a powerful sematics, making it particularly interesting to implement.
  • Miscellaneous:
    • An interactive text editor.
  • Web apps:
    • Show time until/since a point in time.
    • A clone of Doodle, for having a group to choose a time or place or other such thing.
    • A clone of Twitter.

What are your favourite practice programs, either from the list above or otherwise?