This is a read-only archive!

Confidence

One of my flaws when it comes to coding is lack of confidence, or you could call it lack of imagination.

At work we have some data files which are some funky binary format, readable only by some special program. This program has no command line interface. On a whim I thought hey, wouldn't it be nice if I could write my own tool to read these data files, then I could make a command line tool and it'd be scriptable. My first reaction was "Impossible! I don't have a spec for that file." That's a typical reaction on my part.

But when I got a hex editor and looked at the file, it turned out to be super-easy to parse. There were field names in ASCII, then some garbage bytes, then a byte indicating the length of the value, then the value, then a null byte. Records in the file were separated by a certain string of eight bytes. There's a bunch of other garbage in there which may or may not turn out to be significant, but it's not that hard to guess. I ended up writing a naive Ruby parser for these files and it was only around 20 lines of code.

A good strategy that I need to work on adopting is just to assume I can do things until it's been proved that I can't. A lot of problems that look hard are really easy given a good algorithm or a good approach to writing your code. On the other hand a lot of problems that seem easy on the surface turn out to be NP-hard, so the opposite is true too. Programming simply is not an intuitive exercise to my brain, which means the best solution is to try to avoid relying on my intuition.

March 11, 2008 @ 9:23 AM PDT
Cateogory: Programming
Tags: Ruby

2 Comments

Dirk Gently
Quoth Dirk Gently on March 11, 2008 @ 10:09 AM PDT

Even Twain was skeptical. If anything evidence has proved we get more skeptical with age. Immortality if for the young. :)

jvs
Quoth jvs on March 11, 2008 @ 11:28 PM PDT

I have been thinking as you some time ago. today I just start hacking. if I fail, ok, maybe it cannot be done or I'm just not as far to accomplish this. however, most of the time I can get it working and encounter lots of things I have not known before...