Source code

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by imported>MrOllie at 14:18, 20 June 2025 (Reverted 1 edit by 94.131.166.172 (talk) to last revision by 49ersBelongInSanFrancisco). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Jump to navigation Jump to search

Template:Short description Script error: No such module "about".Script error: No such module "Unsubst".

File:Hello world c.svg
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]

Template:Program execution

In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.

Since a computer, at base, only understands machine code, source code must be translated before a computer can execute it. The translation process can be implemented three ways. Source code can be converted into machine code by a compiler or an assembler. The resulting executable is machine code ready for the computer. Alternatively, source code can be executed without conversion via an interpreter. An interpreter loads the source code into memory. It simultaneously translates and executes each statement. A method that combines compilation and interpretation is to first produce bytecode. Bytecode is an intermediate representation of source code that is quickly interpreted.

Background

The first programmable computers, which appeared at the end of the 1940s,Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". were programmed in machine language (simple instructions that could be directly executed by the processor). Machine language was difficult to debug and was not portable between different computer systems.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Initially, hardware resources were scarce and expensive, while human resources were cheaper.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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, instead being designed to express algorithms that could be understood more easily by humans.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Source code is the form of code that is modified directly by humans, typically in a high-level programming language. 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Organization

Script error: No such module "Labelled list hatnote". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

File:CodeCmmt002.svg
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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Purposes

Estimation

The number of lines of source code 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Communication

Source code is also used to communicate algorithms between people

  1. REDIRECT Template:En dash

Template:R protected e.g., code snippets online or in books.[2]

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

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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Modification

Script error: No such module "Labelled list hatnote". Access to the source code (not just the object code) is essential to modifying it.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Understanding existing code is necessary to understand how it worksScript error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". and before modifying it.[4] The rate of understanding depends both on the code base as well as the skill of the programmer.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Experienced programmers have an easier time understanding what the code does at a high level.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Software visualization is sometimes used to speed up this process.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Modification often includes code refactoring (improving the structure without changing functionality) and restructuring (improving structure and functionality at the same time).Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Nearly every change to code will introduce new bugs or unexpected ripple effects, which require another round of fixes.[4]

Code reviews by other developers are often used to scrutinize new code added to a project.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". According to some estimates, code review dramatically reduce the number of bugs persisting after software testing is complete.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Debuggers are tools that often enable programmers to step through execution while keeping track of which source code corresponds to each change of state.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Quality

Template:Main article

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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". It is usually more cost-effective to build quality into the product from the beginning rather than try to add it later in the development process.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Higher quality code will reduce lifetime cost to both suppliers and customers as it is more reliable and easier to maintain.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

Maintainability is the quality of software enabling it to be easily modified without breaking existing functionality.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Following coding conventions such as using clear function and variable names that correspond to their purpose makes maintenance easier.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Many software development organizations neglect maintainability during the development phase, even though it will increase long-term costs.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". A common cause is underestimates in software development effort estimation, leading to insufficient resources allocated to development.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". A challenge with maintainability is that many software engineering courses do not emphasize it.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Development engineers who know that they will not be responsible for maintaining the software do not have an incentive to build in maintainability.[4]

Copyright and licensing

Script error: No such module "Labelled list hatnote". Script error: No such module "Labelled list hatnote".

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.[5] 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".[6][7]

Proprietary software is rarely distributed as source code.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Although the term open-source software literally refers to public access to the source code,Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". 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.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". The free reusability of open-source software can speed up development.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".

See also

References

<templatestyles src="Reflist/styles.css" />

  1. Script error: No such module "citation/CS1".
  2. a b c Spinellis, D: Code Reading: The Open Source Perspective. Addison-Wesley Professional, 2003. Template:ISBN
  3. "Art and Computer Programming" ONLamp.com Script error: No such module "webarchive"., (2005)
  4. a b c Script error: No such module "citation/CS1".
  5. Script error: No such module "Citation/CS1".
  6. Apple Computer, Inc. v. Franklin Computer Corporation Puts the Byte Back into Copyright Protection for Computer Programs Script error: No such module "webarchive". in Golden Gate University Law Review Volume 14, Issue 2, Article 3 by Jan L. Nussbaum (January 1984)
  7. Lemley, Menell, Merges and Samuelson. Software and Internet Law, p. 34.

Script error: No such module "Check for unknown parameters".

Sources

<templatestyles src="Refbegin/styles.css" />

  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".

External links

Script error: No such module "Side box". Script error: No such module "Side box".

Template:Authority control