2

I noticed a long time ago that a number of files included with projects, especially files called README, LICENSE, and so forth, frequently have no filename extension. This is strange to me because it requires the reader of such files to perform some extra commands to open it.

I visited Is it good programming practice to create files with no extension?, but while the answer suggests it's not good to have no filename extension, it doesn't answer my question of whether there is a motive in not including one.

I'd like to know if there are reasons not to include file extensions and what those reasons might be.

3
  • 5
    Reading a text file with file extension .txt: less README.txt. Reading a text file without file extension: less README. What are those "extra commands" I need to "perform" to open it? If anything, the version without extension has 4 keystrokes less than the one with extension. (Although in both cases, I actually only type le<TAB> R<TAB>), so it's 5 keystrokes either way. Commented Nov 6, 2015 at 15:07
  • 2
    @JörgWMittag I suspect they're talking about where windoze asks you which application to use to open a file since this can't be inferred due to the lack of extension
    – Robbie Dee
    Commented Nov 6, 2015 at 16:40
  • I suppose if there was a cross-platform project it would make sense to use conventions that aren't obviously for one OS or another.
    – Robbie Dee
    Commented Nov 6, 2015 at 16:48

1 Answer 1

8

It all depends on your operating system of choice and how they implemented metadata to assist with determining the file type.

Unix-based OS's traditionally use the first four bytes of the file to denote its type.The dot character isn't treated as anything special and no file extension is needed for well behaved utilities and apps to read a file correctly.

DOS, and later Windows, traditionally use "." as a special character to denote the end of the file name and the start of the file type metadata (the file extension). Apps in Windows typically rely on the extension to denote the file's type and to read it correctly.

Using the extension, eg README.txt, means the file is more portable, as Linux doesn't care about it and Windows knows what to do with it. That's the reason why it's generally recommended that they be used. If your world is very Linux-orientated and the README file won't typically be read by a Windows user, then there's little point in cluttering the filename with a .txt extension and not putting the extension on it fits better with Linux idioms.

3
  • Ah, okay. The piece of information I was missing was how Unix systems handle file extensions. Thank you.
    – kettlecrab
    Commented Nov 7, 2015 at 16:19
  • Interesting, but why the LICENSE file specifically has no extension in most repositories while the other files have one?
    – Géry Ogam
    Commented Mar 17, 2023 at 0:15
  • 1
    @GéryOgam, that is a good question. Given that Microsoft owns GitHub these days, it's odd that they haven't "encouraged" fixing that. Windows 11 still doesn't really understand files with no extension. Trying to open LICENSE from windows explorer brings up a "choose an app" with "Just Once" being the only option, ie it can't remember how to open it. Renaming that file to LICENSE.txt might make others thank you. But maybe not as really, who reads a licence file? ;-)
    – David Arno
    Commented Mar 17, 2023 at 16:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.