Building dev muscle memory with Code Kata

Programming is not an art.
Programming is not a discipline of science either.

It's a craft - very special kind of craft:

  • it requires imagination & creativity somehow similar to what art requires
  • it has very strong scientific foundations, especially in terms of various areas of mathematics
  • but in the end programmers are craft(wo)men - their point is to use their knowledge & experience to fix the problem, fulfill the functional need, not to provide aesthetics, express inner emotions or provide a unique, revealing artistic experience

Craft requires following particular engineering principles, mastering patterns & practical understanding "the rules of the game". The world "practical" is crucial - there's no "theoretical programming": reading tutorial, watching few videos or even few books gives just a very slight idea what you're to face. It's all about practice & what's more all the rules & constraints that apply to practical skills in general, apply to programming as well, i.e.:

  1. Skill that's not regularly used, gets forgotten
  2. It's practice that makes the master

Literally. That's why developers need Kata.

What's Kata?

The original idea comes straight from martial arts - Kata are simple exercises that cover the basic techniques - "atoms" of what you would use in actual combats & their most typical combinations. They come in ordered sequences & are to be repeated again & again ...

  • ... first, naturally to execute them better & better each time
  • ... but second, to do it in more natural, instinctive way - one could say: without thinking (by building so-called "muscle memory")

Kata in programming?

Term "Kata" in software development is attributed to Dave Thomas, but the overall idea is much older that this. Applying Kata to code seems a bit crazy at the first glance ("am I supposed to re-write the same basic routine every day to truly master it?!"), but it's been a bit modified to fit specifics of our industry: repeating the same Kata has been removed, while regularity of practice & atomic granularity have remained.

Frankly speaking, it took me some time to convince myself I need it - until some moment I was sure that just learning the theory (learning != reading, the understanding factor is crucial) is enough to use it in practice. My turning point was reading "C++ Templates" by D. Vandevoorde - for me this is a great example of book that separates badasses from amateurs. It showed me that template-based meta-programming capabilities of C++ are vast beyond imaginations of language creators & you can draw from them even more goodness than it appears, but you have to really deepen understanding of the subject and for this there is no other way than ol', good empiricism.

So it went. I've spent countless hours on torturing Boost to learn from the best (its creators). I was inventing my own exercises to use its libraries in practice, find their weaknesses, constraints & undocumented benefits. Any, Bind, Function, Lambda, Optional, Pool, Smart Ptr, Tuple & many others. Actually at some point I've become that fluent & these felt so natural, that I was overdoing their usage ... But the benefit was clear - I've learned tons of new stuff (not just C++ specific) I'd never learn (and even knew it exists) otherwise.

Templates in C++ were was just the beginning. I've practiced Code Kata with (among others): SQL, ANTLR, ServiceStack, ZeroMQ, Rx, Scala, Akka, Scalding, R, functional programming (in general). Now I do this approach to hone my developing Elixir-fu.

Kata VS Pet Project

I know that some people are questioning the idea of Kata - they value actual project experience ("pet projects" devs are free to pick their tech stack for) more relevant than some "artificial", self-invented examples that miss a broader architectural context (by design).

I'd say that both practices are crucial, they cover different kind of learning & they have a different purpose. Code Kata are intended to give you the proper "workshop" you'll be using in Pet Projects in the heat of battle.

  1. W/O Code Kata you'll have very limited perspective on actual capabilities of language / platform / framework library. And as a result you may be far from using it in a truly beneficial way.
  2. W/O Pet Projects you'll miss the safe "sandbox" to test what you've learned. Your perspective on expected cost and / or benefit will be biased & twisted as well.

Kata-in-a-box

As many have learned already, inventing your own Kata may not be that easy, especially when you're still new to tech that's significantly different to what you've been doing so far (functional VS object-oriented, front-end VS back-end, single-threaded VS distributed, etc.), fortunately when there's a "market demand", supply follows :)

There are few truly superb resources I can recommend in some particular ideas:

  • "Functional Programming in Scala" - Code Kata mixed with theory & published as a book - considered as one of the best ways to learn the language & its functional background; HIGHLY recommended (I know people who don't care that these were meant to solve in Scala, they do it in their preferred functional language of choice)
  • There are FPiS versions in Java & JavaScript, but I didn't try them, so can't tell much about them.
  • "Etudes for Erlang" - short booklet that contains exercises only; I'm going through the Elixir version - it's not as good as FPiS, but still worth honest recommendation.
  • Katas by Dave Thomas - language / platform agnostic, from the original author of Code Kata concept - test yourself against his challenges to prove you're worthy!
  • Katas at CodingDojo - some are better, some are ... not so good, some are historical :) (FizzBuzz) what makes them worth trying as well

Pic: © Csaba Peterdi - Fotolia.com