Tuesday 12 April 2016

The History: Back Slashes and Forward Slashes

The History: Back Slashes and Forward Slashes

Have you ever noticed that 'why Windows uses back-slashes for paths, while everything else seems to use forward-slashes'?

In Windows, C:\Windows\ (back-slashes) and everything others, http://portonovocomputertech.blogspot.com/ on web, and /home/user/ on Linux, OS X, and Android (forward-slashes).

And it doesn't matter what type of slash you use, but the modern software, automatically, tries to correct when you type a wrong slash! 

The History: 
Why Windows uses back-slashes?  
It’s all around a few accidents of history, which happened decades ago.

Unix has introduced the forward slash character ( / ) as it's directory separator in 1970's. And we don’t, really, know 'why they chose this character', but that’s the one they picked. 

The original version of MS DOS 1.0 did not supporting directories at all, when it was released in 1981. Most of it's utilities were written by IBM, and they used the / character as a 'switch' character. We can, even, see this character today in the command prompt, i.e., to run the command dir/w tells the directory command to run with wide list of format option, while run the command  dir c:\ tells  the directory command to list the contents of drive C:\.  The different types of slashes here indicate whether you’re specifying an option or a directory path. 

MS-DOS 2.0 introduced support for directories, but IBM wanted to keep compatibility with the original DOS utilities and other programs that expected the / character to be used for switches. Microsoft had already used the / character, so they couldn’t just re-use it. They ultimately chose the \ character instead, as it was the most similar-looking character visually.

Windows may not be built on top of DOS anymore, but you can still see the legacy of DOS throughout Windows in the way backslashes and other features like drive letters are used for the file system.

Many of these details are from Microsoft employee Larry Osterman’s weblog, which contains more detailed information from Microsoft employees who made these decisions.

These all would not be the matter today, but web browsers follow the Unix convention and use / characters for web page addresses. A typical Windows user sees a forward slash when they type a web address and a back slash when they type the location of a local folder; so, this can be confusing. Websites follow the Unix convention, as do other protocols like FTP. Even if you’re running a web server or FTP server on a Windows machine, they’ll use forward slashes because that’s what the protocol calls for.

Other Operating Systems (OS) are using forward slashes for the same reason; it’s the convention of Unix. Linux is a Unix-like operating system; so, it uses the same type of slash. Mac OS X is based on BSD (Berkeley Software Design), an another Unix-like operating system. Other consumer operating systems like Android, Chrome OS, and Steam OS are based on Linux, so they use the same type of slash.

The more interesting question is, here, whether it really matters or not? Browser and OS developers seem to realize that the users are confused; so, they often go out of their way to accept any type of slash possible. 

If you type http:\\portonovocomputertech.blogspot.com\ into Google Chrome, Mozilla Firefox, or Internet Explorer, the browser will automatically correct it to http://portonovocomputertech.blogspot.com/ and load the website normally. 

If you type C:/Users/Public into Windows Explorer and press Enter, it will automatically be corrected to C:\Users\Public and you’ll be taken to the correct location.

DOS developers weren't satisfied with this in the earlier days; so, they made DOS to accept both types of characters for paths. Even you may type commands like C:/Windows/ into the Command Prompt, today, and you’ll be taken to the correct folder.

This doesn’t work everywhere in Windows, if you type a path like C:/Users/Public into the Open dialog and press Enter; you’ll see an error saying that the file name isn’t valid. Other web-based applications may show you the error if you attempt to type a path like http:\\portonovocomputertech.blogspot.com\ it depends whether the program corrects it for you or decides to display an error.


You can just forget that there are two different types of slashes, but it occasionally does matter. It would be nice if everyone used a consistent separator for directory paths, but Windows has historically been all about backward compatibility, even in the early 1980's.

No comments: