You are here:

C++/Programming Language Source Files Business Rules.

Advertisement


Question
Dear Vijayan

http://en.wikipedia.org/wiki/Source_code

There are some queries from my side regarding Programming Language Source code file naming conventions/rules.

1. Can Programming Language Source code file naming extensions be duplicated ?.

For examples :

C Language -> .c extension

C ++ Language -> .cpp

FORTRAN -> .for

Pascal -> .pas

Java -> .java

C# -> .cs

Cobol -> .cob

Does it become mandatory while designing any new compiler or interpreter for the Programming Language to see that the already
Source code file names extensions are not being used OR this is done as a part of Good Programming Language Source files naming convention practice ?

As an example, the source code file name for Cobol is .cob. Now a new compiler or interpreter for the Programming Language "Cobalt" can have the same source code file name say .cob ?.

2. Are there any restrictions in setting maximum string length for the Source Code File Naming extension ?.

For examples :

.c -> 1
.cs -> 2
.cpp -> 3
.java -> 4

i.e. Can the New Programming Language "COBALT" source code file name be given as .cobalt which is six characters in length.

3.Can the New Programming Language Source files be given extensions as

a. .exe,.com,.dll which are Binary Files extensions.
b. .bat which are Batch Files extensions.  
c. .sys which are Configuration files extensions.
d. .txt ASCII Text.
e. .doc,.xls,.ppt,.mdb,.html,.xml,.vxd etc.

Awaiting your reply,

Thanks & Regards,
Prashant S Akerkar

Answer
> Can Programming Language Source code file naming extensions be duplicated ?
> Does it become mandatory while designing any new compiler or interpreter for the Programming
> Language to see that the already Source code file names extensions are not being used
> OR this is done as a part of Good Programming Language Source files naming convention practice

Except for a few exceptions (Java being a notorious example), programming languages in general do not insist on a particular pattern for naming files. The common extensions in use (for example .cc, .cpp, .cxx for C++ implementation files or .h, .hpp, .hxx for C++ header files) are just convenient practical conventions.

Toolchains quite often look at the extension of a file if it is a well known extension. For example, gcc would try to compile myfile.for as a FORTRAN file:
gcc myfile.for



> Are there any restrictions in setting maximum string length for the Source Code File Naming extension ?.

No, there are none.

Some filesystems limit the length of the extension (such as the classic FAT file system not allowing more than three characters). This created the need to condense a file's type into three characters. And the result was not a happy one; it caused problems for Java, it led to abbreviations of well known extensions - for example .html to .htm . And it led to conflicts - for example, .rpm is used for both Linux RPM packages and RealPlayer Media files.

Most current filesystems do not impose such severe restrictions of the length of a file name and extensions could be much more descriptive.  



> 3.Can the New Programming Language Source files be given extensions as
> a. .exe,.com,.dll which are Binary Files extensions.
> ...

Theoretically there are no restrictions. In practice it is not a good idea. Most tools (particularly those in a GUI environment) determine the file's generic type from the extension and this would lead to a lot of confusion.  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


vijayan

Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.

Experience

about 15 years or so

Education/Credentials
post graduate engineer

©2016 About.com. All rights reserved.