TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Backslash must die

157 pointsby chris-atabout 9 years ago

13 comments

TazeTSchnitzelabout 9 years ago
The sad thing is Microsoft never wanted the backslash. It&#x27;s all IBM&#x27;s fault.<p>DOS 1.0 had no subdirectories. There was no slash: you didn&#x27;t type A:\FOO.TXT, you typed A:FOO.TXT, and the prompt wasn&#x27;t A:\&gt;, but rather A&gt;. Incidentally, this still works today, and sometimes DOS boots with a A&gt; prompt.<p>In DOS 2.0, Microsoft decided to add UNIX-style directories, with . and .. for navigation, &#x2F; as the separator, cd to change directory and so on. But there was a problem.<p>DOS 1.0 had used &#x2F; for flags (e.g. DIR &#x2F;W). Microsoft&#x27;s solution to this was to switch to - for flags, but IBM didn&#x27;t like this change. So Microsoft compromised on using \ as the directory separator and kept &#x2F; in use for flags.<p>However, Microsoft clearly didn&#x27;t like having to make this change. How do we know this? Well, DOS nonetheless also supported &#x2F; for directories (and thus its successors, including Windows NT do), and, at least for a little while, contained a setting which let you use - as the flag character.
评论 #11435469 未加载
评论 #11436581 未加载
skrebbelabout 9 years ago
So the thing is, low-level Windows APIs (such as CreateFile) have supported forward slashes for a <i>long</i> time. And since libc&#x2F;posix-ish stuff like fopen() is implemented with that API on Windows, nearly all programming languages are magically forward&#x2F;backslash agnostic on Windows. As a programmer, this means that in places where it really matters, you&#x27;re usually just fine with forward slashes.<p>Many UIs get confused on forward slashes though (file open dialog, stuff like that), and given that the vast majority of people, worldwide, that understand what files and directories are, believe backslashes are the way to go, I doubt MS is ever going to change this.<p>But from personal experience - I&#x27;ve programmed cross-platform stuff on Windows for very many years, and I never bothered about backslashes. In all honesty I never understood all the open source stuff that comes with DIRECTORY_SEPARATOR global constants or eslint rules that tell you to use path.join() instead of `dir + &quot;&#x2F;&quot; + subdir`. The forward slash just works, and it has worked for ages.<p>The only &quot;problem&quot; is that at times you end up concatenating paths together and end up with stuff like<p><pre><code> C:\Temp&#x2F;mydir&#x2F;2&#x2F;..\file.txt </code></pre> That&#x27;s a bit quirky in log file and in the debugger. But fopen eats it just fine.<p>Sure there might be cases where this is a problem, probably the libraries I&#x27;ve seen code around backslashes have good reasons, but really for end-programmers it&#x27;s no biggie.<p>Now, MAX_PATH, that&#x27;s something else. <i>That</i> should die in a fire and it blows my mind that it hasn&#x27;t been addressed yet.
评论 #11434796 未加载
评论 #11434595 未加载
评论 #11435326 未加载
评论 #11437119 未加载
评论 #11436948 未加载
评论 #11436995 未加载
评论 #11435841 未加载
评论 #11436021 未加载
Animatsabout 9 years ago
And, after that, kill CR LF as a line separator. That&#x27;s an idea which belongs to the era of mechanical Teletype machines.
评论 #11435059 未加载
评论 #11434548 未加载
评论 #11436249 未加载
评论 #11437015 未加载
评论 #11434499 未加载
评论 #11435652 未加载
评论 #11436759 未加载
评论 #11435051 未加载
评论 #11434615 未加载
monochromaticabout 9 years ago
Forward slash has worked just fine on Windows for a LONG time. Backslash will probably still be around in the year 3,000 for backwards compatibility though.
评论 #11434297 未加载
评论 #11434320 未加载
_kst_about 9 years ago
Many Windows commands use &quot;&#x2F;&quot; to introduce options (much like most Unix commands use &quot;-&quot;). Since the default command shell doesn&#x27;t require whitespace after the command name and permits options to follow other arguments, it would be difficult to use &quot;&#x2F;&quot; as a directory separator in all cases.<p>An example from Microsoft&#x27;s documentation:<p><pre><code> dir c:\*.txt &#x2F;w&#x2F;o&#x2F;s&#x2F;p</code></pre>
评论 #11434505 未加载
评论 #11438600 未加载
评论 #11434538 未加载
评论 #11435067 未加载
glandiumabout 9 years ago
The best part of using backslashes in paths is that for character encoding historical reasons, backslashes are printed as ¥ in Japan.<p>C:¥Windows¥System32.
jasonjeiabout 9 years ago
It would be nice if we could get Windows internally to use paths like &#x2F; for the C drive and then use &#x2F;mnt&#x2F;d for the D drives, and use Bash as the default shell instead of cmd.exe. I suspect it will take some time, but if they do so, it would make Windows a first-class POSIX development setup.<p>I can only imagine the difficulty of something like this, given all the legacy code and backward compatibility issues. Perhaps intelligently rollback to C:\ style paths when apps use backslashes. For Program Files, they might as well continue using &#x2F;Program Files&#x2F; since it&#x27;s not all too different from &#x2F;opt.
评论 #11436165 未加载
评论 #11435483 未加载
评论 #11434929 未加载
评论 #11436500 未加载
jonathankorenabout 9 years ago
I thought this was about people still misreading URLs more than 20 years since the popularization of the web as &quot;example-dot-com-backslash-tour&quot;<p>I&#x27;ve never understood that. The only way I could explain it in the 90s was because &quot;computers use backslashes&quot; due to the ubiquitousness of DOS and Windows paths. Now, who types a path on their local machine besides developers using a command line?
d33about 9 years ago
Would that involve also adding smb:&#x2F;&#x2F;HOSTNAME as opposed to \\HOSTNAME?
评论 #11435548 未加载
评论 #11437051 未加载
mikestewabout 9 years ago
I don&#x27;t even have a working Windows image to try the new bashy goodness, but this was my first thought when it was announced: what about the slash&#x2F;backslash difference? But even twenty years ago, bouncing back and forth between DOS&#x2F;Windows and some flavor of Unix, I wished MSFT would get with the program and ditch the hard-to-reach backslash.
评论 #11433474 未加载
skywhopperabout 9 years ago
I think this post is a little bit confused, since it talks about Bash in Windows, but I&#x27;ve seen no evidence that Bash supports backslash as a path separator in Windows. I agree it&#x27;s unfortunate that backslash paths are still around, but I guarantee you that won&#x27;t be the most annoying issue with running Linux userspace tools on Windows.
gozur88about 9 years ago
The really sucky thing about working on Windows is the paths. On Linux my applications are in &#x2F;opt or &#x2F;usr&#x2F;apps. On Windows the path names seem super long and include all sorts of parens and spaces and such.
评论 #11435645 未加载
dandareabout 9 years ago
Why is backslash called BACK slash when it actually points forward?<p><a href="http:&#x2F;&#x2F;ux.stackexchange.com&#x2F;questions&#x2F;92390&#x2F;why-is-backslash-called-back-slash-when-it-actually-points-forward" rel="nofollow">http:&#x2F;&#x2F;ux.stackexchange.com&#x2F;questions&#x2F;92390&#x2F;why-is-backslash...</a>