7 Exercises to be a better programmer

Take your programming to the next level

Here are 7 exercises you can do to be a better programmer, at the end, I will share examples of projects or tasks I have done for each of them. Not all of these are well suited for novice programmers, but if you’re ready for a challenge, you may actually find these exercises achievable if you try and focus on the basics!

1. Write Your Own Language

Have you ever been frustrated with a programming language? Does the syntax seem weird, or does it just not work the way you want?

Well, good news, nothing is stopping you from making your own language.

Writing a general purpose programming language can be complex and challenging, but there are ways to get started that are much simpler. If you write a “Domain Specific Language”, then it doesn’t have to do everything, you can just directly interpret it to perform a specific task. You could make a data query language, a custom language for a calculator, a templating language, or simply a flexible file format for some kind of media.

Writing languages will teach you about parsing, grammar, syntax, interpretation, “virtual machines” and more. Both very simple and very complex languages have to deal with these issues.

2. Learn an Old Language

The annals of programming history are filled with the corpses of forgotten and abandoned languages from the past. Some of these, surprisingly, show some semblance of life. There is a full spectrum of dead languages, zombie languages, and just really old languages that somehow keep living.

I recall reading a programmer commenting about how dead programming languages are much more useful than dead human languages(I believe it was Paul Graham). Whereas a dead human language will only let you talk to a few people, a “dead” programming language can still be used to write a program that millions of people can find useful. As long as the computer can run it, and it’s a good program, your users won’t care.

So take a look at COBOL, fortran, Forth, TCL, Basic, or even Perl(perl is not dead, and even surprisingly modern, I do highly recommend). Even if it just helps you appreciate more modern languages, it can be an exercise well worth the effort.

3. Work on an Unsolved Math Problem, or Make an Original Algorithm.

Unsolved math problems are a dime a dozen. For whatever reason, there are a million questions in mathematics that are really easy to ask, but for some reason very difficult to answer.

Whether it’s the collatz conjecture, odd perfect numbers, or a beast like the Riemann hypothesis, unsolved math problems can be a lot of fun, and take your math and programming skills to the next level, regardless of your current level of knowledge.

While most people won’t discover any new insights on an unsolved problem, the process of working on one forces you be creative and helps you develop your problem solving skills.

If an unsolved math problem seems too daunting, you can always design your own mathematical algorithm, such as for computing pi, or you could create your own sorting algorithm and then test if it works and see if someone else has described a similar algorithm before.

There’s a lot more possibilities than you may realize!

4. Report a Bug

This may not sound like a big deal, but there can be more to reporting a bug than you might expect, and it’s a good way to get started being involved in open source projects.

To properly report a bug, you have document something reproducible that causes a program malfunction. You also need learn the requirements of the project for bug reporting, and you may find that the bug, or a similar one, has already been reported. If that’s the case, sometimes you can still add a comment or more information to the existing bug.

There are a lot of ways this can turn out. Your bug report could be ignored, or the project owner could contact you and say the project is no longer being maintained. It’s possible that no one else has reported the bug, and then it gets fixed in a timely fashion and someone from the project thanks you for reporting it.

When reporting a bug, you should learn and follow the procedures and written or unwritten expectations of the project, and be patient. If you can, you might work on a patch or pull request yourself to fix the problem.

Regardless of how it turns out, it’s a valuable learning experience for all kinds of programmers.

5. Clone a Game or Program

Do you ever get nostalgic for that old game you used to play all the time as a kid? Have you scoured the web looking for a usable copy without success? Now that you think about it, was that program actually surprisingly simple for hours of enjoyment it provided?

Well, have no fear, just write it yourself. For some programs this can be a serious project, but for others it may only take a few hours.

Classic arcade games like pong, snake, or asteroids are a good place to start. You could also write a board game or card game, like chess, checkers, or connect 4.

Cloning something gives you practice creating the logic of a program or game, without having to worry about the challenge of design. Often, when we write original programs or games, they don’t end up being fun or useful the way we expected.

When you clone something, you already know it’s useful or fun, the challenge is recreating the logic and other details accurately. And here’s a secret: if you don’t share it, you probably won’t have to worry copyright, patent, or trademark issues. If you decide to publish your clone, you should probably research any legal issues before you do so.

6. Write a Native Extension

We already talked about writing your own language and learning an old language, and this is another exercise along those lines.

Programming languages aren’t magical primordial forces of nature(well, except perhaps for lisp), they were written by programmers using computer systems in a different programming language or at least bootstrapped so they can self-compile.

For well designed language implementations, there’s usually some way to write a “native” module. This means you interact with the language at this lower level.

I would recommend getting started with lua or python. These are interpreted languages with well documented APIs for writing native extensions and interacting with the language in “native” code.

Most modern languages, including java, node, go, ruby, javascript(node), and more offer some way of writing native extensions.

7. Publish a Library to a Package Manager

Dependency management is one of the most significant challenges in programming. Dependency management is one of the most significant challenges in programming. That’s worth repeating a third time. Dependency management is one of the most significant challenges in programming.

Working with a new or tricky package manager can be hard enough, much less writing and maintaining a package yourself for deployment.

But working through this process can dramatically boost your knowledge and confidence in using a package manager. There are lot of details that may not be obvious as a package user, but make a lot more sense once you learn to appreciate the perspective of a package publisher.

This doesn’t have to be a complex XML parsing library, you can start with something incredibly simple. But even writing a simple library can teach you a lot, and help you be a better programmer.

My Examples:

Here are some examples I have done for each of these. They may not be the best projects, with unfixed bugs or poor documentation, but they demonstrate the basic idea.

1. Write Your Own Language

Lisp Markup

2. Learn an Old Language

Find Primes in Forth

3. Work on an Unsolved Math Problem, or Make an Original Algorithm

Hadwiger Nelson Problem Graph Tool

4. Report a Bug

I don’t have great examples, but here are a couple issues I have created on github:

5. Clone a Game or a Program

6. Write a Native Extension

This is just the most basic “Hello, World” style example copied directly from the Python C documentation, but technically it counts.

7. Publish a Library to a Package Manager

I have a couple different packages on npm. As far as I know, I’m the only person who uses them, but it’s still a good exercise.


My examples for each exercise are definitely not the best examples out there. If you decide to do these exercises, you want to find different examples of these tasks to help guide you.

I’m sharing my examples to document how I have completed each exercise, and show it can be done if you keep working on programming!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.