infundibulum

Note to self: Stop being lazy

July 16th, 2006

You know, there’s this programmer saying that goes “lazy is good.”

For instance, if you understand how to use libraries, and you use them, then your code will be shorter and easier to understand and maintain.

I’ve discovered repeatedly that that is in fact true, as far as it goes.

But it’s directly opposed to the other programming maxim: RTFM

The discovery, for me, is that in point of fact RTFM’ing is in fact easier in the long run, often.

(And before I describe this, I should point out that I really don’t care who thinks I’m clueless about what. I only care about what I think I’m clueless about. Because if I think I am clueless about something, well, by the demiurge, I am.)

Case in point:

When you go digging around for tutorials on how web servers work, you eventually run into this thing called “CGI.” Which you later learn means “Common Gateway Interface.” Which fact you dutifully attempt to absorb:

Oh ho ho, yes, old chum, why, that’s the Common Gateway Interface! It’s so… why, it’s Common!

And then, you go and you bang your head against whatever tutorials you can find.

But see, you still haven’t RTFM’d. Because you still don’t know how a web server works, because you don’t know how HTTP works.

Now this can be a slippery slope, because you don’t know how TCP works, and networking, and hardware, and, and, and, well, and sooner or later you hit Heisenberg, right? (Then there is no F’ing M.)

Eheh.

Like, today for some god forsaken reason I tried firing up this weird little builtin Python module called CGIHTTPServer. Which is kind of surprising, really — it’s a web server that you can start up from your command line, (if you have Python), like this:

$ python -c 'import CGIHTTPServer; CGIHTTPServer.test()'

Whammo, web server. You open up http://localhost:8000, and there’s a web server, which will actually run CGI scripts, which you put in a directory called cgi-bin, in the same place where you run that command. And you can put Python cgi scripts in there.

And it spits out log messages and everything.

It’s nutty, I tell you.

Now I mean, I’ve actually “known” how all this HTTP/CGI/blah blah works for a long time. But there’s something about finding a minimal arrangement that generates much grokkery:

Oh, that’s why there has to be a blank line after that Content-type: text/html; charset=utf-8\n thing… it really does separate the headers from the body… Oh yeah right, the difference between a GET and a POST is just obvious, you see the URL in the logs on a GET

And so on.

I think the programmers who are naturals are people who can look at some new problem, and they can say “okay, I know what I need to accomplish, I think I need to R this much of TFM in order to get to the point where I can start being lazy…”

In other news I’m a complete and utter insomniac.