<<< shades of grey

Home

Wednesday, February 01, 2006 09:49 PM >>>


On the Persistence of Bad Design...

Wednesday,  02/01/06  09:36 PM

… on the persistence of bad design decisions …

As a programmer you are constantly making design decisions.  Some are small, some are big.  Some have little effect, some have larger effect.  And every once in a while you make some decisions which seem small, but have a huge effect.  If these decisions are made badly, then it affects many other people for years to come.  Some of the worst decisions which have had the biggest bad effect were made in the early days of DOS.

These decisions were not made at Microsoft (raise your hand if you knew DOS was not originally developed by Gates & company) and were made in a hurry, because IBM was choosing the operating system for their new personal computer, and time was of the essence.  The competitors at that time were CP/M, QDOS, and UCSD p-system.  QDOS was a skinny clone of CP/M, which was [at that time] the dominant OS for personal computers.  Microsoft took QDOS, reworked it a bit, and positioned it as the OS of choice for IBM.  They priced it far less than CP/M and p-system, and the rest, as they say, is history.

Now CP/M was a shallow copy of Unix.  CP/M was little more than a command line interpreter, but it did emulate a few really important Unix concepts, such as stdin/stdout, redirection, and pipes.  (It also introduced some non-Unix kludges, like “drive letters”, which – in the spirit of this rant - we regret to this day.)  And these concepts were cloned in DOS.

The DOS people made one little teeny decision which plagues us to this day.  They wanted to support “switches” on the command line.  This is a Unix-ish concept, and in Unix switches are always introduced by a dash.  So you type, “program –switch –switch2 file file”.  The command line parameters were positional, but switches were a way to stick in non-positional optional things.  I don’t know why – history does record, or at least Mr. Google doesn’t seem to know – but for some reason the DOS people decided to use slashes instead of dashes for switches.  Queue heavy organ music – dum dum DUM.

As we all know, the Unix path delimiter was a forward slash.  But this was before hard drives, there were no directories in DOS.  Only devices and files.  Since slashes were not used for anything else, it probably seemed okay to use them for switches.  That was a bad decision – not to remain compatible with a preexisting standard – but so be it.  There was worse to come.

Along came DOS 2.0, and support for hard drives, and support for directories.  And now we needed path delimiters!  But since the DOS people had already used forward slashes for switches, they decided to use backward slashes for path delimiters.  Queue more heavy organ music – dum dum DUM.  This one decision ranks as one of the worst OS design decisions of all time, amid serious competition.  At least in terms of the reach of the effect, this one wins.

Now backslashes are funky characters to begin with – most people have trouble finding them on a keyboard – but they already had a purpose in life.  Since time zero backslashes have been used to “escape” non-printable characters.  For example, t means “tab” and n means “linefeed” (“newline”).  So the DOS guys, in their infinite dis-wisdom, picked the escape character to use as their path delimiter.

By the way, this difference only exists on the command line.  Internally DOS has always supported forward slashes as well as backward slashes in path delimiters, probably as a concession to compatibility with Unix.  But on the command line you must use backward slashes to avoid confusion with switches.

Did this make sense?  No.  Does it cause problems?  Yes.  How much time has been wasted over this bad design decision?  Who can say...  Not only do people like me have to make a career of editing scripts which include things like this: “sed s/\\\\/\\\\\\\\/g”, we also get so irritated that we spend additional time composing and posting long rants about it on blogs.  Which then waste the time of our visitors who have to read them :)

Moral of the story:  Make good decisions.  You never know how far-reaching the effects of a bad decision might be.

P.S. Yes, I really have a script which includes “sed s/\\\\/\\\\\\\\/g”.  This is necessary to preserve the leading “\” in servernames.  Don’t ask.

[ Later: this article explains further.  [ via Keith Gaughan ]  My favorite part of the article is the last line, "Fixed title - it's been bugging me all week"; of course we know exactly why the title was broken, it contains a backslash, and the author probably had to add at least one backslash, or maybe three, or maybe five, in order to get a backslash to appear in the title correctly :)  The persistence of bad design, indeed...  ]