Monday, January 28, 2008

Computers. I hate 'em.

Not really, of course. They are just kind of frustrating, at whatever level of expertise one might have. My dad is not a newbie, but most of the problems he calls me with are relatively straightforward for me to fix. In my own work, I can find myself chasing a subtle bug in a program, or looking for days for documentation to figure out how to do something that seems like it ought to be easy. And for just about everyone, from rank amateur to the real hardcore programmers I know, there are times when things happen that just defy explanation.

One reason for this is that computers have become complex enough that they can retain a rather long memory of things that are done to them. Murray Gell-Man, a physicist, was recently talking about how the universe is the product of fundamental rules plus a bunch of accidents. (You can find this talk, and plenty more to entrance you, at TED.com. If you like hearing smart people talk about the things they know about, you can waste a lot of time at the TED site.)

It made me think- computers have all sorts of 'accidents' going on all the time. Things happen that perturb the system in ways the programmers did not predict, and probably could not predict, even in principle. Some are obvious bugs- some action a person takes sends the computer to a nonsensical part of memory. Others may be more subtle, where some lack of resources was not imagined, and was never encountered in testing. This sort of lack of robustness is a type of flaw, but not really a bug, per se.

A computer system's function relies on keeping accurate track of what resources are in use. When I program, one thing I have to be careful of in some languages are 'memory leaks'. This is when I tell the computer "hey, give me a chunk of memory to store this picture of a baboon's ass" but forget, when I have processed the baboon butt, to release the memory. C and C++ make it pretty easy to do this. Java and some other languages do 'garbage collection' automatically, but to do so, they have to have considerable resources tied up to act as garbage collectors. There is usually a trade-off between safety of code and performance.

As computing power increases, it becomes more practical to use 'safer' languages, since the performance hit is not so noticeable. It makes it easier for people like me, people who want to use computational power without devoting my entire professional life to it, to still do useful things.

In the olden days (heck, up to a few years ago) it was pretty hard to use things like networking or serial ports without a lot of detailed knowledge of what the hardware and software does when it moves data around. The realization that jobs like this (and stuff like making lists, printing, etc) were being done over and over again made some really smart people start thinking about how to reuse software efficiently. For a long time, there have been 'libraries' of code to help do hardware access, and all sorts of computational and database operations. Still, many of these have been complicated, and most of them islands unto themselves, requiring serious investments of time to learn to use them efficiently. Learning one system might not teach you anything about any other.

Some time back, people started thinking about how they could abstract things, how they could hide details so that a programmer could use a resource without worrying exactly how things worked at the level of individual bits, or hardware.

This has proven to be very successful. Rather than writing data to a location in memory to use a serial port, I can use a serial port 'object' that hides a lot of the crap I don't care about, at least not most of the time. As important, but more subtle, is that this kind of 'object oriented' programming provides a metaphor that can make the whole process seem much more natural. It takes discipline to do well, and I am still a novice. But the force multiplication in this method is palpable very quickly.

Some hardcore programmers resist this. They scoff at people who aren't guru enough to manage their own pointers and memory allocation. They don't want any detail hidden. A real programmer should know how every last bit is twiddled.

They remind me a bit of the guilds of clockmakers who resisted the introduction of standard parts and machine tools. Beautifully crafted timepieces can be made with little more than hammers, saws, and files. But that kind of craft means that every clock has its own personality. When your objective is timekeeping, and not art, then standardization becomes important. I want artisans to keep at it, but I don't want to have to be one to know what time it is. There just isn't time to reinvent everything.

There will never be any system that can't be misunderstood, nor any detail that can't be forgotten or overlooked. And it gets frustrating, ever more so as we all become more dependent on computers for all that we do. The truth is, though, that I really love computers, and the better they get at hiding details, and presenting their resources as abstractions that I can use, the more power they yield. And I dig that.

Tuesday, January 22, 2008

That's what I'm talking about...

When I say I've got libertarian leanings, people immediately think I'm a nutbag who wants no government, absolutely no help for anyone, free-market free-for-all, and the devil take the hindmost.

That isn't exactly what I mean. Regardless of whether, in principle, things like police protection and highways could be provided by the market, I still think we have to have government. There are lots of things worth spending money on in our society. It sucks that it has to come out of each of our paychecks, but I'm willing to grant that not every penny of it is wasted by the government.

At the same time, I think that there is a fairly good intellectual case to be made for an observation of Hayek: order does, in fact, emerge out of relatively free markets, and no political hack (or omnibenevolent public servant) could ever take into account the myriad of variables the market does naturally, to solve many problems. The 'invisible hand' may not always tend toward perfection, but it usually gets far closer than any 'best laid' plan ever could. I won't make that point now, if ever. Read Hayek. You may disagree vehemently if you are predisposed towards a centralized, planned economy, but he was prophetic in predicting both the problems and decline of centralized socialism.

Nevertheless, my core reason for even flirting with the label 'libertarian' (which is, in some of my social circles, like 'scientologist' or 'moonie') is my deep belief in the fundamental value of individual rights. I saw something Glenn Reynolds wrote that sums it up for me:

Personally, I'd be delighted to live in a country where happily married gay couples had closets full of assault weapons.


That's exactly what I mean. There are times, no doubt, when the needs of the many have to take precedence, but those times should be few, and far between. People should not harm one another. Past that, leave adults alone, no matter what your personal preferences are. That's what I am talking about.

Wednesday, January 02, 2008

upside down gidget


upside down gidget
Originally uploaded by sciencedave

My Coronene buddies posted a cute kitty picture, so I felt obligated to return fire.

This is pretty much how I spent the break, too. It was glorious, but too much free time makes me nuts. I was very glad to return to work today. It is still pretty quiet, with a lot of people not back yet, but I got some chemistry done and some programming figured out, so it was a good day. I missed my afternoon nap, though.