Source code

from Wikipedia, the free encyclopedia
Source code example of the procedural programming language C . For examples of other languages, see separate articles .

Source code , including source code ( English source code ) or blurred code called, is in the computer science of to -read people , in a programming language written text of a computer program . In abstract terms, the source text for a program can also be referred to as a software document , which describes the program so precisely and completely that it can be translated from it completely automatically by a computer into machine language.

Source text can also be (partially or completely) non-textual form, for example as a graphical link between logical function blocks (for example in Simulink or as a UML diagram). The source text of a program can consist of several parts, for example it can be divided into several files (possibly different formats ) or it can be partly graphical, partly textual (e.g. UML, enriched with method implementations in the programming language used).



Source text is usually created manually using an integrated development environment or a text editor . But there are also code generators that extract the code from structured design documents, e.g. B. automatically generate structure diagrams or UML drafts. Another creation possibility are development tools that can generate code from drafts and vice versa from code. Manual changes to the code are subsequently incorporated back into the draft. In this way, " round-trip engineering " is possible, in which manual changes can be made at any point in the entire development process.

A simple text editor is usually sufficient to create the source text. With the help of language-specific editors, certain work steps can be simplified: Syntax highlighting allows parts of the source text to be highlighted in color according to their functionality, which improves readability. In order to improve readability, programmers usually adhere to certain source text formatting (e.g. indentation of subsections, upper / lower case ...). In some languages ​​a certain formatting of the source text is specified (e.g. Fortran -77, Python ), some integrated development environments can format the source text automatically (so-called beautifier ).

With larger programs that consist of many individual source files , information is sometimes managed that describes the interdependencies of the source text files . When compiling, this allows all the work steps to create the finished program to be carried out using a single call and only those parts to be recompiled that have been changed in the meantime or depend on changed components. Makefiles are an example of this .

For better documentation of the changes or the targeted synchronization of several programmers working at the same time, the source text is often saved with a software version management system, so that changes can be viewed later and, if necessary, reversed.

Translation and execution

Before the program that the programmer writes can be executed by a computer , it must be converted into machine language , i.e. into a sequence of bits that the computer can understand . This can be done either in advance by a compiler or - at runtime - by an interpreter or JIT compiler . In some programming languages, a combination of both variants is chosen, whereby first the source text of the respective language - usually initiated by the programmer - is translated into an abstract intermediate code, which is then transferred from a runtime environment to the machine code by an interpreter or JIT compiler becomes. This principle has the advantage that one and the same intermediate code can be executed on a large number of different platforms and therefore a separate version of the software does not have to appear for every system common on the market. Typical examples of such an intermediate code are the Java bytecode and the Common Intermediate Language . Using a debugger , the functionality of the program can be followed during runtime.

Arrive at the programming precompiler used, the by can programmers created original source u. a. Contain expressions / instructions that the actual programming language does not 'understand'. An example of this are SQL statements. Such instructions are translated into programming language instructions by the precompiler; The original instructions are usually inserted as comments in the often only temporarily generated source text data in order to remain visible. The procedure is similar when using macro processors : These generate commands in the respective programming language from the instructions formulated as macros .

The machine commands generated during compilation (with higher-level programming languages ​​usually several per source code instruction) generally represent the programmed function itself (for simple commands such as adding variable contents); this also includes calls to operating system functions . Alternatively, the compiler can execute a routine corresponding to the programmed instruction, e.g. E.g. from a program library , insert directly into the target code - or just a call command for such a routine (e.g. for a database call or for complex algorithms). Routines called in this way execute coded instructions in the source text as subroutines and thus 'encapsulated'.


Software and the associated source text are subject to copyright . They can be divided into two categories: proprietary software and open source software.

Open source programs, ie those that are under an “open source” license, are usually delivered directly with their source code, the modification and distribution of which is permitted by the license. This enables them to be studied, tested and adapted for specific needs. Proponents of the open source principle believe that this also improves the quality, since experts could better localize the errors and either fix them directly or provide the original programmers with better quality error messages. The possibility of checking open source software on the basis of its source code increases the user's trust in its correctness and functionality in the interests of the user. In this sense, free software is identical to open source software.

Proprietary software is usually delivered without source code ( closed source ) or only under particularly restrictive licenses. The protection of the customer / user then serve sometimes agreements to source code deposit (Source Code Escrow Agreements) . In the case of individually commissioned creation of custom software by third parties, the transfer of the source text is usually also agreed. For software that a user , for example a company, creates for their own purposes, license agreements are superfluous.

Other meanings

In a broader sense, source text also means the human-readable description of a rendered medium.

  • The source code of web pages is usually written in HTML .
  • The source text of Wikipedia articles is the text that the authors of the article enter. As with many dynamic web pages, the HTML code here is the result of transforming the wiki code into HTML and CSS . Thus, in the case of dynamic websites with source text, the generated HTML is often not meant, but the information source from which the website is generated.
  • Also, PostScript and other vector formats are un-changed "source code".
  • VHDL describes electronic circuits that can operate data processing in a simulator.

See also

Web links

Wiktionary: Source text  - explanations of meanings, word origins, synonyms, translations
Commons : Source code  - collection of images, videos and audio files

Individual evidence

  1. ^ Brian Kernighan : Programming in C - A Tutorial. (PDF; 71 kB) Bell Laboratories , 1974, archived from the original on December 10, 2005 ; accessed on September 15, 2018 (English).