• Octopus1348
    link
    fedilink
    arrow-up
    7
    ·
    5 months ago

    I once heard some YouTuber say Windows uses \ in path names instead of / like everyone else because Microsoft thinks backwards.

    • dan@upvote.au
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      5 months ago

      As what often happens, using \ for paths is for backwards compatibility.

      Neither CP/M nor MS-DOS 1.0 had folders. When folders were added in MS-DOS 2.0, the syntax had to be backwards compatible. DOS already used forward slashes for command-line options (e.g. DIR /W) so using them for folders would have been ambiguous - does that DIR command have a /W option, or is it viewing the contents of the W directory at the root of the drive? Backslashes weren’t used for anything so they used them for folders.

      This is the same reason why you can’t create files with device names like con, lpt1, and so on. DOS 2.0 has to retain backwards compatibility with 1.0 where you could do something like TYPE foo.txt > LPT1 to send a document to a printer. The device names are reserved globally so they can work regardless of what folder you’re in.