In computer science, source code is any collection of statements or declarations written in some human-readable computer programming language. Source code is the means most often used by programmers to specify the actions to be performed by a computer.
The source code which constitutes a program is usually held in one or more text files, sometimes stored in databases as stored procedures 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, 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 file by a compiler, or executed on the fly from the human readable form with the aid of an interpreter.
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. 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, 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.
Source code is primarily used as input to the process that produces an executable program (ie., it is compiled or interpreted). It is also used as a method of communicating algorithms 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.
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 . Possible porting options include binary translation and emulation of the original platform.
Programmers frequently adapt source code from one piece of software to use in other projects, a concept known as software reusability.
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
|This article is outdated.|
In a 2003 court case in the United States, the courtTemplate:Which 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.
The way a program is written can have important consequences for its maintainers. Many source code programming style 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.
- China Compulsory Certificate
- Legacy code
- Machine code
- Open-source software
- Obfuscated code
- Object code
- Programming language
- Programming style
- Source code repository
- Syntax highlighting
- ↑ Extending and Embedding the Python Interpreter — Python v2.6 Documentation 
- ↑ 2.0 2.1 2.2 Spinellis, D: Code Reading: The Open Source Perspective. Addison-Wesley Professional, 2003. ISBN 0-201-79940-5
- ↑ "Art and Computer Programming" ONLamp.com, (2005)
- (VEW04) "Using a Decompiler for Real-World Source Recovery", M. Van Emmerik and T. Waddington, the Working Conference on Reverse Engineering, Delft, Netherlands, 9-12 November 2004. Extended version of the paper.
- Source Code Definition - by The Linux Information Project (LINFO)
- Google public source code search
- A publicly editable wiki of source code
- Online source code sharing
- "Obligatory accreditation system for IT security products (2008-09-22), may start from May 2009, reported by Yomiuri on 2009-04-24.". MetaFilter.com. http://www.metafilter.com/75061/Obligatory-accreditation-system-for-IT-security-products. Retrieved 2009-04-24.
- Programmer2programmer.Net - Live project source code
- SourceCodeHub.com - project source codesaf:Bronkode
ar:كود مصدري ast:Códigu fonte be:Крынічны код be-x-old:Крынічны код bs:Izvorni kod bg:Изходен код ca:Codi font cs:Zdrojový kód da:Kildekode de:Quelltext et:Lähtekood el:Πηγαίος κώδικας es:Código fuente eo:Fontkodo eu:Iturburu kode fa:کد مبدأ fr:Code source gl:Código fonte ko:소스 코드 hy:Ելակետային կոդ hr:Izvorni kod id:Kode sumberhe:קוד מקור lv:Pirmkods lt:Išeitinis kodas hu:Forráskód ms:Kod sumber nl:Broncode ja:ソースコード no:Kildekode nn:Kjeldekodept:Código fonte ro:Cod sursă qu:Pukyu qillqa f simple:Source code sk:Zdrojový kód sl:Izvorna koda sh:Izvorni kod sr:Изворни код fi:Lähdekoodi sv:Källkod th:รหัสต้นฉบับ tr:Kaynak kodu uk:Сирцевий код vi:Mã nguồn zh:源代码