All Topics  
Source code

 

   Email Print
   Bookmark   Link






 

Source code



 
 
In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, source code (commonly just source) is any collection of statements or declarations written in some human-readable
Human-readable

The term "human-readable" refers to a representation of data that can be naturally Reading by humans. In most contexts, the alternative representation is a machine-readable format or medium of data primarily designed for reading by electronic, mechanical or optical devices, or computers....
 computer programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
. Source code allows the programmer to communicate with the computer using a reserved number of instructions.

The source code which constitutes a program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
 is usually held in one or more text file
Text file

A text file is a kind of computer file that is structured as a sequence of line . A text file exists within a computer file system. The end of a text file is often denoted by placing one or more special characters, known as an end-of-file marker, after the last line in a text file....
s, sometimes stored in databases as stored procedure
Stored procedure

A stored procedure is a subroutine available to applications accessing a relational database database management system. Stored procedures are actually stored in the database data dictionary....
s and may also appear as code snippets printed in books or other media.






Discussion
Ask a question about 'Source code'
Start a new discussion about 'Source code'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, source code (commonly just source) is any collection of statements or declarations written in some human-readable
Human-readable

The term "human-readable" refers to a representation of data that can be naturally Reading by humans. In most contexts, the alternative representation is a machine-readable format or medium of data primarily designed for reading by electronic, mechanical or optical devices, or computers....
 computer programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
. Source code allows the programmer to communicate with the computer using a reserved number of instructions.

The source code which constitutes a program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
 is usually held in one or more text file
Text file

A text file is a kind of computer file that is structured as a sequence of line . A text file exists within a computer file system. The end of a text file is often denoted by placing one or more special characters, known as an end-of-file marker, after the last line in a text file....
s, sometimes stored in databases as stored procedure
Stored procedure

A stored procedure is a subroutine available to applications accessing a relational database database management system. Stored procedures are actually stored in the database data dictionary....
s and may also appear as code snippets printed in books or other media. A large collection of source code files may be organized into a directory tree
Directory (file systems)

In computing, a directory, folder, catalog, or drawer is a virtual container within a digital file system, in which groups of files and other directories can be kept and organized....
, in which case it may also be known as a source tree.

A computer program's source code is the collection of files needed to convert from human-readable form to some kind of computer-executable form. The source code may be converted into an executable
Executable

In computing, an executable causes a computer "to perform indicated tasks according to encoded instruction ," as opposed to a file that only contains data ....
 file by a compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
, or executed on the fly
On the fly

Colloquial usageIn colloquial use, on the fly means something created when needed. The phrase is used: to explain that something wasn't planned ahead, or...
 from the human readable form with the aid of an interpreter
Interpreter (computing)

In computer science, an interpreter normally means a computer program that execution , i.e. performs, instructions written in a programming language....
.

The code base of a programming project is the larger collection of all the source code of all the computer program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
s which make up the project.

Purposes

Source code is primarily used as input to the process that produces an executable program (ie., it is compiled
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
 or interpreted). It is also used as a method of communicating algorithm
Algorithm

In mathematics, computing, linguistics and related subjects, an algorithm is a sequence of finite instructions, often used for calculation and data processing....
s between people (eg., code snippets in books).

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

In the arts, media are the materials and techniques used by an artist to produce a work....
.

Porting
Porting

In computer science, porting is the process of adapting software so that an executable Computer program can be created for a computing environment that is different from the one for which it was originally designed ....
 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 . Possible porting options include binary translation
Binary translation

In computing, binary translation is the emulation of one instruction set by another through translation of Machine language. Sequences of instruction s are translated from the source to the target instruction set....
 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.

Organization

The source code for a particular piece of software may be contained in a single file or many files. Though uncommon, a program's source code is not necessarily all written in the same programming language. For example, a program written primarily in the C programming language
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
, might have portions written in Assembly language
Assembly language

An assembly language is a low-level language for programming computers. It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture....
 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
Java (programming language)

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' 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, 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
Revision control

Revision control is the management of multiple revisions of the same unit of information. It is most commonly used in engineering and software development to manage ongoing development of digital documents like application source code, art resources such as blueprints or electronic models, and other projects that may be worked on by a team o...
 system is another tool frequently used by developers for source code maintenance.

Licensing

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

Free Software or software libre is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with minimal restrictions only to ensure that further recipients can also do these things and to prevent consumer-facing hardware...
 and proprietary software
Proprietary software

Proprietary software is a term coined by advocates of the free software movement to describe computer software which is the legal property of one party....
.

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
GNU General Public License

The GNU General Public License is a widely used free software license, originally written by Richard Stallman for the GNU project. The GPL is the most popular and well-known example of the type of strong copyleft license that requires derived works to be available under the same copyleft....
 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
Linux kernel

The Linux kernel is an operating system kernel used by a family of Unix-like operating systems. The term Linux distribution is used to refer to the various operating systems that run on top of the Linux Kernel....
.

For proprietary software, the provisions of the various copyright laws, trade secrecy
Trade secret

A trade secret is a formula, Best practice, process, design, Legal instrument, pattern, or compilation of information which is not generally known or reasonably ascertainable, by which a business can obtain an economic advantage over competitors or customers....
 and patent
Patent

A patent is a set of exclusive rights granted by a state to an inventor or his assignee for a term of patent in exchange for a disclosure of an invention....
s are used to keep the source code closed. Additionally, many pieces of retail software come with an end-user license agreement
Software license agreement

A software license agreement is a contract between a producer and a user of computer software which grants the user a software license. Most often, a software license agreement indicates the terms under which an end-user may utilize the licensed software, in which case the agreement is called an end-user license agreement or EULA...
 (EULA) which typically prohibits decompilation, reverse engineering
Reverse engineering

Reverse engineering is the process of discovering the technological principles of a device, object or system through analysis of its structure, function and operation....
, analysis, modification, or circumventing of copy protection
Copy protection

Copy protection, also known as content protection, copy prevention, or copy restriction, is a technology for preventing the reproduction of copyrighted software, movies, music, and other media....
. Types of source code protection -- beyond traditional compilation
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
 to object code -- include code encryption, code obfuscation or code morphing
Code morphing

Code morphing is one of the approaches to protect software applications from reverse engineering, analysis, modifications, and cracking used in obfuscating software....
.

Legal issues in the United States

In the United States, as of 2003, court systems are in the process of deciding whether source code should be considered a Constitutionally protected form of free speech. Proponents of the free speech argument claim 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. The opposing view is that source code is functional, more than artistic speech, and is thus not protected by First Amendment
First Amendment to the United States Constitution

The First Amendment to the United States Constitution is the part of the United States Bill of Rights that expressly prohibits the United States Congress from making laws "Establishment Clause of the First Amendment" or that prohibit the Free Exercise Clause of the First Amendment, laws that infringe the Freedom of speech in the United State...
 Rights of the U.S. Constitution.

One of the first court cases regarding the nature of source code as free speech involved University of California
University of California

The University of California is a public university system in the U.S. state of California. Under the California Master Plan for Higher Education, the University of California is a part of the state's three-tier public higher education system, which also includes the California State University system and the California Community Colleges s...
 mathematics
Mathematics

Mathematics is the study of quantity, structure, space, change, and related topics of pattern and form. Mathematicians seek out patterns whether found in numbers, space, natural science, computers, imaginary abstractions, or elsewhere....
 professor Dan Bernstein, who had published on the internet the source code for an encryption
Encryption

In cryptography, encryption is the process of transforming information using an algorithm to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key ....
 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
National security

The late political scientist Hans Morgenthau, author of Politics Among Nations, defines national security as the integrity of the national territory and its institutions....
, and had to be approved by the State Department
United States Department of State

The United States Department of State, often referred to as the State Department, is the United States Cabinet-level foreign affairs agency of the United States Federal government of the United States, similar to foreign ministries, foreign offices, ministries of external relations, etc....
. The Electronic Frontier Foundation
Electronic Frontier Foundation

The Electronic Frontier Foundation is an international non-profit organization advocacy and legal organization based in the United States with the stated purpose of being dedicated to preserving the right to freedom of speech, such as protected by the First Amendment to the United States Constitution, in the context of today's digital age ....
 sued the U.S. government
Federal government of the United States

The Federal Government of the United States is the central current reigning United States governmental body, established by the United States Constitution....
 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. Many source code programming style
Programming style

Programming style is a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers to read and understand source code conforming to the style, and help to avoid introducing errors....
 guides, 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 programs 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

  • Legacy code
    Legacy code

    Legacy code is source code that relates to a no-longer supported or manufactured operating system or other computer technology. The term can also mean code inserted into modern software for the purpose of maintaining an older or previously supported feature — for example supporting a serial interface even though many modern systems don...
  • Machine code
    Machine code

    Machine code or machine language is a system of instructions and data executed directly by a computer's central processing unit. Machine code may be regarded as a primitive programming language or as the lowest-level representation of a compiled and/or assembly language computer program....
  • Open-source software
    Open-source software

    Open source software is defined as computer software for which the source code and certain other rights normally reserved for copyright holders are provided under a computer software license that meets the Open Source Definition or that is in the public domain....
  • Obfuscated code
    Obfuscated code

    Obfuscated code is source code in a computer programming language that has been made difficult to understand. Programmers may deliberately obfuscate code to conceal its purpose, to deter reverse engineering, or as a puzzle or recreational challenge for readers....
  • Object code
  • Programming language
    Programming language

    A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
  • Programming style
    Programming style

    Programming style is a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers to read and understand source code conforming to the style, and help to avoid introducing errors....
  • Source code repository
  • Syntax highlighting
    Syntax highlighting

    Syntax highlighting is a feature of some text editors that displays text—especially source code—in different colors and typefaces according to the category of terms....


External links

  • - The most widely used free software license. Official website.
  • - by The Linux Information Project (LINFO)