📜 ⬆️ ⬇️

Slash and backslash: milestones on the way

A bit of history


Slash

The appearance of a slash is attributed to the times of the Roman Empire. In the early stages of modernity, in Fracture [ 1 ], which was widespread throughout Europe in the Middle Ages, slash (/) was used instead of a comma, while double slash (//) was used instead of a dash. The double slash eventually became a symbol similar to the equal sign (=), and later was further simplified to a dash or hyphen [ 2 ].

Backslash

Bob Boehmer introduced a backslash (\) into the ASCII character set, September 18, 1961, as a result of studying the frequency of using characters found in particular in programs on ALGOL. Then, along with the backslash, square brackets were included in the standard.
In particular, \ was introduced so that the boolean operators ALGOL'a AND and OR could be represented using ASCII characters as "/ \" and "\ /" respectively [ 3 , 4 ].
How did it happen that historically the Orthodox slash was replaced by its mirror image, introduced as an auxiliary character specifically for an already dead language?

The Russian-language Wikipedia says this:
In the DOS and Windows operating systems of Microsoft and their counterparts from other developers, the backslash is used to separate directory (directory) names when specifying the path to the file. The direct slash used for this in Unix could not be used in MS-DOS, because it was already used to specify the command line keys (inherited from CP / M, where MS-DOS command “dir / w” was written as “dir / w ") [ 5 ].

Since this explanation didn’t satisfy me too much, I had to find the article “ Why is the DOS path character" \ "? ”[ 6 ], which completely satisfied my curiosity. Free translation of selected parts in my performance:
The fact that the "/" character clashed with the path separator of another relatively popular OS was not directly connected with the developers - after all, DOS did not support directories, just files in the same root directory.
For MS-DOS 2.0 (in which the support of directories appeared), DOS designers chose a hybrid version - they already had drive names inherited from DOS 1.0, so the developers had to use them. And in addition to the drive names, they decided to use the * nix-style method of defining the directory hierarchy — instead of using the directory in the file name (as was done in VMS and DEC-20), they simply made the directory and file name integral parts of the path. But there was a problem with it. It was impossible to use the path separator * nix (/), for the reason that the slash was already used as a key separator.
What did they do? Of course they could use "." as in DEC, but the dot has already been used as a separator between the file name and the extension. Therefore, they chose the best option from the rest - the symbol "\", which was visually similar to "/".This was how the" \ "symbol was chosen to separate the paths in DOS.
By the way, there is a little secret about MS-DOS. The DOS developers were not happy with this state of affairs - they used Xenix [ 7 ] for mail and other things, so they were familiar with the structure of * nix commands. Therefore, they added to the OS the ability to take as a separator both "/" and "\" (it works today, by the way - try executing the "notepad c: /boot.ini" under XP (if your user has admin rights)) . Further more. They added an undocumented system call to change the key delimiter character. And they updated the utilities to support this flag. They even added the SWITCHAR parameter to the config.sys, which will allow the user to set the key divider to "-". In this way, MS-DOS could be turned into an * nix-style OS using "-switch", and paths with a separator "/".
')

Actually what is it all about?


I was led to sort out the following situation.
The task was to set up a reporting system for automated tests. We use two types of tests - Selenium (functional) and Jmeter (stress). Actually there was nothing difficult in this - for these purposes there is a completely open-source project called logging selenium [ 8 ] and plugin for maven - chronos [ 9 ]. Having set everything up and tested the reports locally, I began to integrate with our CI - TeamCity. It was here that the very surprise that awaited me to write this article waited for me.
After all the tests were completed, the report on the Selenium tests was as follows:

image

Everything was perfectly displayed, and there were no differences from the local version.
But the report, which was displayed for Jmeter-tests, did not inspire enthusiasm:

image
Completely missing all the images on the page.
After viewing the source code of the page, it became clear that the backslash was to blame. Links to images were specified in this format:

<img src="images\gc-performancetest.png"> 

In fairness it is worth noting that the images were missing in Firefox, but perfectly displayed in IE. Although if IE did not display the resources in the URI of which there is a backslash, as a Windows path separator, then another, and not without that tainted, Indian programmer’s reputation would be another flaw.

In general, after some deliberation, it became clear that somewhere inside chronos'a File.separator is used, which is responsible for the appearance of a backslash in the ways of resources and problems with displaying graphs in reports. Downloading the source code of the plug-in and correcting the corresponding line in which the URL was formed solved the problem and made it possible to enjoy the beautiful graphs that are generated based on the results of the JMeter tests.

image
image

In conclusion, I would like to caution against the mindless use of the native File.separator - this does not always lead to cross-platform, and in some cases may even cause new bugs. The usual slash works in Windows (often), works in * nix, Java, and finally it should be respected by at least seniority, since it is one and a half thousand years older than its looking-glass brother.

PS: Thanks to Alexander Yastrebov for clarifying the history of C.

Source: https://habr.com/ru/post/120652/


All Articles