Source code

Short description: Human-readable instructions for a computer

For other uses, see Source Code (disambiguation).

Simple C source code for a "Hello world" program. Taken from the seminal book The C Programming Language, it originates from Brian Kernighan in the Bell Laboratories in 1974.[1] Program execution

General concepts

* Code
* Translation
* Compiler
* Compile-time
* Optimizing compiler
* Intermediate representation (IR)
* Execution
* Runtime system
* Runtime
* Executable
* Interpreter
* Virtual machine

Types of code

* Source code
* Object code
* Bytecode
* Machine code
* Microcode

Compilation strategies

* Just-in-time (JIT)
* Tracing just-in-time
* Ahead-of-time (AOT)
* Transcompilation
* Recompilation

Notable runtimes

* Android Runtime (ART)
* Common Language Runtime (CLR) & Mono
* crt0
* HHVM
* Java virtual machine (JVM)
* Objective-C
* V8
* Node.js
* PyPy
* Zend Engine

Notable compilers & toolchains

* GNU Compiler Collection (GCC)
* LLVM
* Clang

* v
* t
* e

In computing, source code, or simply code or source, is human readable plain text that can eventually result in controlling the behavior of a computer[citation needed]. In order to control a computer, it must be processed by a computer program – either executed directly via an interpreter or translated into a more computer-consumable form such as via a compiler. Sometimes, code is compiled directly to machine code so that it can be run in the native language of the computer without further processing. Many modern environments, though, involve compiling to an intermediate representation such as bytecode that can either run via an interpreter or be compiled on-demand to machine code via just-in-time compilation.

## Contents

* 1 Background
* 2 Organization
* 3 Purposes
* 3.1 Estimation
* 3.2 Communication
* 3.3 Modification
* 3.4 Compilation and execution
* 3.5 Portability
* 4 Quality
* 5 Copyright and licensing
* 6 See also
* 7 References
* 7.1 Sources
* 8 External links

## Background

The first programmable computers, which appeared at the end of the 1940s,[2] were programmed in machine code (simple instructions that could be directly executed by the processor). Machine language was difficult to debug and was not portable between different computer systems.[3] Initially, hardware resources were scarce and expensive, while human resources were cheaper.[4] As programs grew more complex, programmer productivity became a bottleneck. This led to the introduction of high-level programming languages such as Fortran in the mid-1950s. These languages abstracted away the details of the hardware, and were designed to express algorithms that could be understood more easily by humans.[5][6] As instructions distinct from the underlying computer hardware, software is therefore relatively recent, dating to these early high-level programming languages such as Fortran, Lisp, and Cobol.[6] The invention of high-level programming languages was simultaneous with the compilers needed to translate the source code automatically into machine code that can be directly executed on the computer hardware.[7]

Some definitions of source code consider it to be the form of code that is modified directly by humans, typically in a high-level programming language.[8]

Object code can be directly executed by the machine and is generated automatically from the source code, often via an intermediate step, assembly language. While object code will only work on a specific platform, source code can be ported to a different machine and recompiled there. For the same source code, object code can vary significantly—not only based on the machine for which it is compiled, but also based on performance optimization from the compiler.[9][10]

## Organization

Most programs do not contain all the resources needed to run them and rely on external libraries. Part of the compiler's function is to link these files in such a way that the program can be executed by the hardware.[11]

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.

Software developers often use configuration management to track changes to source code files (version control). The configuration management system also keeps track of which object code file corresponds to which version of the source code file.[12]

## Purposes

### Estimation

The number of source lines of code (SLOC) is often used as a metric when evaluating the productivity of computer programmers, the economic value of a code base, effort estimation for projects in development, and the ongoing cost of software maintenance after release.[13]

### Communication

Source code is also used to communicate algorithms between parties, e.g., code snippets online or in books.[14]

Computer programmers can find it helpful to review extant source code to learn about programming techniques.[14] The sharing of source code between developers is often cited as a contributing factor to the maturing of their programming skills.[14] Some consider source code an expressive artistic medium.[15]

Source code often contains comments—blocks of text marked for the compiler to ignore. This content is not part of the program logic, but is instead intended to help readers understand the program.[16]

Companies often keep the source code confidential in order to hide algorithms considered a trade secret. Proprietary, secret source code and algorithms are widely used for sensitive government applications such as criminal justice, which results in black box behavior with a lack of transparency into the algorithm's methodology. The result is avoidance of public scrutiny of issues such as bias.[17]

### Modification

See also: Software development and Software maintenance

Access to the source code (not just the object code) is essential to modifying it.[18] Understanding extant code is necessary to understand how it works[18] and before modifying it.[19] The rate of understanding depends both on the code base as well as the skill of the programmer.[20] Experienced programmers have an easier time understanding what the code does at a high level.[21] Software visualization is sometimes used to speed up this process.[22]

Many software programmers use an integrated development environment (IDE) to improve their productivity. IDEs typically have several features built in, including a source-code editor that can alert the programmer to common errors.[23] Modification often includes code refactoring (improving structure without changing function) and restructuring (improving structure and function simultaneously).[24] Nearly every change to code introduces new bugs or unexpected ripple effects, which require another round of fixes.[19]

Code reviews by other developers are often used to scrutinize new code added to a project.[25] The purpose of this phase is often to verify that the code meets style and maintainability standards and that it is a correct implementation of the software design.[26] According to some estimates, code review dramatically reduce the number of bugs persisting after software testing is complete.[25] Along with software testing that works by executing the code, static program analysis uses automated tools to detect problems with the source code. Many IDEs support code analysis tools, which might provide metrics on the clarity and maintainability of the code.[27] Debuggers are tools that often enable programmers to step through execution while keeping track of which source code corresponds to each change of state.[28]

### Compilation and execution

Source code files in a high-level programming language must go through a stage of preprocessing into machine code before the instructions can be carried out.[7] After being compiled, the program can be saved as an object file and the loader (part of the operating system) can take this saved file and execute it as a process on the computer hardware.[11] Some programming languages use an interpreter instead of a compiler. An interpreter converts the program into machine code at run time, which makes them 10 to 100 times slower than compiled programming languages.[23][29]

### Portability

Another reason many programs are distributed in source code form, instead of as executable binary files, is that (often) a single source code file can be written once and will run on a variety of different end-user machines (each with their own localized compiler or interpreter), unlike an executable code file which generally only works on nearly-identical machines. Source code was used this way to distribute the Unix operating system early in the history of Unix, and later to allow programs written in scripting languages (in particular the JavaScript client-side scripting language) to run on a wide variety of machines.

For this goal, minified, obfuscated, or decompiled source code files (all of which eliminate the comments in the original code) are generally just as portable as the original source code files (which nearly always include comments), even though they are far less useful for modification, and therefore don't meet the definition of source code in the GNU General Public License, version 2 (GPL2).

## Quality

Software quality is an overarching term that can refer to a code's correct and efficient behavior, its reusability and portability, or the ease of modification.[30] It is usually more cost-effective to build quality into a product from the start rather than try to add it later in a development process.[31] Higher quality code reduces lifetime cost to both suppliers and customers as via higher reliability and maintainability.[32][33]

Maintainability is the quality of software enabling it to be easily modified without breaking extant functions.[34] Following coding conventions such as using clear function and variable names that correspond to their purpose makes maintenance easier.[35] Use of conditional loop statements only if the code could execute more than once, and eliminating code that will never execute can also increase understandability.[36] Many software development organizations neglect maintainability during the development phase, even though it will increase long-term costs.[33] Technical debt is incurred when programmers, often out of laziness or urgency to meet a deadline, choose quick and dirty solutions rather than build maintainability into their code.[37] A common cause is underestimates in software development effort estimation, leading to insufficient resources allocated to development.[38] A challenge with maintainability is that many software engineering courses do not emphasize it.[39] Development engineers who know that they will not be responsible for maintaining the software do not have an incentive to build in maintainability.[19]

## Copyright and licensing

See also: History of free and open-source software

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.[40] 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".[41][42]

Proprietary software is rarely distributed as source code.[43] Although the term open-source software literally refers to public access to the source code,[44] open-source software has additional requirements: free redistribution, permission to modify the source code and release derivative works under the same license, and nondiscrimination between different uses—including commercial use.[45][46] The free reusability of open-source software can speed up development.[47]

## See also

* Bytecode
* Code as data
* Coding conventions
* Free software
* Legacy code
* Machine code
* Markup language
* Obfuscated code
* Object code
* Open-source software
* Package manager
* Programming language
* Source code repository
* Syntax highlighting
* Visual programming language

## References

1. ↑ Kernighan, Brian W.. "Programming in C: A Tutorial". Bell Laboratories, Murray Hill, N. J.. http://cm.bell-labs.com/cm/cs/who/dmr/ctut.pdf.
2. ↑ Gabbrielli & Martini 2023, p. 519.
3. ↑ Gabbrielli & Martini 2023, pp. 520–521.
4. ↑ Gabbrielli & Martini 2023, p. 522.
5. ↑ Gabbrielli & Martini 2023, p. 521.
6. ↑ 6.0 6.1 Tracy 2021, p. 1.
7. ↑ 7.0 7.1 Tracy 2021, p. 121.
8. ↑ Stallman, Richard (February 1989). "Gnu General Public License". GNU. https://www.gnu.org/licenses/old-licenses/gpl-1.0.html.
9. ↑ Lin et al. 2001, pp. 238–239.
10. ↑ Katyal 2019, p. 1194.
11. ↑ 11.0 11.1 Tracy 2021, pp. 122–123.
12. ↑ O'Regan 2022, pp. 230–231, 233, 377.
13. ↑ Foster 2014, pp. 249, 274, 280, 305.
14. ↑ 14.0 14.1 14.2 Spinellis, D: Code Reading: The Open Source Perspective. Addison-Wesley Professional, 2003. ISBN 0-201-79940-5
15. ↑ "Art and Computer Programming" ONLamp.com , (2005)
16. ↑ Kaczmarek et al. 2018, p. 68.
17. ↑ Katyal 2019, pp. 1186–1187.
18. ↑ 18.0 18.1 Katyal 2019, p. 1195.
19. ↑ 19.0 19.1 19.2 Offutt, Jeff (January 2018). "Overview of Software Maintenance and Evolution". https://cs.gmu.edu/~offutt/classes/437/maintessays/maintEvolutionOverview.html.
20. ↑ Tripathy & Naik 2014, p. 296.
21. ↑ Tripathy & Naik 2014, p. 297.
22. ↑ Tripathy & Naik 2014, pp. 318–319.
23. ↑ 23.0 23.1 O'Regan 2022, p. 375.
24. ↑ Tripathy & Naik 2014, p. 94.
25. ↑ 25.0 25.1 Dooley 2017, p. 272.
26. ↑ O'Regan 2022, pp. 18, 21.
27. ↑ O'Regan 2022, p. 133.
28. ↑ Kaczmarek et al. 2018, pp. 348–349.
29. ↑ Sebesta 2012, p. 28.
30. ↑ Galin 2018, p. 26.
31. ↑ O'Regan 2022, pp. 68, 117.
32. ↑ O'Regan 2022, pp. 3, 268.
33. ↑ 33.0 33.1 Varga 2018, p. 12.
34. ↑ Varga 2018, p. 5.
35. ↑ Tripathy & Naik 2014, pp. 296–297.
36. ↑ Tripathy & Naik 2014, p. 309.
37. ↑ Varga 2018, pp. 6–7.
38. ↑ Varga 2018, p. 7.
39. ↑ Varga 2018, pp. 7–8.
40. ↑ Liu, Joseph P.; Dogan, Stacey L. (2005). "Copyright Law and Subject Matter Specificity: The Case of Computer Software" (in en). New York University Annual Survey of American Law 61 (2). https://lawdigitalcommons.bc.edu/lsfp/536/.
41. ↑ 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)
42. ↑ Lemley, Menell, Merges and Samuelson. Software and Internet Law, p. 34.
43. ↑ Boyle 2003, p. 45.
44. ↑ Morin et al. 2012, Open Source versus Closed Source.
45. ↑ Sen et al. 2008, p. 209.
46. ↑ Morin et al. 2012, Free and Open Source Software (FOSS) Licensing.
47. ↑ O'Regan 2022, p. 106.

### Sources

* Ablon, Lillian; Bogart, Andy (2017) (in en). Zero Days, Thousands of Nights: The Life and Times of Zero-Day Vulnerabilities and Their Exploits. Rand Corporation. ISBN 978-0-8330-9761-3. https://www.rand.org/content/dam/rand/pubs/research_reports/RR1700/RR1751/RAND_RR1751.pdf. Retrieved 31 May 2024.
* Boyle, James (2003). "The Second Enclosure Movement and the Construction of the Public Domain". Law and Contemporary Problems 66 (1): 33–74. ISSN 0023-9186. https://scholarship.law.duke.edu/lcp/vol66/iss1/2/. Retrieved 7 April 2025.
* Campbell-Kelly, Martin; Garcia-Swartz, Daniel D. (2015) (in en). From Mainframes to Smartphones: A History of the International Computer Industry. Harvard University Press. ISBN 978-0-674-28655-9.
* Daswani, Neil; Elbayadi, Moudy (2021). Big Breaches: Cybersecurity Lessons for Everyone. Apress. ISBN 978-1-4842-6654-0.
* Dooley, John F. (2017) (in en). Software Development, Design and Coding: With Patterns, Debugging, Unit Testing, and Refactoring. Apress. ISBN 978-1-4842-3153-1.
* Foster, Elvis C. (2014) (in en). Software Engineering: A Methodical Approach. Apress. ISBN 978-1-4842-0847-2.
* Gabbrielli, Maurizio; Martini, Simone (2023) (in en). Programming Languages: Principles and Paradigms (2nd ed.). Springer. ISBN 978-3-031-34144-1.
* Galin, Daniel (2018) (in en). Software Quality: Concepts and Practice. John Wiley & Sons. ISBN 978-1-119-13449-7.
* Haber, Morey J.; Hibbert, Brad (2018) (in en). Asset Attack Vectors: Building Effective Vulnerability Management Strategies to Protect Organizations. Apress. ISBN 978-1-4842-3627-7.
* Kaczmarek, Stefan; Lees, Brad; Bennett, Gary; Fisher, Mitch (2018) (in en). Objective-C for Absolute Beginners: iPhone, iPad and Mac Programming Made Easy. Apress. ISBN 978-1-4842-3428-0.
* Katyal, Sonia K. (2019). "The Paradox of Source Code Secrecy". Cornell Law Review 104: 1183. https://heinonline.org/HOL/LandingPage?handle=hein.journals/clqv104&div=32&id=&page=.
* Kitchin, Rob; Dodge, Martin (2011) (in en). Code/space: Software and Everyday Life. MIT Press. ISBN 978-0-262-04248-2.
* Lin, Daniel; Sag, Matthew; Laurie, Ronald S. (2001). "Source Code versus Object Code: Patent Implications for the Open Source Community". Santa Clara Computer and High Technology Law Journal 18: 235. https://heinonline.org/HOL/LandingPage?handle=hein.journals/sccj18&div=16&id=&page=. Retrieved 31 May 2024.
* Morin, Andrew; Urban, Jennifer; Sliz, Piotr (2012). "A Quick Guide to Software Licensing for the Scientist-Programmer" (in en). PLOS Computational Biology 8 (7). doi:10.1371/journal.pcbi.1002598. ISSN 1553-7358. PMID 22844236. Bibcode: 2012PLSCB...8E2598M.
* O'Regan, Gerard (2022) (in en). Concise Guide to Software Engineering: From Fundamentals to Application Methods. Springer Nature. ISBN 978-3-031-07816-3.
* Sen, Ravi; Subramaniam, Chandrasekar; Nelson, Matthew L. (2008). "Determinants of the Choice of Open Source Software License". Journal of Management Information Systems (Informa UK Limited) 25 (3): 207–240. doi:10.2753/mis0742-1222250306. ISSN 0742-1222.
* Sebesta, Robert W. (2012) (in en). Concepts of Programming Languages (10 ed.). Addison-Wesley. ISBN 978-0-13-139531-2.
* Tracy, Kim W. (2021) (in en). Software: A Technical History. Morgan & Claypool Publishers. ISBN 978-1-4503-8724-8.
* Tripathy, Priyadarshi; Naik, Kshirasagar (2014) (in en). Software Evolution and Maintenance: A Practitioner's Approach. John Wiley & Sons. ISBN 978-0-470-60341-3.
* Varga, Ervin (2018) (in en). Unraveling Software Maintenance and Evolution: Thinking Outside the Box. Springer. ISBN 978-3-319-71303-8.

## External links

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Source code. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Source_code&oldid=4568970"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template