Failing the First Time Around

Some of you may have been keeping up with Michael Harrison's SICP study group. I was supposed to be part of it, but have fallen utterly flat on my face (sorry, guys) and never really got past chapter 1.

But even at that early point I was regularly feeling completely lost. I couldn't keep the algorithms in my head - I didn't have the building blocks to make it possible to do so.

And between school and work, I didn't really have the time to put into learning those building blocks. I kinda had an inkling at the beginning of the semester that I wouldn't be able to do it all; I guess my only triumph is that I was right.

Failing In "Real Life"

But it's becoming clearer to me that I'm going to have to learn those things. Right now, at work, my project is to make a syllabus-publishing system. The challenging part is that it requires subtle levels of inheritance. Multiple people need to be able to make changes to different parts of the syllabus, and sometimes it's a required change, or just a default value, and sometimes they apply for all syllabi in a particular course, or in a particular division, and sometimes globally.

Don't Be Too Clever

"I know," I thought to myself, "I'll use a hierarchical structure to make things easy for me." I thought that was pretty clever. Every piece of content would somehow inherit from a root node, and I could have different branches for every piece in a particular division or course, and each node could then be assigned to an individual syllabus and have their own permissions, and then my application logic would inspect the node and the parent node and decide on-the-fly how it would be presented in the view.

It was gonna be awesome.

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. - Brian W. Kernighan

Predictably, I can see in retrospect, I am not smart enough to debug this. Which is why I'm writing this after hours of fruitless debugging of my clever scheme, two weeks past go-live, and with the dull hurt in my brain of "not getting it" reminding me strongly of SICP. Then, as now, I just don't have the logical fundamentals to grasp what I'm doing.

Sigh.

Numbers are Hard

Not that it's hopeless. I've been reading some of Bertrand Russell's essays. He points out that, overall, our mental capacity isn't that great. If it weren't for us conveniently having a number system, mathematics, grammar, and language, expressing all but the most trivial of thoughts would be near-impossible. You might - might - be able to conceive of having some number of fingers, which we happen to call "five." And if you tried hard enough, you might be able to realize that there are also five branches on that tree, or one more than five on that other tree.

But thinking that a certain number of objects - what we could call "nine" - can be divided up into a number of equal groups, such that the number within each group is equal to the number of groups? Naah. You can't really think that without language and math, and you certainly can't generalize it to a class of numbers in general. But with the fundamental of math and language, we just refer to it as a "perfect square," and it's not that hard to grasp - but only because we have a common framework for discussing it.

Programming is, Too

And what grammar is to complex thought and mathematics is to properties of numbers, logic is to the behavior of processes.

I mostly recognized that before, which is why I bought SICP and TAOCP and PAIP - all of which are sitting on my bookshelf, as yet unread.

I think I might finish them in a decade or so.

Unfortunately, my recognition is significantly more dramatic right now, because I need to fix my code two weeks ago, not in a decade.

So I'll likely just put a bunch of Boolean flag columns in the database to indicate all the separate possibilities. I'll admit to being a little sad; the hierarchy seemed so much more elegant.

But if you want elegance, you have to understand algorithms.

And if you want to understand algorithms, you have to have a solid logical foundation, as surely a you need a number system to start addressing number theory.

Algorithms matter. Logic matters.

But right now, a half-dozen flag columns will do.