Source code

Source code
An illustration of Java source code with prologue comments indicated in red, inline comments indicated in green, and program code indicated in blue

In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source code, which can then be automatically translated to binary machine code that the computer can directly read and execute. An interpreter translates to machine code and executes it on the fly, while a compiler only translates to machine code that it stores as executable files; these can then be executed as a separate step.

Most computer applications are distributed in a form that includes executable files, but not their source code, which is useful to a user, programmer, or system administrator who wishes to modify the program or understand how it works.

The source code which constitutes a program is usually held in one or more text files stored on a computer's hard disk; usually these files are carefully arranged into a directory tree, known as a source tree. Source code can also be stored in a database (as is common for stored procedures) or elsewhere.

Source code also appears in books and other media; often in the form of small code snippets, but occasionally complete code bases; a well-known case is the source code of PGP.

The notion of source code may also be taken more broadly, to include machine code and notations in graphical languages, neither of which are textual in nature. An example from an article presented on the annual IEEE conference on Source Code Analysis and Manipulation:[1]

For the purpose of clarity ‘source code’ is taken to mean any fully executable description of a software system. It is therefore so construed as to include machine code, very high level languages and executable graphical representations of systems.[2]

The code base of a programming project is the larger collection of all the source code of all the computer programs which make up the project.

It has become common practice to maintain code bases in version control systems.

Contents

Organization

The source code for a particular piece of software may be contained in a single file or many files. Though the practice is uncommon, a program's source code can be written in different programming languages.[3] For example, a program written primarily in the C programming language, might have portions written in assembly language for optimization purposes. It is also possible for some components of a piece of software to be written and compiled separately, in an arbitrary programming language, and later integrated into the software using a technique called library linking. This is the case in some languages, such as Java: each class is compiled separately into a file and linked by the interpreter at runtime.

Yet another method is to make the main program an interpreter for a programming language[citation needed], either designed specifically for the application in question or general-purpose, and then write the bulk of the actual user functionality as macros or other forms of add-ins in this language, an approach taken for example by the GNU Emacs text editor.

Moderately complex software customarily requires the compilation or assembly of several, sometimes dozens or even hundreds, of different source code files. In these cases, instructions for compilations, such as a Makefile, are included with the source code. These describe the relationships among the source code files, and contain information about how they are to be compiled.

The revision control system is another tool frequently used by developers for source code maintenance.

Purposes

Source code is primarily used as input to the process that produces an executable program (i.e., it is compiled or interpreted). It is also used as a method of communicating algorithms between people (e.g., code snippets in books).[4]

Programmers often find it helpful to review existing source code to learn about programming techniques.[4] The sharing of source code between developers is frequently cited as a contributing factor to the maturation of their programming skills.[4] Some people consider source code an expressive artistic medium.[5]

Porting software to other computer platforms is usually prohibitively difficult without source code. Without the source code for a particular piece of software, portability is generally computationally expensive.[citation needed] Possible porting options include binary translation and emulation of the original platform.

Decompilation of an executable program can be used to generate source code, either in assembly code or in a high level language.

Programmers frequently adapt source code from one piece of software to use in other projects, a concept known as software reusability.

Licensing

Software, and its accompanying source code, typically falls within one of two licensing paradigms: free software and proprietary software.

Generally speaking, software is free if the source code is free to use, distribute, modify and study, and proprietary if the source code is kept secret, or is privately owned and restricted. Note that "free" refers to freedom, not price. Under many licenses it is acceptable to charge for "free software". The first free software license to be published and to explicitly grant these freedoms was the GNU General Public License in 1989. The GNU GPL was originally intended to be used with the GNU operating system. The GNU GPL was later adopted by other non-GNU software projects such as the Linux kernel.

For proprietary software, the provisions of the various copyright laws, trade secrecy and patents are used to keep the source code closed. Additionally, many pieces of retail software come with an end-user license agreement (EULA) which typically prohibits decompilation, reverse engineering, analysis, modification, or circumventing of copy protection. Types of source code protection — beyond traditional compilation to object code — include code encryption, code obfuscation or code morphing.

Legal issues in the United States

In a 2003 court case in the United States, it was ruled that source code should be considered a constitutionally protected form of free speech. Proponents of free speech argued that because source code conveys information to programmers, is written in a language, and can be used to share humour and other artistic pursuits, it is a protected form of communication.

One of the first court cases regarding the nature of source code as free speech involved University of California mathematics professor Dan Bernstein, who had published on the internet the source code for an encryption program that he created. At the time, encryption algorithms were classified as munitions by the United States government; exporting encryption to other countries was considered an issue of national security, and had to be approved by the State Department. The Electronic Frontier Foundation sued the U.S. government on Bernstein's behalf; the court ruled that source code was free speech, protected by the First Amendment.

Quality

The way a program is written can have important consequences for its maintainers. Coding conventions, which stress readability and some language-specific conventions, are aimed at the maintenance of the software source code, which involves debugging and updating. Other priorities, such as the speed of the program's execution, or the ability to compile the program for multiple architectures, often make code readability a less important consideration, since code quality depends entirely on its purpose.

See also

References

  1. ^ SCAM Working Conference, 2001-2010.
  2. ^ Why Source Code Analysis and Manipulation Will Always Be Important by Mark Harman, 10th IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM 2010). Timişoara, Romania, 12–13 September 2010.
  3. ^ Extending and Embedding the Python Interpreter — Python v2.6 Documentation [1]
  4. ^ a b c Spinellis, D: Code Reading: The Open Source Perspective. Addison-Wesley Professional, 2003. ISBN 0-201-79940-5
  5. ^ "Art and Computer Programming" ONLamp.com, (2005)

External links


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Source Code — Tren similar al de la película, en Chicago Título Código fuente (España) 8 minutos antes de morir (Latinoamérica) …   Wikipedia Español

  • Source Code — Données clés Titre québécois Code source Titre original Source Code Réalisation Duncan Jones Scénario Ben Ripley Acteurs principaux Jake Gyllenhaal …   Wikipédia en Français

  • source code — A computer program written in its original programming language. In source code form a program is intelligible to a suitably trained human being. To be intelligible to a machine it is translated (compiled) into object code. + source code USA The… …   Law dictionary

  • source code — ˈsource code noun [uncountable] COMPUTING the form or language in which a computer program is written, which must be changed into machine code (= a different form using only numbers ) before a computer can understand it * * * source code UK US… …   Financial and business terms

  • Source Code — steht für: Quelltext, für Menschen lesbarer, in einer Programmiersprache geschriebener Text eines Computerprogrammes Source Code (Film), ein Spielfilm des Regisseurs Duncan Jones aus dem Jahr 2011 Diese Seite ist eine Begriffs …   Deutsch Wikipedia

  • source code — source codes N VAR Source code is the original form of a computer program as it is written by a programmer. It is then converted into code that the computer can understand. [COMPUTING] …   English dictionary

  • source code — n [U] technical the original form in which a computer program is written before it is changed into a form that a particular type of computer can read →↑machine code …   Dictionary of contemporary English

  • Source Code —   [engl.], Quellcode …   Universal-Lexikon

  • source code — source ,code noun count COMPUTING a set of instructions for a computer program that a computer PROGRAMMER understands and that are translated into instructions that a computer understands …   Usage of the words and phrases in modern English

  • source code — noun program instructions written as an ASCII text file; must be translated by a compiler or interpreter or assembler into the object code for a particular computer before execution • Hypernyms: ↑ASCII text file * * * noun : computer code in its… …   Useful english dictionary


Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.