To Koans or Not to Koans?

I’ve had the chance to get my hands dirty in many different programming languages since I joined Atomic Object. As a kinesthetic learner, I look for opportunities to get hands-on experience with every language. This is how I discovered programming koans.

Cartoon image with the words: Learning a new programming language? Why not koans?

What are Programming Koans?

According to the Merriam-Webster dictionary, koans are “a paradox to be meditated upon that is used to train Zen Buddhist monks to abandon ultimate dependence on reason and to force them into gaining sudden intuitive enlightenment.”

As a coding exercise, this is typically represented as a suite of unit tests where the participant fills in the expected values to satisfy a collection of expectations about how the language operates. The idea is that, through the process of getting the tests to pass, the participant will learn the structure, syntax, and core features of the language.

There are koans exercises in a variety of languages and platforms. I have personally completed a handful of these exercises and wanted to share some of my observations as well as ways I believe they can be improved.

Pros

Structure and Syntax

Koans teach the structure, syntax, and core features of particular languages very well. After completing a koans project, transitioning to an existing project with a codebase written in that particular language is quite easy.

Focus on Test Driven Development (TDD)

A strong emphasis is placed on the importance of testing throughout each koan project. It is encouraging when an essential task such as writing thorough and concise tests is emphasized in the resources you use to learn a language.

Practice Debugging Errors

No matter the language you are working with, there will always be times when you need to troubleshoot buggy code. Sometimes, it requires a trip to StackOverflow or the language’s documentation to find an answer, but you eventually figure it out. Knowing where to go for help in these situations greatly reduces the time spent debugging errors. These aren’t resources that you typically consider or visit when reading through a Getting Started guide.

Cons

Exercises are Often Largely Isolated

Each of the exercises does an excellent job at focusing on a specific feature, but there are often not enough examples of these features being used together to solve more complex problems. This is something that Codewars does quite well, and it would be an excellent addition to a koans project.

Helpful Tools and Packages Are Often Ignored

Depending on your perspective, this might not be considered a con. To me, the purpose of learning these languages is to be able to use them on actual projects. But more often than not, a project will not solely rely on the core features of a language.

No “Next Steps” Included<

After finishing a koans project, I’m often left wondering what resource I should turn to next to continue learning. Even a simple text file or a section at the end of the README with a few suggestions for next steps would be adequate.

Final Thoughts

Koans have been an excellent resource for me to get acquainted with a number of languages in a short amount of time, but I believe there is room for improvement. With that being said, I believe these exercises can be helpful for developers of all skill levels. Whether you’re new to programming or have been working exclusively with object-oriented languages and want to try functional programming for a change, there is always something new to learn.

Let me know what you think about koans in the comments!