Coding Conventions - Language Factors

Language Factors

All software practitioners must grapple with the problems of organizing and managing very many detailed instructions, each of which will eventually be processed in order to perform the task for which it was written. For all but the smallest software projects, source code (instructions) are partitioned into separate files and frequently among many directories. It was natural for programmers to collect closely related functions (behaviors) in the same file and to collect related files into directories. As software development evolved from purely procedural programming (such as found in FORTRAN) towards more object-oriented constructs (such as found in C++), it became the practice to write the code for a single (public) class in a single file (the 'one class per file' convention). Java has gone one step further - the Java compiler returns an error if it finds more than one public class per file.

A convention in one language may be a requirement in another. Language conventions also affect individual source files. Each compiler (or interpreter) used to process source code is unique. The rules a compiler applies to the source creates implicit standards. For example, Python code is much more consistently indented than, say Perl, because whitespace (indentation) is actually significant to the interpreter. Python does not use the brace syntax Perl uses to delimit functions. Changes in indentation serve as the delimiters. Tcl, which uses a brace syntax similar to Perl or C/C++ to delimit functions, does not allow the following, which seems fairly reasonable to a C programmer:

set i 0 while {$i < 10} { puts "$i squared = " incr i }

The reason is that in Tcl, curly braces are not used only to delimit functions as in C or Java. More generally, curly braces are used to group words together into a single argument. In Tcl, the word while takes two arguments, a condition and an action. In the example above, while is missing its second argument, its action (because the Tcl also uses the newline character to delimit the end of a command).

Read more about this topic:  Coding Conventions

Famous quotes containing the words language and/or factors:

    It would seem as if the very language of our parlors would lose all its nerve and degenerate into palaver wholly, our lives pass at such remoteness from its symbols, and its metaphors and tropes are necessarily so far fetched.
    Henry David Thoreau (1817–1862)

    The economic dependence of woman and her apparently indestructible illusion that marriage will release her from loneliness and work and worry are potent factors in immunizing her from common sense in dealing with men at work.
    Mary Barnett Gilson (1877–?)