Sunday, September 12, 2010

You looked over my shoulder #searchenginesunday

A quick look at Google Analytics a couple of days ago found a strange phrase that someone had typed into a search engine, that somehow had brought them to this page. You looked over my shoulder. Perhaps they were disappointed when they found this blog, but no more. Here's a post written to precisely that title.

"You looked over my shoulder!" I spun around in the office chair, expecting to see Russ pranking again. Instead, I found myself looking into my manager's eyes, and smelling his breath. Shit. If it wasn't enough that he knew nothing about the industry, he was now here to micro-manage? It was going to be a long day.

He was a Navy man, apparently, all neatly starched shirts and a jacket with very, very shiny buttons. He'd stand up, stretch his arms out in front of him, make some indescribable noise through his lips and then demand to know if everything was "shipshape". He'd been brought in to bring some order to the chaos; to somehow get a bunch of twentysomethings to produce video game software. And so far, his best suggestion had been for us all to turn up clean-shaven and "get your bloody 'air cut!" He had impeccable credentials for the job; he'd been buddies with the new part owner of the company, who had recently bought his share to bail us out of some serious trouble.

And now he was about to tell me how to write code. This could be fun. "So, what are you doing, then? You haven't typed anything for the last five minutes. That's all this job is, right, typing?"

As soon as I heard that, part of me died inside. "It's not as easy as that, sure, I know you'd like to think it is," I grimaced. "I currently have what we in the 'business' call a 'bug'. You might have heard that term before. You know, named after that story about how insects had actually crawled into the first computers and frazzled up the valves. You know, those clever fellers up in Manchester, or down at Bletchley Park." I wasn't sure whether I'd been sufficiently patronizing for that to be a justified response to the mortal sin my new boss had just committed.

"Of course I know what a bug is, young man," the boss responded, craning his neck in a manner which would, within a couple of days, be impersonated by every wag in the company. "But, it's a completely logical process, isn't it? I mean, there's only so many lines right there in front of you. You go through them, one at a time, until you find the incorrect one. Then you fix it." I hit the right control key, and the text editor scrolled to the beginning of the file. I spun around in my chair, while holding "page down". Page after page of assembler blurred across the screen and reflected in the old boy's eyes.

"Harumph," he retorted. "Don't try to bedazzle me with bullshit - no matter what you say, it's still a linear process. Be systematic, and you'll find it. I have every confidence in you." He pulled up another chair and perched on the edge of it, intent that something was about to happen in the next few seconds. When nothing did, he became restless again. "So, what is it, precisely, that you're doing here?".

"It's display code," I explained, intent on showing that if sarcasm didn't work, straight-out honesty would at least bore him to tears. "What you see in front of you, on the screen, that's what's called memory-mapped. Every one of those pixels - yep, pixels, you can call them 'little dots' if you want - is represented by an address in memory. But, when I write to the display, I can only see 65,536 of those memory addresses at one." I saw him raise his eyebrows and begin to ask a question, but I continued. "The display, well, this one at least, is 640 pixels wide. Which, since that doesn't go into 65,536 exactly, means I have to do some clever fidgeting about to write some of the lines. Actually, I ask the display driver for what the screen geometry is and build myself some nice tables upfront, then, when I have to do anything with the screen, I just look everything up in the tables. It's very quick, on this machine, it takes something of the order of sixteen nanoseconds."

The question that had been eating him alive for the last couple of sentences of this explanation finally got to the surface. "Why 65,536? And how can you possibly remember that number?" "That, sir, is why I'm a code monkey, and you joined the Navy," I gleefully replied.

At that, he left my desk.

Feel like joining me? Have a go at writing either to this title, or one of your own, and list your entry in the comments. Have fun!