4 ms·
/ vs. \ confuses me a lot, how do you remember them?
How do you know when to use what as a programmer and a superuser? Back slash vs forward slash confuse me a lot.
- beardyw 4y agoAs characters Forward Slash leans to the Right and is often the cause of division. Back Slash leans to the Left and has been involved in helping difficult characters escape. Both are employed as path separators.
- demetrius 4y agoIf you think about cursive writing (or an italic font, based on the cursive writing), the names are pretty straightforward. All letters in cursive and italic are slanted to the right. Iceland becomes Iceland, with top part of each letter going right and bottom part going left. So, if you just wanted to write a slash in cursive, you'd end up with /. That's just a normal slash, a result of writing a line according to the general direction of the writing. And the slash that defies the general direction of the writing is 'backslash'. For this, you have to move your hand back from your normal writing position.
- ifqwz 4y agoThis reminds me of people who even in adulthood confuse "left" and "right" - I have always wondered how that happens.
- alrlroipsp 4y agoIt happens because not everyone is wired the same as you are. You probably already noticed this in other fields of life.
- colechristensen 4y agoThe piece of the brain that handles that works better for some people than others. Whether it’s genetic or developmental, it’s just a thing which happens to some people.
- 9wzYQbTYsAIc 4y agohttps://pubmed.ncbi.nlm.nih.gov/2319959/ https://pubmed.ncbi.nlm.nih.gov/2319959/ “It follows that the participants were not in a state of complete ignorance. Rather, they relied upon extraneous knowledge of either a general or a specific nature (bias and schema hypotheses, respectively), whose importation into this domain was in fact invalid. The resulting belief that coin portraits face left was not right.”
- deleted 4y ago[deleted]
- stjohnswarts 4y agoI remember that / is the right way to do it as done on my favorite OS (Linux) left is the incorrect way pursued by a lesser operating system (windows) but it still works there despite being the obviously wrong way to do it, but windows has to do things bassackwards. Also a lot of times "/" works on both, depending on API/file operations. On linux \ is mostly used to escape things in quotes and regex's.
- jaitaiwan 4y agoForward slash unless windows is pretty much how I remember it. Character escapes are universally backslash. If you're asking me how to remember the difference between them, I just imagine I'm the line, then the question is: does it look like I'm falling forward or backward.
- dusted 4y ago/ is what seperates paths and ends your tags. \ is what escapes your special characters. But back in the olden days, I thought \ is what windows uses in paths, / is what URLs use.
- kevin_b_er 4y agoFor the usage? I guess it is natural now, like left and right. For the names? The little stick figure is leaning forward or backward in reading order.
- solardev 4y agoThanks for the stick figure tip! That's so helpful.
- mikewarot 4y agoSlash - Normal fractions, division, and conversational use all use / as in 1/2 x/y he/she etc. I describe it over the phone as the one under the question mark. Backslash - Not used much except in Linux, C, etc. As others have said, path separations, quoting characters, etc. \n is a linefeed in most quoted strings. I describe this as the slash not under the question mark Now, paths on Unix use / because \ is already in use... so you end up with /home/mike Lastly, DOS, and thus Windows, had to use \ because they needed to be as different as possible from Unix (to avoid lawsuits)... and thus you end up with C:\DOS
- 9wzYQbTYsAIc 4y agoRead the manual, memorize, and make use of muscle memory. edit: also, you can try anchoring, a memory technique https://fs.blog/mental-model-anchoring/ https://fs.blog/mental-model-anchoring/
- stop50 4y agoOn unix: no problem backslashes are only used as escapes windows: as escapes no problem, for paths, take the next best class for pathbuilding and use it and double the backslashes at every position it is given to external output(printf, ...)(and double it at every time the output is going through another parsing.
- themodelplumber 4y agoI remember making so many mistakes with those. Still do sometimes. But at first I know I had to remember them like this: "Top is left side, or top is right side?" like where is the literal top of the shape at. Then I made a little memory aid out of that. Comparing the usage in OSes: You can imagine the backslash as the front of the W in Windows, and the forward slash as the front of an italic L for Linux, for example. Or any of a million other ways to think about it, probably. My sympathies though, it's not fun or cool and while the post title may not describe my feeling at the moment, it's fun to see someone else working through it like this, because we all have little battles to fight along the journey.
- 9wzYQbTYsAIc 4y agobackslash can also the left side of the person and the forward slash the right side of the person in the classic hands up in the air emoji: \o/
- schoen 4y agoMaybe you could think of the forward slash as making progress on a graph. Things are growing over time, so (at least culturally in a business and economic context) they're getting better, so we're "moving forward".
- schoen 4y agoAfter reading the replies, I'm confused about whether you're having more trouble with the names "back" and "forward" or more trouble remembering the meanings assigned to them in programming languages. Some people seemed to take your question one way and some people seemed to take it the other way. In the Windows command line, \ is the path separator and / is for options. That diverges from the Unix command line, where / is the path separator and \ is for escaping special characters ("use the literal meaning of this character, rather than the special meaning"). The Unix command line uses hyphen (-) for options. Most programming languages use \ for escaping special characters, so \" would often be a literal quotation mark and \\ would often be a literal backslash. For example, in many languages writing "\"" will give a one-byte-long string containing a quotation mark character. Here the backslash escapes the second quotation mark, cancelling out its meaning of ending the string. https://en.wikipedia.org/wiki/Use%E2%80%93mention_distinction https://en.wikipedia.org/wiki/Use%E2%80%93mention_distinctio... https://en.wikipedia.org/wiki/Escape_character https://en.wikipedia.org/wiki/Escape_character The second article mentions a further subtlety, which is that escaping a character that doesn't have a special meaning sometimes adds a special meaning. For example, "\t" is used in many programming languages to write the tab character (ASCII 9), while "\n" is used to write the newline character (ASCII 10).
- 9wzYQbTYsAIc 4y agoAlso, path separation in URIs uses / as a path separator but // to identify the authority https://www.rfc-editor.org/rfc/rfc3986#section-3 https://www.rfc-editor.org/rfc/rfc3986#section-3
- schoen 4y agoI think Windows also does that with file sharing where it uses remote references like "\\host\path".
- 9wzYQbTYsAIc 4y agoAnd is it a \ or / between domain and username in Windows? Trial and error, every time on that one.