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?

When I started to learn Go, I went from Hello World to (a part of) the Go tour, which I found quite helpful, then built simple (naïve, rather) number factorisation, a rot13 program, s simple DNS lookup tool (wrapper around the resolver functions with argument and option parsing, a bit of formatting), a strftime() in Go (which it doesn't have), and only then wrote a Lisp interpreter.

It wasn't my first one (and not the last), so I could concentrate on the language to learn instead of the one to implement. Such an interpreter is complex enough that you start to think about modularisation, encapsulation, adequacy of data structures, performance issues, etc. So, yes, I agree, a Lisp interpreter is in my experience a good thing to do. When I started one in Perl later, it suddenly got features the one in Go hadn't (let alone the earlier ones), so I ported them over to the one in Go, and now I am at that one again in my Copious Free Time.

Some time ago I wanted to learn Lua using Lisp, but that never materialised.

I plan on learning Swift now that is has been open-sourced, and I think I may go straight from Hello World to Lisp then. --Jyrgenn.

Comment by ni Wed Mar 16 18:40:51 2016