Tuesday, June 28, 2011

Hidden behind the abstraction barrier

In the complicated modern world, most people only have the capacity to be experts on one or two things. But there are some fields, like biology or English, that most people have at least an elementary grasp on., whether  because they are common to take in college, useful for everyday life, or the subject of great debate. Computer science is not one of these fields. Most people are content to have their computer remain a black box (or grey box, in Windows' case), using it for internet or applications and oblivious to what goes on beneath the surface. My major almost feels like a secret society sometimes; we talk about it freely among each other with great interest, but whenever I talk much about it with a non-initiate, their eyes kind of glaze over and they change the subject and/or run away. I've learned not to try. But not today. I'm going to try to explain the concept of an abstraction barrier to you all.

The abstraction barrier is the reason why programmers like myself are able to work in nice, symbolic programming languages rather than manually flipping ones and zeroes. It is essentially a gap in knowledge that hides the complexity of some subsystem from the rest of the program. At the most basic level, this might be, for instance, an algorithm I write to sort a list. Once I have it working, I don't have to worry what sorting algorithm I used or what exactly happens every time I use it (unless I'm optimizing), I can just sort the list. I could go back and switch to use a completely different algorithm, and as long as it didn't take drastically longer to work, no one using my sort method would even need to know I'd done anything. I was in a class last week at my Seagate job and was struck by how much bit acrobatics a hard drive goes through to "open a file"--a single command in Python. Unless I'm a Seagate engineer, I don't need to worry about this at all.

Once I internalized the idea of abstraction barriers in programming, I started to see them everywhere. For instance, the internet itself--a mind-boggling amount of infrastructure goes to make it easy for you to connect to a Wi-fi hotspot and check your Facebook. And don't forget how your web browser makes sense of all those bits flying at you--to the computer, a video, a list of E-mails, and this blog all look the same. Outside of technology, the organization of a company is set up to make it easy for others to acquire, say, paper, without worrying about how it's produced, transported, or any of the other challenges that go into orchestrating these things. People can even be abstraction barriers, of a sort. As I was writing a help page for my program today, I realized an obvious feature it was missing and added it. This turned out to be painfully slow, though, and I spent over an hour figuring out why and improving it so my program wouldn't hang for half a minute. I could write another entire post on some of the tricks I used. When I committed my work, though, I mentioned none of this--I just "allowed recursive searching from the default directory."

Abstraction barriers are convenient slipcovers we put over a world that is far too complex to grasp in its entirety. They allow programs to work cleanly, without getting in each others' business, all below the surface of what you're doing on a computer. And now you know something about computer science.

No comments:

Post a Comment