Long ago, when the Unix file system was being developed, “pseudo-files” appeared in it
.
and
..
to simplify moving between directories. It seems that
..
was added in Version 2, when the file system became hierarchical (in the first version it was arranged quite differently). But these “pseudo-files” littered the output of
ls
, and either Ken, or Dennis, added a simple check to the
ls
code:
if (name [0] == '.') continue;
In fact, the programs were then written in assembler, but the essence of the test was exactly the same.
It would be better to implement this check more deployed:
if (strcmp (name, ".") == 0 || strcmp (name, "..") == 0) continue;
- but what's the difference, the main thing is that everything worked.
This had two far-reaching consequences.
Firstly, a precedent was created for such “careless optimizations” in Unix, and a lot of other lazy programmers injecting bugs into their programs in the same way: in particular, files starting from a point are often ignored where they should be processed.
')
Secondly, and much worse, “hidden files”, starting with a dot, were perceived as a “feature”. A lot of lazy programmers began to create such files in the home directory of each user. There are not so many programs installed on my machine, but there are about a hundred hidden files in my home directory, and I don’t even know about most of them why they are needed, and whether they are needed at all. Every search for files in my home directory slows down at times due to all this invisible garbage.
I'm sure that “hidden files” appeared in Unix
by mistake , as an unexpected result of that “optimization” in
ls
.
How many bugs, how many wasted CPU cycles, how much human annoyance can be explained only by the fact that 40 years ago the authors of Unix saved half a line of code?
Remember this case every time you want to “cut the corner” in your own code.
(Many argue that files with a dot in the system are necessary. Yes, the files themselves are necessary, but the dot in their names is not. It would be much more convenient to store them in
$HOME/cfg
or in
$HOME/lib
; and this is how we did in Plan 9, in which there are no "hidden files. We can learn from our mistakes.)