New language? Here is your first assignment in it.

So you know a handful of programming languages and now need to learn another one? Interesting.

One of the most important things when learning a new programming language is to have a couple of small programs in mind that you can implement. You don't learn a language by reading about it, though that helps significantly. Also, you don't learn a language by reading code, though once you have a handle on the syntax and semantics, this is invaluable to improving. You learn a language by writing code in it, running the code and debugging the code.

You don't jump into a new language and write a dependency injection framework or build VisagePamphlet, the new killer social media application. You need to write a few small programs that you can personally validate are more or less correct with a test suite or simple manual execution.

The choice of what to write is kind of tricky, so here is what you should do :

Implement a Brainfuck Interpreter

WHAT.

If you have never attempted this, it might seem kind of insane, but it's actually far less difficult than you may imagine. The language is so tiny that a reasonable implementation in any current mainstream language is going to be under 100 lines of code. But more importantly, this little program you are going to write requires:

  • variables
  • loops
  • if/else
  • switches
  • possibly recursion
  • thinking about types (if applicable)
  • string manipulation
  • IO

But this has an additional side benefit as well, you have to write Brainfuck programs to exercise and test out your new interpreter. This in and of itself is a challenge due to the limited features available in the language. In addition, once your test programs are working, there are a host of programs available on the Internet which you can download and throw at your interpreter.

Finally, depending on how deep you wish to go, this program is now an excellent launchpad for future experimentations into the language you wish to learn. Write something so you can dump the memory of the Brainfuck program. Add another pass to verify the program is valid before running it.