Charles Petzold on writing books, reading books, and exercising the internal UTM

Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

Backslashes and Repercussions

July 6, 2006
Roscoe, NY

Julie Lerman's discussion of forward slashes and backslashes (and the confusion that results) reminds us how a single stupid decision can have long-term repercussions. I don't think there would be much confusion at all about slashes had not a certain decision been made in 1983.

The Wikipedia entry for "slash" reminds us that the regular slash character is very old and used for several purposes, while the backslash is relatively young and invented in connection with computers.

The developers of C used the backslash as an escape character. The backslash was an excellent choice for an escape character because the backslash wasn't used for anything else. The backslash is also used as an escape character (that is, for markup) in RTF, and in some other contexts.

In an environment where the backslash is used only as an escape character, it assumes a special identity. The backslash becomes the "weird" slash and clearly distinguished from the regular slash, because the regular slash is used for everything else, including conjunctions, fractions, and directory paths.

And so that idyllic state of nature existed until 1983 and MS-DOS 2.0. This was the first version of DOS to support directory structures, and because the slash had already been used in MS-DOS 1.x to indicate command line arguments, the backslash was chosen to separate directory names. Larry Osterman's blog entry about the backslash has a discussion of this history behind this decision. It is my understanding that IBM was overly concerned about compatibility with DOS 1.x command syntax, and pressured Microsoft to use the backslash rather than the slash in DOS directory paths. (At least that's the sense I got from Microsofties.)

This was a bad, bad, bad decision, and not only for C programmers who had to use double backslashes to code directory paths in strings. The decision elevated the backslash out of the realm of its special role as an escape character to become something syntactically significant on its own, and worse yet, to be used for the same purpose as the regular slash in other operating systems (i.e., Unix) and (eventually) URLs.

And that's why people confuse the slash and the backslash. The only people who should be using backslashes are programmers, and then only for very special purposes, such as escape characters and line continuation characters. (And you know what else is nuts? Visual Basic uses the backslash for integer division. No wonder people get confused!)

It's handy to have a rarely used character on the keyboard that can be used as a escape character. But after a particular character has a historical precedence as an escape character, it really becomes off limits. To define a use for that character in a context where you really should be using its mirror image is just insane. This is what's commonly called a sin.

Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold