Venerating blessed Saint Makita
Posted: Tue, 10 February 2009 | permalink | No comments
From my sigfile:
> There really is no substitute for brute force. Indeed - I must admit to being a disciple of blessed Saint Makita myself. -- Robert Sneddon and Tanuki, in the Monastery
Over the last couple of weeks, I've been teaching myself Erlang by solving the problems over at Project Euler. They're interesting problems, require a bit of math knowledge and logical reasoning (my skills in both have been getting rusty anyway), along with just enough coding on each problem to make it interesting.
One of the things that I've found, though, is that algorithmic elegance is required far less often than I had expected. In several cases, I've sat down with the problem and gone, "well, I can brute-force it like this, (clickety click), but I'll bet it'll take forever to run. I'll set that going while I think about a bett... oh, it's done already."
Part of this is that I've got a nice shiny-fast computer, and I'm writing the sort of code that Erlang does well at (and using it's sexy-powerful concurrent programming features to hammer away at all my CPU cores, with practically no extra coding effort on my part), but primarily the problem is that I don't have that good a "feel" for how long something's going to actually take to run. I suspect I'm not the only one, and that it's not something that experience is going to completely solve.
My take away lesson from all this (apart from a working knowledge of the basics of Erlang), is one that has been said a million times before, but is so easily forgotten in the excitement of coding: premature optimisation is the root of all evil. In other words, first make it work, then make it fast.
Post a comment
All comments are held for moderation; markdown formatting accepted.