3 ms·
Exactly, the logic is that "...", "....", "..*", etc. do not exist and besides users should have the common sense to not name stuff like that. Therefore it is m
by alexvoda 4y ago
Exactly, the logic is that "...", "....", "..*", etc. do not exist and besides users should have the common sense to not name stuff like that. Therefore it is much easier to just use the easier to write (assembler) and much faster solution.
- wizofaus 4y ago"Much" easier? It only needs 3 or 4 extra instructions to check for the null terminator at position 1 or 2 (0 based), which would be an improvement (only 1 or 2 letter filenames starting with dot would be hidden), and a couple of extra to check for dot at position 1. Given all the other things ls has to do, that's negligible.
- alexvoda 4y agoIndeed, but I believe, that is not the mindset of a person programming in an extremely constrained environment. Care for correctness is younger than "ls". For all intents and purposes at the time, it was a hack but it worked, and it worked well.
- wizofaus 4y agoI cut my teeth writing 8086 assembly code where keeping machine code size down to as few bytes as possible was necessary and that still strikes me as very lazy hack - saving a few bytes at the cost of an infinite number of possible filenames being hidden vs just two?
- GekkePrutser 4y agoCare for correctness was much more of a thing, when coding was a rare art and not a copy/paste from stack overflow to finish this week's sprint on time. There was also a lot less code in general so I would expect every line to be considered in much more detail. Also, 'laziness' tends to be a character flaw that manifests itself everywhere in a person's work, not just in one place. And Richie/Kernighan don't exactly have a bad reputation. I wonder if the '-a' parameter of ls appeared at the same time. If so it definitely wasn't an oversight.
- wizofaus 4y agoAre we sure there weren't other rules or conventions in place at the time that specified filenames had to start with an alphanumeric character?