A Collection of Exercises for Learning Erlang (Or Any Other Language)
If you want to become an expert as a programmer you must deliberately practice programming. We can't hope to get better with our languages, our tools, or our general knowledge of programming such as algorithms, data structures and even general problem solving skills without putting some real effort into improving with them. Steve Yeggee put it well in his essay on practicing programming;
Contrary to what you might believe, merely doing your job every day doesn't qualify as real practice. Going to meetings isn't practicing your people skills, and replying to mail isn't practicing your typing. You have to set aside some time once in a while and do focused practice in order to get better at something.
The best way to get the aforementioned deliberative practice is to sit down and write some code. Solve a problem, solve it again, and if you want to add another performance metric then time yourself how long it takes you to solve it. Make sure the problem is challenging, maybe just outside your reach. Maybe you'll have to do some research before you solve it because you're unfamiliar with the problem domain, or some math involved. I've compiled a list of exercises that you can use to practice your programming skills. Despite the fact that this article's title is focused on erlang I have kept the problem set language agnostic to increase its usefulness.
Katas And Problems / Challenges
- Code Kata - Prag Dave, who coined the term according to Wikipedia, has a collection of 21 (at the time of writing) katas for you to practice using whatever language you choose.
- Project Euler - A collection of hundreds mathematical problems not branded as Katas, but will nonehteless get you writing code. The problems are designed to be solved programmatically using any language you choose. As an added bonus these will get you doing some reading on mathematical topics too.
- Roy Osherove's TDD Katas - A collection (of two at the time of writing) katas to get you started with test driven development. If you want to explore TDD further, the previously mentioned Project Euler kats can be used to practice TDD as well.
- CodeDojo Kata Catalogue - A collection of Kata exercises that have been tried at Dojo meetings. They are broken down into five categories; Algorithmic, Game Modeling, Math Oriented, String Manipulation, Specific Technologies.
- Programming Challenges [PDF Link] - The Programming Contest Training Manual for ACM competitions. This book not only offers challenges but teaches the topics as well. They apply to general computing focusing on data structures and algorithms.
General Learning Exercises
- Practicing Programming by Steve Yegge - A dozen exercises to make you a better programmer, a few involve coding, but most are career oriented.
- The Ultimate Code Kata by Jeff Atwood - Jeff Atwood of Coding Horror's article inspired by the above Steve Yegge post. I'm actively working on Jeff's first list item right now by writing this blog. :)
My Own Technique - Textbook Algorithms
I personally find a lot of value implementing algorithms from texts or practical books. This has the advantage of allowing you to practice a language, and gain a deeper insight into a specific topic. I've been eyeballing a text I used for an AI and Advanced AI course at University; Artificial Intelligence A Modern Approach by Stuart Russell and Peter Norvig as a potential candidate for this. The official site lists sources in Java, Python and Lisp and I think it would benefit me greatly to implement all of their code listings in Erlang.
If a thick technical text like this appears daunting to you, and it does it me thats why I haven't started, then perhaps you can try one of the many great practical books from publishers like Oreilly and Pragmatic Programmers, to name a few.
Share Your Own
This list was by no means exhaustive, and I'm sure you've got your own practice exercises that you like to use. I'd love to hear about the ones I've missed, and I hope I can fill in the gap in my practice regimen. Please share your own exercise sets or practice regimens in the comments below. I'll add them to this list, with attribution of course. :)
Reader Suggestion - Simple Web Server
parley left a great suggestion in the Hacker News Comments for this post;
Personally, I've always liked creating a simple web server as a nice step in learning a language/stdlib. Some concurrency, some I/O, some string parsing, etc. Obviously it's not the first thing one does, but I find it a nice package to put together that actually achieves something real.
If you liked this please consider sharing it on Hacker News or reddit.