Why does Windows use `\` while everyone else uses `/`?2023. 5. 20.
Me: "Why does Windows use \
while everyone else uses /
?"
GPT-4: "The reason for the difference lies in the history of the two operating systems and the choices made by their developers.
Microsoft's Windows OS uses backslashes (\
) as a path separator due to its legacy of MS-DOS. MS-DOS was heavily influenced by an older operating system named CP/M, which did not have a hierarchical file system, meaning it did not have directories/folders and therefore did not need a directory separator character. When Microsoft introduced directories in MS-DOS 2.0, they needed a character to act as a directory separator, but the forward slash (/
) was already being used as the switch character (a kind of option flag) for command-line arguments. Therefore, Microsoft chose the backslash (\
) to avoid breaking compatibility with existing software.
On the other side, Unix and Unix-like systems (including Linux and MacOS), use the forward slash (/
) as a path separator. The forward slash was chosen as a directory separator in Unix due to its simplicity and ease of use in a command line interface. The forward slash was available because Unix uses the hyphen - for command-line options, not the forward slash.
It's worth noting that although Windows primarily uses backslashes for paths, it does understand forward slashes in most contexts. However, because the backslash is the standard, Windows software often expects paths to be written with backslashes and can behave unexpectedly if they're not."