Ruby, iOS, and Other Development

A place to share useful code snippets, ideas, and techniques

All code in posted articles shall be considered public domain unless otherwise noted.
Comments remain the property of their authors.

2007-10-18

The Magic in the Box

Disclaimer: This is a rant. If you are not interested in reading the rant, please don't, but please also do not comment unless you have read it all the way through.

I'm a pretty easy-going guy, and I like to be helpful on mailing lists (and in person), but I expect a basic level of knowledge from people, particularly about the tools they are using. For anyone writing software, the computer is their tool. (So is a text editor or IDE and compiler or interpreter, but that's not where I'm headed with this.)

A strong formal education in computer science provides an understanding of data representation, logic, memory hierarchies, algorithmic analysis (and common algorithms), concurrency, common/basic data structures, stack and heap layout, compiler design, and probably a dozen other things I'm omitting. (Ideally, program design and development is a part of that education, but it should not be at the expense of anything I mentioned.) It's challenging, but self-taught programmers can learn the same things on their own. And should. As a professional of any sort, one has a responsibility to understand both the unavoidable tools (in particular, memory and CPU details) and the available tools (go look up the heap data structure right now if you don't know what it is).

One can argue that newbies should be able to jump right into programming, but at the same time there really is such a thing as a stupid question. Nothing says, "I don't understand how computers work and shouldn't be paid to write software until I do," like a question that shows a complete unawareness of the accuracy limitations of floating point representation. There are certainly other stupid questions, but that one came up recently.

I could have ended this rant on the previous paragraph, but I was afraid it would come across as unreasonable and mean-spirited, and my goal is to express the reasoning behind the distress I feel when I read such questions. First, though, I want to address the newbie issue in greater depth. If one is teaching oneself how to program, that is to be encouraged, but it involves some work beyond following along in a book or online tutorial. For the floating point example above, the autodidact (great word, look it up) should be expected to follow roughly these steps:

  1. discover an anomaly in floating point arithmetic
  2. in irb, run something like "0.1.class" to discover that 0.1 is a Float
  3. ri Float to discover that "Float objects represent real numbers using the native architecture's double-prescision floating point representation"
  4. google for "floating point representation"
  5. Read the very first link in the results, which has a specific section on the issue
  6. achieve enlightenment

The point is that teaching oneself involves more than just reading a book and playing around, sometimes in involves taking time to investigate the parts that don't immediately make sense. (Note that those steps are the shortest, simplest path from confusion to understanding; it might take someone more work than that, but the fact remains that there is a simple and reasonable path to understanding and that it isn't particularly hard to find.) If one does not know how to learn on one's own, self-teaching is the wrong choice and it is time to go get that formal education.

A bit more on why these questions I'm calling stupid distress me so. Imagine yourself as a master carpenter who is training an aspiring apprentice. The apprentice has assembled some Ikea furniture and decided he likes carpentry, so he's going to give it a whirl. One day, he brings in a stool with a leg that needs replacing. He says, "I've been trying to remove the leg, but the screw is just stuck or something, and I think something is wrong with it." You look, and ask him to show you how he's tried to go about it. He picks up a screwdriver and desperately tries to fit its flat head into the cross of the phillips screw. You tell him to stop, take out a phillips screwdriver, and proceed to unscrew things easily. He gawks and asks, "There are different kinds of screws that need to be treated differently?"

Imagine your horror. How could he not know something so basic? Aspiring to be a carpenter requires understanding the tools a carpenter uses. Likewise, aspiring to be a programmer requires understanding the tools a programmer uses. Enjoy!

Labels: