The source code or is used for obtaining the object code, or executed by the interpreter. Changes are never executed over the object code, only over initial, with the subsequent repeated conversion to object.
Other important purpose of the source code — as the description of the program. In the text of the program it is possible to recover logic of her behavior. For simplification of understanding of the source code comments are used. There are also work benches allowing to receive automatically documentation on the source code — so-called generators of documentation.
Besides, the source code has many other applications. It can be used as the instrument of training; to the beginning programmers happens it is useful to investigate the existing source code for studying of the equipment and programming methodology. It is also used as the instrument of communication between experienced programmers, thanks to the (ideally) laconic and unambiguous nature. Sharing of the code by developers is often mentioned as the factor promoting improvement of experience of programmers.
Programmers often transfer the source code from one project to another that the name of reuse of the code (Software reusability) carries.
The source code — the major component for process of software porting on other platforms. Without source code of any part of software, porting or is too difficult, or in general it is impossible.
The source code of some part of software (the module, component) can consist of one or several files. The code of the program is not necessarily written only in one programming language. For example, often the programs written in the Si language for the purpose of optimization, contain code inserts in assembler language. Situations when some components or parts of the program are written in different languages, with the subsequent assembly in the uniform performed module by means of technology known as configuration of libraries (library linking) are also possible.
The difficult software at assembly requires use of tens, or even hundreds of files with the source code. In such cases for simplification of assembly the files of projects containing the description of dependences between files with the source code, and describing build process are usually used. These files may contain also other parameters of the compiler and design-time environment. Different files of the project can be applied to different design-time environments, and in some environments these files can be in a text format, the programmer, suitable for direct editing, using universal text editors, in other environments special formats are supported, and creation and changes of files is made using special instrumental programs. Files of projects usually include in the concept "source code". In the majority of modern language environments files of projects regardless of complexity of the other source code entering this project are surely used. Often mean by the source code also the resource files containing the different these, for example, graphics images necessary for assembly of the program.
For simplification of work with the source code, for joint work over the code the programming team, uses version management systems.
Unlike the person, for the computer there is no code "well written" or "badly written". But that as the code is written can influence process of maintenance of software strongly. It is possible to speak about quality of the source code in the context of the following parameters:
- readability of the code (including existence or lack of code comments — the blocks of any text lowered by the program compiler);
- ease in support, testing, debugging and elimination of errors, modification and porting;
- low complexity;
- low use of resources — memories, the processor, disk space;
- lack of the notes output by the compiler;
- lack of "garbage" — so-called "dead variables" (i.e. variables which are not used), operators who are never performed, comments from the previous versions of this code which lost the meaning, etc.
Not performed source code
Kopileftny licenses for the free software require distribution of the source code. These licenses are often used also for the works which are not programs — for example, documentation, images, data files for computer games.
In such cases the form of this work preferable to its editing is considered the source code. In the licenses intended not only for software, it can be also called the version in "a transparent format". It can be, for example:
- for the file compressed with data loss — the version without loss;
- for the bitmap image — the vector version;
- for the two-dimensional image of three-dimensional model — three-dimensional model
- for the image of the text — the same text in a text format;
and at last, the file if it meets the specified conditions or if more convenient version just did not exist.