Search code examples
compiler-constructionprogramming-languages

Can a compiler compile code without an extention?


This is a random question that came to me, obviously I wouldn't want to do it because it is bad practice, but is it possible to compile and run code from a file without an extension? Does this work with c,c++, java, python, any languages? If it does, than is the extension more of a stylist property or does it have a purpose for something else?


Solution

  • Extension doesn't mean anything. Just a way to help you keep track of what file is what. (also helps stuff like a GUI explorer open the file in the right program).

    (Java might care becuase the language spec says a source files end in .java, but there may be a way to hack it).