You are here:

C++/Programming Language Source Files Business Rules.

Advertisement


Question
QUESTION: Dear Zlatko

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: Hello Prashant

You could use any extension you like for your new language, but if you use a popular extension, you may cause some undesired effects or cause confusion.

For example, on UNIX/Linux, there is a program build facility called Make, and the files instructing Make are called makefiles. Within the Make system, there are automatic ways of handling certain extensions. For example, a .c extension will call the C compiler. You can override the operation within the makefile, so that the .c extension calls your language compiler, but then you would lose the ability of handling real C files within that makefile.

On Windows, you could give your language source files any extension, but if you gave them say a .bat, or .exe extension, you would not be able to open them with a mouse click. Doing so would cause the operating system to do the default operation on them, which is to run them. It also becomes confusing to people who receive your files.

I suggest you stay away from the popular extensions, especially if they conflict with other languages which you or your peer group are using.

There are always limits to file-name sizes, usually 255 characters, but extensions are not limited to the usual 3 or 4 characters.

Best regards.
Zlatko

---------- FOLLOW-UP ----------

File Naming Extensions
File Naming Extensions  
QUESTION: Dear Zlatko

Thank you.

1. Are Programming Language Source Files extensions Case Sensitive for compilation ?

For example :

a. helloworld.cs
b. helloworld.CS

Will it compile successfully for both the files ?

2. As you mention stay away from the popular extensions, especially if they conflict with other languages then in this case by creating a excel workbook database consisting of Programming Languages, Binary Files, Configuration files, Ascii Files, Device Drivers, Web Documents,Office Automation files,Image Files, Audio Files, Video files etc excel worksheets for each of those could be useful before actually designing a new compiler for the Programming Language ?

Note : Attached Image is a Single Excel Sheet for "Programming Languages". There will be different worksheets for different file extensions.

Awaiting your inputs,

Thanks & Regards,
Prashant S Akerkar

Answer
Hi

In Windows, filenames are not case sensitive, so the C# would compile a .CS file. In fact, the two files

a. helloworld.cs
b. helloworld.CS

could not exist together in the same folder because Windows is not case sensitive.

Best regards
Zlatko

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2016 About.com. All rights reserved.