Mike knew he had a problem. His shareware planetarium software, Kepler, was flying off the shelves at software stores across the US. It was in such demand that he had to buy a second Amiga just to write more installation floppies. However, Kepler came with a glaring hole in functionality: no one could take screenshots.
"I just wish AmigaOS shipped with a screenshot API," Mike complained to his business partner, Seamus. "Every developer I know wants to grab screenshots. Every user I talk to says the same thing. How many teachers have written us, saying how they want to copy a star chart onto some floppies for their students?"
"I lost count after a hundred," Seamus replied. "Say, have you checked the BBS lately? At least one other person has had this same conversation, only they had a spare weekend where they weren't burning hundreds of floppies."
"And annoying the barbershop next door," Mike said. "I'll go digging around."
Mike scourged the Amiga forums on BBS for open-source screenshot toolkits. Among the dozens available online, most were written by a man that only went by the alias Dr. John. He included his credentials with each toolkit he released: PhD in Computer Science, ten years of experience, and he even reverse-engineered parts of the AmigaOS to find programming shortcuts.
And Dr. John had written the perfect screenshot toolkit.
Seamus bought sandwiches for lunch while Mike compiled Dr. John's toolkit for use in Kepler. By the time he got back Mike had finished integrating the toolkit. Mike's screen, running Kepler, showed the Orion constellation.
"Watch the magic happen," Mike said, and pressed a key.
The floppy whirled and growled and stuttered, in that loud, obnoxious way that Amiga drives do. After three minutes, however, it hadn't stopped.
"Taking a little long for the magic to happen, isn't it?" Seamus said.
Mike nodded in agreement, but a few seconds later, the drive fell silent. Mike navigated into the floppy and opened a file named KepSShot. And there was Orion, just as it had appeared in the application screen.
"It's still too slow," Seamus said. "You sure you want to ship it?"
"The users won't care. At least it's better than what they have now."
Seamus carried in another sack of letter into the office. A month after releasing an update to Kepler, they had received over a thousand letters. All of them boiled down to one problem: writing a screenshot to disk took far too long.
Mike read one of the letters. "This one, he says Kepler killed his floppy drive when he took a screenshot." He opened another. "And this one says the drive was so noisy it kept waking up her husband in the middle of the night."
"We have to do something about this," Seamus said.
Mike sighed. Resigned, he opened the source code of Dr. John's screenshot toolkit. I doubt I could improve on the algorithms of a graduate of his caliber, Mike said. What did he say, ten years of experience?
After ten minutes of code hunting, Mike laughed. Well, this doesn't look like ten years of experience to me, he thought. Dr. John's source code was well-organized, documented thoroughly, and abysmally slow. And Mike could see why: instead of writing the screenshot bitmap in 1K buffers like any sane programmer, he used a write() call for every single pixel in the bitmap.
Black Hole of Bad Code
Dear Dr. John,
Included are my alterations to your screenshot toolkit. While I appreciate the time and effort you took to put this together, and while it has given our product Kepler some much-needed functionality, I'm afraid I cannot recommend using your toolkit as-is.
I've included a changelog. You'll see that I rewrote the disk-writing mechanism to use buffers.
I wonder what kind of education you've gotten for your PhD in Computer Science, as you often claim. Unless your education has been entirely confined to theory and not practice, I suspect you may be exaggerating your credentials.
Mike's BBS post generated several hundred responses, including many who were profoundly happy with Mike's contribution to the toolkit. Dr. John, meanwhile, went incommunicado, and the dozen or so toolkits he authored soon fell out of favor. Kepler, meanwhile, did just fine.