edit: I now understand this is a reference to a comic that was published when I was five years old. Hah.
edit: I now understand this is a reference to a comic that was published when I was five years old. Hah.
File extensions should only be used by people. The OS should have other ways of knowing the file type. And ".txt" is redundant. The default assumption should be "text" and only other file types should require extensions. IMHO.
Just looking at extensions can be misleading because not all files have extensions and some extensions correspond to multiple types of files. In general, no method will be perfect because no modern OS provides dedicated file typing (some older operating systems stored the file type as metadata, although even that breaks down at the boundary between your computer and the rest of the world). The imperfection is usually manageable, depending on the type of file (which is the real answer to your question - it depends on why you want to know).
Applications that won't open what I tell them to because they disagree about the file type are just broken. (Having to rename files whenever I want to open them is annoying. Having to replace a good piece of software because it refuses to follow instructions is even more annoying.)