Source code

Simple C-language source code example, a procedural programming language. The resulting program prints "hello, world" on the computer screen. This first known "Hello world" snippet from the seminal book The C Programming Language originates from Brian Kernighan in the Bell Laboratories in 1974.[1]

In computing, source code is any collection of code, possibly with comments, written using[1] a human-readable programming language, usually as plain text. The source code of a program 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. The source code is often transformed by an assembler or compiler into binary machine code that can be executed by the computer. The machine code might then be stored for execution at a later time. Alternatively, source code may be interpreted and thus immediately executed.

Most application software is distributed in a form that includes only executable files. If the source code were included it would be useful to a user, programmer or a system administrator, any of whom might wish to study or modify the program.


The Linux Information Project defines source code as:[2]



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.[4]

Often there are several steps of program translation or minification between the original source code typed by a human and an executable program. While some, like the FSF, argue that an intermediate file "is not real source code and does not count as source code",[5] others find it convenient to refer to each intermediate file as the source code for the next steps.


The earliest programs for stored-program computers were entered in binary through the front panel switches of the computer. This first-generation programming language had no distinction between source code and machine code.

When IBM first offered software to work with its machine, the source code was provided at no additional charge. At that time, the cost of developing and supporting software was included in the price of the hardware. For decades, IBM distributed source code with its software product licenses, until 1983.[6]

Most early computer magazines published source code as type-in programs.

Occasionally the entire source code to a large program is published as a hardback book, such as Computers and Typesetting, vol. B: TeX, The Program by Donald Knuth, PGP Source Code and Internals by Philip Zimmermann, PC SpeedScript by Randy Thompson, and µC/OS, The Real-Time Kernel by Jean Labrosse.



A more complex Java source code example. Written in object-oriented programming style, it demonstrates boilerplate code. With prologue comments indicated in red, inline comments indicated in green, and program statements indicated in blue.

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.[7] 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. In some languages, such as Java, this can be done at run time (each class is compiled into a separate file that is 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.

The code base of a computer 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. Moderately complex software customarily requires the compilation or assembly of several, sometimes dozens or maybe 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 programming relationships among the source code files and contain information about how they are to be compiled.



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




Legal aspectsEdit

The situation varies worldwide, but in the United States before 1974, software and its source code was not copyrightable and therefore always public domain software.[10]

In 1974, the US Commission on New Technological Uses of Copyrighted Works (CONTU) decided that "computer programs, to the extent that they embody an author's original creation, are proper subject matter of copyright".[11][12]

In 1983 in the United States court case Apple v. Franklin it was ruled that the same applied to object code; and that the Copyright Act gave computer programs the copyright status of literary works.

In 1999, in the United States court case Bernstein v. United States it was further ruled that source code could 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 humor and other artistic pursuits, it is a protected form of communication.[13][14][15]


Copyright notice example:[16]

Copyright [yyyy] [name of copyright owner]



An author of a non-trivial work like software,[12] has several exclusive rights, among them the copyright for the source code and object code.[17] The author has the right and possibility to grant customers and users of his software some of his exclusive rights in form of software licensing. Software, and its accompanying source code, can be associated with several licensing paradigms; the most important distinction is open source vs proprietary software. This is done by including a copyright notice that declares licensing terms. If no notice is found, then the default of All rights reserved is implied.

Generally speaking, software is open source 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. One of the first software licenses to be published and to explicitly grant these freedoms was the GNU General Public License in 1989; the BSD license is another early example from 1990.

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.



See alsoEdit


  1. ^ a b "Programming in C: A Tutorial" (PDF). Archived from the original (PDF) on 23 February 2015.
  2. ^ The Linux Information Project. "Source Code Definition".
  3. ^ SCAM Working Conference, 2001–2010.
  4. ^ 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.
  5. ^ "".
  6. ^ Martin Goetz (8 February 1988). "Object-code only: Is IBM playing fair?". Computerworld. Vol. 22 no. 6. p. 59. It was in 1983 that IBM reversed its 20-year-old policy of distributing source code with its software product licenses.
  7. ^ "Extending and Embedding the Python Interpreter".
  9. ^ "Art and Computer Programming", (2005)
  10. ^ P., Liu, Joseph; L., Dogan, Stacey (2005). "Copyright Law and Subject Matter Specificity: The Case of Computer Software". New York University Annual Survey of American Law. 61 (2).
  11. ^ Apple Computer, Inc. v. Franklin Computer Corporation Puts the Byte Back into Copyright Protection for Computer Programs in Golden Gate University Law Review Volume 14, Issue 2, Article 3 by Jan L. Nussbaum (January 1984)
  12. ^ a b Lemley, Menell, Merges and Samuelson. Software and Internet Law, p. 34.
  13. ^ "Info" (PDF). Retrieved 27 December 2019.
  14. ^ Bernstein v. US Department of Justice on
  15. ^ EFF at 25: Remembering the Case that established Code as Speech on by Alison Dame-Boyle (16 April 2015)
  16. ^ "License". Retrieved 27 December 2019.
  17. ^ Hancock, Terry (29 August 2008). "What if copyright didn't apply to binary executables?". Free Software Magazine. Retrieved 25 January 2016.


External linksEdit