How to, Once and for All, Remember when to use “\” or “/”

download (1)

Does anyone else have a problem with this?? This seems to pop up for me ALL THE TIME! Whether it is in a web URL, a file path on Windows computers, a file path on Mac computers, switch charters in command line, or wherever else they are used! How can I remember whether to use a forward slash or a backslash so that I do not constantly have to keep looking up the correct syntax for the situation that I am in???? Side Note: Actually, most of the time, I can’t even remember which one is called a backslash and which one is called the forward slash! I think most people have finally figured out a good way to at least get the names right (and I finally did too after remembering this trick) and that is to just picture the backslash as if it was a line that otherwise would be standing up straight, but instead, is falling BACKwards from the direction in which you read and type (therefor you can also make the mental connection that the forward slash looks like a line falling FOWARDs). Here is a picture to illustrate that:

foomanForwardslashBackslash_580w_161h

However…. Remembering the name is usually not the biggest problem for me though. The real problem for me (and I think most people) is remembering when to use one or the other. Then I started wondering why this was so hard for me to remember when I didn’t have trouble remembering a lot of other small details about situations. Then it came to me. The reason that I could not remember this detail was because I had no CONTEXT to put it in. Or, put into other words, it just seemed like a crap shoot to me which one would be used and that there was really no rhyme or reason to it! (I thought I just had to memorize each instance when and where to use each and that there was no way around it) Boy was I wrong. Of course there was a reason and there is most definitely a method to the madness. Once I was able to put what I was trying to remember into some context, it became a breeze to always know (not remember) which slash to use. download I think an effective way to always know where and when to use each is to understand why there are forward slashes and why there are backslashes. What is the history behind them. Why couldn’t we just have picked to use one or the other?? So lets dig into that!

History of the Slashes

The forward slash (“/”) first made its way into the computer word when the operating system Unix was released. The designers of the Unix operating system decided to denote the symbol “/” to be a file path and directory separator. This happened around 1970 before Microsoft was even in the picture! Well low and behold Microsoft DOS – MS DOS 1.0 – comes to make its way onto the scene in 1981 and believe it or not, did not yet support directories at all! Most of the utilities included with DOS were written by IBM, and they used the “/” character as a “switch” character. You can still see this today in the command prompt — running the command dir /w tells the dir command to run with the wide list format option, while running the command dir c:\ tells the dir 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. (On Unix, the – character is used instead of the / character to indicate switches.) Well MS-DOS 2.0 decided not to suck as much as MS-DOS 1.0 and 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 for something, so they couldn’t just re-use it. They ultimately chose the “\” character instead, as it was the most similar-looking character visually (haha thanks a lot you guys!! NOT). different-types-of-slashes-in-windows-command-prompt 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.

Why Everything Else Uses Forward Slashes

This all wouldn’t really 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 backslash 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 use forward slashes for the same reason — it’s the Unix convention. Linux is a Unix-like operating system, so it uses the same type of slash. Mac OS X is based on BSD, 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. forward-slashes-in-paths-on-linux So what to take away from all this is that EVERYTHING uses forward slashes, EXCEPT file paths in Windows (or a switch statement in a cmd prompt) only because Unix introduced the forward slash (before Windows was around) and everything went with that and Microsoft, being difficult, decided that they would confuse all of us and pick an almost identical, but different symbol, for file paths! So when in doubt use “/” unless you are accessing a file path on a Windows computer!! P.S. Finding out the WHY to something will always help you more than just trying to memorize something. Dig deep into subject matter to understand it instead of just brushing the surface and accepting it for the way it is and trying to memorize it. That’s my 2 cents!

%d bloggers like this: