Categories
Geek

"Programming Pearls" online

Joe Mahoney, on his blog Cheerschopper, points to Jon Bentley’s site for his classic book on good programming practices, Programming Pearls. Distilled from his columns from the magazine Communications of the ACM in the 1980s, the advice Bentley gives is still good today. I’m glad to see that he’s included samples from the book to peruse.

Here’s a good one on debugging:

The expert debugger never forgets that there has to be a logical explanation, no matter how mysterious the system’s behavior may seem when first observed.

That attitude is illustrated in an anecdote from IBM’s Yorktown Heights Research Center. A programmer had recently installed a new workstation. All was fine when he was sitting down, but he couldn’t log in to the system when he was standing up. That behavior was one hundred percent repeatable: he could always log in when sitting and never when standing.

Most of us just sit back and marvel at such a story. How could that workstation know whether the poor guy was sitting or standing? Good debuggers, though, know that there has to be a reason. Electrical theories are the easiest to hypothesize. Was there a loose wire under the carpet, or problems with static electricity? But electrical problems are rarely one-hundred-percent consistent. An alert colleague finally asked the right question: how did the programmer log in when he was sitting and when he was standing? Hold your hands out and try it yourself.

The problem was in the keyboard: the tops of two keys were switched. When the programmer was seated he was a touch typist and the problem went unnoticed, but when he stood he was led astray by hunting and pecking. With this hint and a convenient screwdriver, the expert debugger swapped the two wandering keytops and all was well.

A banking system built in Chicago had worked correctly for many months, but unexpectedly quit the first time it was used on international data. Programmers spent days scouring the code, but they couldn’t find any stray command that would quit the program. When they observed the behavior more closely, they found that the program quit as they entered data for the country of Ecuador. Closer inspection showed that when the user typed the name of the capital city (Quito), the program interpreted that as a request to quit the run!

Bob Martin once watched a system “work once twice”. It handled the first transaction correctly, then exhibited a minor flaw in all later transactions. When the system was rebooted, it once again correctly processed the first transaction, and failed on all subsequent transactions. When Martin characterized the behavior as having “worked once twice”, the developers immediately knew to look for a variable that was initialized correctly when the program was loaded, but was not reset properly after the first transaction.

In all cases the right questions guided wise programmers to nasty bugs in short order: “What do you do differently sitting and standing? May I watch you logging in each way?” “Precisely what did you type before the program quit?” “Did the program ever work correctly before it started failing? How many times?”

Categories
Geek

"Achewood" imitates life

In the last Achewood comic strip, Roast Beef not only looks like me, he’s doing the sort of reading I’m doing.

But really, Beef, white briefs? Not boxers with pictures of polar bears on ’em?

Categories
Geek

All your web server statistics are belong to us

Nearly two-thirds of your base are belong to Apache

While doing some research in my capacity as Tucows’ TC/DC (Technical Community Development Coordinator, a cool mish-mash of developer relations, Open Source Nerd Wrangler and playing the part of “The Cheat” to Ross Rader’s “Strong Bad”), I hit the Netcraft site to see how the server market was divided.

The latest Netcraft Web Server Survey — the August 2003 edition, which marks the 8th anniversary of the survey — says that Apache HTTP Server has its biggest share of the market ever, with 63.98% of the nearly 43 million servers surveyed. That’s about 27.4 million servers.

(For comparison’s sake, the first Netcraft survey back in August 1995 found less than 20,000 sites. That’s three freakin’ orders of magnitude’s difference in less than a decade.)

Graph: Market Share for Top Servers Across All Domains August 1995 - August 2003, courtesy of Netcraft.

Apache is really “moving zig”!

According to Netcraft, Apache has a bigger than two-to-one lead over Microsoft’s server offerings — they have 23.75% of the servers, or 10.2 million servers. When counting Microsoft servers, Netcraft lumps all the various flavours of IIS (Internet Information Services) and PWS (Personal Web Server) together. This is a 2.2% drop in IIS’ market share that is attributed to Network Solutions’ migrating the rest of their domain parking system back to Solaris from a Windows based system hosted at Interland.

No! Over half your base are belong to Microsoft!

I mentioned this to Boss Ross (who reports to Boss’ Boss Noss):

Me: Hey, Ross. Seen the latest Netcraft survey? Apache has its biggest-ever share of the server market.

Ross: So who did Microsoft take their bigger share from?

Me: Bigger share? They lost almost a million servers from their July numbers!

Ross: Check out Scoble’s blog. He said IIS is on the upswing.

I hit the Scobleizer, and sure enough, he links to a guy quoting the Port80 survey of the top 1000 corporations’ web servers. According to that survey, IIS has the lead, with 53% of the share, easily trouncing Netscape at 18.6% and Apache at 16%.

Graph: Top 1000 Corporations' Web Server, courtesy of Port80.

“You have no chance to survive, Apache, make your time.”

So who’s right?

Probably both.

The Netcraft survey is Internet-wide, which accounts for anyone running a server, which ranges from my neighbour Hector all the way to Amazon, while the Port80 survey is restricted to Fortune 1000 companies.

In other words, if you limit your scope to the suits, all your base are belong to Microsoft. However, if you expand your scope to include the suits and everyone else, including Google, the Internet Archive, a zillion blogs, hosting services, DNS, and anything else that doesn’t wear a tie and say stuff like “That’s not on my action item list!” and “Let’s run it up the flagpole and see who salutes!”, things are quite different.

Suddenly I’m reminded of Danny O’Brien’s recent remarks:

Also the Microsoft stuff continues to have its head stuck right up the ass of corporate America. One of my big bones with MS stuff is that it always makes me feel like I’m eating out of the trash bins outside a cubicle farm. All of their software is designed to help busy executives plan their lives. Everyone I know uses it to try and write birthday cards and chat with their friends. When people use Microsoft Office they use it anywhere but in an office. Microsoft knows this – but it also knows that the money comes from their corporate clients, so there’s a limit to how much it can bend its software toward a wider customer base. Ultimately when you use MS software, you’re not the end user MS perceives at all: we’re just living off the scraps Microsoft leaves out after feeding its big customers.

Yes, Microsoft has its games division, but I get the feeling that games are for the gaps in the borth-school-work-death cycle of good little consumers.

Where’s the software that lets you create — and no, I don’t just mean slideshows covering your ass for last quarter’s losses? I don’t think it’s coming from them.

And speaking of cubicle farms, I have a TPS report to file. Later!

Recommended Reading

Ross’ take on the whole stats thing. “Personally, I’d love to see a number that quantifies, in absolute dollar amounts, the percentage of ecommerce that each platform is responsible for faciliating. Or maybe, total HTTP gets…or how about security patches per second? Segfaults per month? ”

The Adventures of Action Item. D’you think anyone in Redmond dresses up as him for Hallowe’en?

All Your Base Are Belong To Us. Oh, the memes of early 2001…

Categories
Geek

When good programmers make bad choices for touchy-feely-smurfy reasons

Every now and again, I reserve the right to taunt a friend mercilessly. This is one of those times.

My friend Danny O’Brien was trying to decide whether to use Perl or Python for a project. He was originally leaning towards Perl; I blame the fact that he might have been living in California too long, or perhaps he’s inhaled too many fumes while changing his lovely daughter’s diapers.

He writes:

I’m utterly torn between Perl and Python. My first choice in this case would be Python, because bad Python code doesn’t seem to be quite so personal. I’ve seen people spit blood at other coder’s Perl, just because it’s not the way that they would do it. Perl demands rather more sympathy with your predecessor than does Python. With Python, it’s just more code to stare at.

This sort of statement makes me imagine Danny at an electrical engineering class: “But professor, how does Kirchoff’s Voltage Law make you feel?”

Danny’s statement seems to imply that Perl requires you to know the previous programmer’s “headspace” in order to be able to maintain his or her code. In other words, the language alone does not communicate the author’s intent without the kind of exegesis usually reserved for studies of the subtext of inside jokes that might have appeared in the Gnostic Gospels.

You wanna get all touchy-feely and sympathetic with the previous developer’s “inner child”, don’t read their code. Instead, why don’t you two curl up in front of the TV and watch Oprah, then go hop in the hot tub and kiss?!

What is this, the Matt Damon/Ben Affleck school of coding?

That said, your successor does need to actually know the language. Most of the people I can imagine maintaining this code will know Perl but not Python. Python doesn’t take that long to learn, but reading Python to take on someone else’se project just isn’t much *fun*. Sitting down to learn someone’s Perl, while tough, does teach you about the way they were thinking when they wrote the application. Python’s clarity, I think, cuts down on its expressiveness in depicting why certain decisions were made. When I had to hunker down and learn POE or Moveable Type, for instance, I came away with a very deep understanding of how it was supposed to work. It was fun, albeit time-consuming. I sometimes have problems doing the same with slabs of Python code, just because they can be very lacking in personality.

What you call personality, I call distraction. Yes, I’m probably bound to find out more about the previous coder’s approach to programming by their Perl code. I might even able to ratiocinate their astrological sign or whether they’re dominant or submissive. But damned if I can figure out what the hell they were trying to get the code to do.

Python’s clarity is what I like about it. My first Python project — an actual paying one with an actual deadline for an actual system to be used by actual users — required me to pick up where the original developer, who had to work on other parts of the system, left off. The clarity of Python actually allowed me to see his design decisions; the obscurity of Perl would’ve been a hindrance.

That said, I’m not paid to be a programmer. What is fun is a hobby can be skull-crackingly frustrating in a job with a deadline.

Even when I have plenty of time to kill (hah!), I’d rather have a language that let me concentrate on my task and less on the language’s idiosyncracies.

Danny, being the kinesthetic sort, learned his lesson by peeing on the electric fence:

Now, a couple of days into it, I’ve begun to seriously reconsider. I’m nowhere near the Mason bit of the application, and I’m getting continually bogged down in Perl style issues that really don’t have anything to do with what I’m trying to write.

To be honest, I think this is my Perl rustiness kicking in; and I think it may go away after a few more days hacking. Worse, though, is the effect of something I thought would be a real boon – CPAN. There’s a bunch of useful utilities there that I’d love to suck in and use in my program. But they all have different idioms – all of which I have to sit down and learn. Plus there’s the whole dependency issue: sooner or later I’m going to have to install all of this on the working server, and there’s a real penalty to be paid for being dependent on a lot of scattered Perl modules. Will they work? Will they still be maintained? Which of alternative implementations should I choose?

Not into the touchy-feely thing anymore, are we, John Gray?

Oh, I’m being cruel now. Group hug!

(I’m kidding, Danny.)

Luckily, he eventually made the right decision, and I’m happy to report that things are working well for him.

Otherwise, I might have to mock him even more.

Categories
Geek

Thank you, Blogger

I’m a little late in writing this. I meant to write this before moving over to Blogware, but as they say, “better late than never.”

I’d like to say “thank you” to Blogger.

Blogger got me started in the blogging game in the first place. Although I could thrown together my own “content management system” or simply done things the hard way by hand-coding HTML, Blogger was there, and it saved me the trouble of having to worry about technical issues and concentrate on what it is that makes a weblog: the writing.

The nice people at Blogger have impeccable taste; quite early on in the history of The Adventures of AccordionGuy in the 21st Century (remember, in the Blogger blog it’s “AccordionGuy”, here it’s “Accordion Guy”), they declared it a “Blog of Note”. Remember, this was well before some of my better-known, wilder entries.

How many applications can you say changed your life in ways both subtle and extreme? In my case, I can’t think of any other than Blogger. Blogging most certainly saved me from a big world of misery: you might recall the story about the New Girl, in which my effusive blogging about a new girlfriend prompted a reader (who became a reader because she liked an earlier post of mine) to warn me that this new girlfriend was not whom she claimed to be. Through blogging, I widened my circle of friends; I’m sure it also played a part in landing me a very nice job at Tucows.

Blogging encouraged me to write daily, which improved my writing, gave me more discipline, and acted as a way by which I get a better perspective on myself. I understand that line about the unexamined life not being worth living more clearly now — since I write about what I do and who I am, I give more thought to what I do and who I am. That has paid off in spades.

As you know, I switched tools.

At Tucows, we’re rolling out Blogware, our own blogging tool, and as part of the Research and Innovation Group, I’ll be making my small contributions, giving direct feedback to the developers and of course, “eating our own dog food”. Blogware’s a good tool with a lot of neat features, and I like it a lot. For all these reasons, I made the switch from Blogger.

However, I wanted to express my gratitude to Blogger for giving me my start. Let me pay Blogger the biggest compliment I can: blogging — which I did via Blogger — has been just about as life-changing for me as the accordion has been.

To Evan, Steve and the rest of the crew, I’d like to express my thanks.

Categories
Geek

Steve Mann on the IKEA incident

Hey, I got email from Steve Mann! Cool!

He wrote in response to the posting about my photography experience at IKEA. He tells me that the Thursday evening panel discussion that I mentioned in this posting is going to cover the issues of surveillance versus sousveillance — where surveillance is turned upside down and the watched watch the watchers — and matters related to public versus private.

Thanks for the heads-up, Steve!

And double thank you for taking my “MISTER CYBORG” ribbing in the good-natured spirit in which it was intended. After all, who am I to talk? The present-day version of the rig he carries everywhere is less bulky and probably weighs a tenth as much as the accordion I carry everywhere.

(And as I take off my backpack and empty my pockets to change to dress up for tonight’s stag party for a friend, what do I see? In the backpack, a 12″ G4 Powerbook, power supply, Logitech MX500 mouse, spare power bar, small ethernet hub and power supply, USB ultra-bright LED reading light, USB hub. Ahem. In my pockets: Nikon Coolpix SQ camera, Samsung N370 cell phone, Mandylion password-memorizing/generating key fob, Handspring Visor Platinum, Planet Bike flashing ultra-bright LED bike light. Dammit, I may as well be a loosely-coupled cyborg myself.)

I extend a filet mignon on a flaming sword to the professor!

Maybe he’ll record the next Friday accordion video with me. The song I have in mind is Gary Numan’s Are “Friends” Electric?

Recommended Reading/Viewing

Steve Mann’s page on sousveillance. Who watches the watchers?

This is not “The Softer Side of Sears”. An MPEG video in which Steve asks Sears staff about their surveillance equipment. The whinging that the Sears staff do is quite something, and the way they react when they realize that they’re on camera is priceless.

Thanks to Steve Mann for the links!

Categories
Geek

"It is cloudy. You are likely to fly into a grue."

That new version of Flight Simulator must be really good, ’cause Scoble’s got it on the brain.

(I’ll probably pick it up. I said I was lowering my reliance on Microsoft-based stuff, not ditching it outright. But first, there’s Star Wars Galaxies, and I don’t dare touch that until I’ve got my freelance coding work off my plate.)

In a recent blog entry of mine, Getting pragmatic, part 1, I talked about what Andrew Hunt and Dave Thomas in The Pragmatic Programmer refer to as “The Power of Plain Text”. Scoble, in response to that part of my entry, writes:

I think I should be able to do more than just plain text on my computer. For instance, I wanna play some Flight Simulator (seen the latest version, it’s freaking awesome).

I wanna use my Tablet to write in ink. That ain’t plain text.

My friend built a system to run a Pistachio factory. That ain’t plain text.

It would appear that our wires are getting crossed. When I speak of plain text, I’m not talking about plain text interfaces, but plain text data formats:

  • Flight Simulator’s interface isn’t plain text, but the data files used to describe the “world” in which you fly might be, allowing third-party world-builders — yourself included — to create virtual worlds to fly in, real or imagined.
  • Same deal with the tablet — you write in ink, and perhaps your pen-strokes are saved, but the real data is the text that your handwriting represents.
  • As for the pistachio factory, the gui may be what the line controller sees, and bits over RS232 might be what the line machines “hear”, but the data — instructions to the line, settings, logs — could be stored as plain text.

That’s what I was talking about.

Hey, if I wanted plain text interfaces, I wouldn’t have paid the “Apple tax” and bought a Powerbook. I would’ve gotten an off-brand notebook, covered it with skateboard stickers and saved myself a lot of dough (and spared myself the trouble of having a life, too).

Of course it would be silly to make Flight Simulator a plain text game, although imagining it is fertile ground for a laugh:

> MAINTAIN COURSE

Your course remains unchanged, but you are approaching the point where you will be "handed off" to the flight control tower at Gander, Newfoundland, Canada. "Good," you think. "I'll annoy them by saying 'over and oot. Stupid Canuckleheads."

The stick feels a little sluggish today; you find yourself constantly arm-wrestling with it as the 737's nose insists on pointing downward. The pedals don't feel right, either. There's a bit of yaw to the right, and the crosswind isn't helping make things any easier.

Airspeed remains constant at 340 knots.

There is an exit to the aft.

There is a stewardess here.

> LOOK STEWARDESS

She's hot.

I’ll elaborate more on plain text and how it serves interoperability later.