0

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.

  • 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. – Jörg W Mittag Nov 6 '15 at 15:07
  • 1
    @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 Nov 6 '15 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 Nov 6 '15 at 16:48
6

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.

  • Ah, okay. The piece of information I was missing was how Unix systems handle file extensions. Thank you. – person27 Nov 7 '15 at 16:19

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