walls.corpus

By Nathan L. Walls

  • Sunset, Jan. 2, 2021/Williams Township
  • On Bougher Hill/Williams Township
  • Sunrise, Dec. 19, 2020/Williams Township
  • Sunset, Dec. 27, 2020

Code Kata: 99 Bottles

One of Chad Fowler’s recommendations in The Passionate Programmer is to practice Code Kata. Similar to musicians practicing scales or a martial artist practicing forms, this isn’t code that’s meant for practical value beyond practice. The means is the end.

I started with Fowler’s recommendation to implement programs that outputted the complete text of “99 bottles of beer on the wall” in a variety of languages. Very straightforward and I was pleased to observe/learn the following:

  • Out of four languages attempted, I was able to get all four to work. Yay!
  • I’m very familiar with Perl and Ruby. My career’s been spent on those two languages.
  • I’m very rusty with PHP. I used PHP as a primary language for web development for about a year, back around 2000. I used it again from roughly 2005 to early 2007 on a client project, but I wouldn’t say I ever became conversant in the language. What I was looking at was bad code, too. In the time since, I’ve forgotten what little I did learn.
  • I’ve never done anything with Python, but, for this exercise, it seemed pretty straight-forward.
  • To accomplish the same task, the languages landed, in order of brevity, as follows: Python, Ruby, PHP, Perl.
  • I don’t find using php tags for shell scripting ideal. At all.
  • I learned a bit more about Ruby’s case/when statements. Most of my Ruby experience has been with Rails, and I’ve not found the need to write case/when statements.
  • I wanted to use Perl 5.10’s features. You have to explicitly ask for them. I don’t like that so much. On the other hand, typing use strict; use warnings; doesn’t bother me.

Finally, I had David A. Black’s excellent The Well-Grounded Rubyist to draw from after seeing that my Ruby implementation was not doing what I expected. I used PHP Bible for finding what I needed for my PHP example. Language preference aside, there’s a broad-spectrum of programming book quality. One end offers encouragement to dig deeper and demonstrates best-practices. The other end is a fire hose of language info to write the site your uncle gave you $200 to build that he wants Monday. Regardless of the language, I need to find the first type of documentation and avoid the second.

If you’re interested, I’ve put all four languages into one gist on GitHub.