HOME

TheInfoList



OR:

In computing, source code, or simply code, is any collection of code, with or without
comments Comment may refer to: * Comment (linguistics) or rheme, that which is said about the topic (theme) of a sentence * Bernard Comment (born 1960), Swiss writer and publisher Computing * Comment (computer programming), explanatory text or informa ...
, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the work of computer
programmer A computer programmer, sometimes referred to as a software developer, a software engineer, a programmer or a coder, is a person who creates computer programs — often for larger computer software. A programmer is someone who writes/creates ...
s, 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 is then available for execution at a later time. Most application software is distributed in a form that includes only
executable In computing, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instruction (computer science), instructi ...
files. If the source code were included it would be useful to a
user Ancient Egyptian roles * User (ancient Egyptian official), an ancient Egyptian nomarch (governor) of the Eighth Dynasty * Useramen, an ancient Egyptian vizier also called "User" Other uses * User (computing), a person (or software) using an ...
, programmer or a system administrator, any of whom might wish to study or modify the program. Alternatively, depending on the technology being used, source code may be interpreted and executed directly.


Definitions

Richard Stallman's definition, formulated in his 1989 seminal license, proposed source code as whatever form in which software is modified:
The “source code” for a work means the preferred form of the work for making modifications to it.
Some classical sources define source code as the text form of programming languages, for example:
Source code (also referred to as source or code) is the version of software as it is originally written (i.e., typed into a computer) by a human in plain text (i.e., human readable alphanumeric characters).
This responds to the fact that, when
program translation A translator or programming language processor is a generic term that can refer to a compiler, assembler (computing), assembler, or interpreter (computing), interpreter—anything that converts code from one computer language into another. T ...
first appeared, the contemporary form of software production were textual programming languages, thus source code was text code while machine code was target code. However, as programming pipelines started to incorporate more intermediate forms, some in languages like JavaScript that could be either source or target, text code stopped being synonymous with source code. Stallman's definition thus contemplates JavaScript and HTML's source-target ambivalence, as well as contemplating possible future forms of software production, like visual programming languages, or datasets in Machine Learning. Other broader interpretations, however, consider source code to include the machine code along with all the high level languages that produce it, this definition undoes the original machine/text distinction by considering each step in the program translation to be source code.
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.
This approach allows for a much more flexible approach to system analysis, dispensing with the requirement for designer to collaborate by publishing a convenient form for understanding and modification. It can also be applied to scenarios where a designer is not needed, like DNA. However, this form of analysis doesn't contemplate a costlier machine-to-machine code analysis than human-to-machine code analysis.


History

The earliest programs for
stored-program computer A stored-program computer is a computer that stores program instructions in electronically or optically accessible memory. This contrasts with systems that stored the program instructions with plugboards or similar mechanisms. The definition i ...
s were entered in binary through the front panel switches of the computer. This
first-generation programming language A first-generation programming language (1GL) is a machine-level programming language. A first generation (programming) language (1GL) is a grouping of programming languages that are machine level languages used to program first-generation com ...
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. 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.


Organization

The source code which constitutes a program is usually held in one or more text files stored on a computer's
hard disk A hard disk drive (HDD), hard disk, hard drive, or fixed disk is an electro-mechanical data storage device that stores and retrieves digital data using magnetic storage with one or more rigid rapidly rotating platters coated with magnet ...
; usually, these files are carefully arranged into a directory tree, known as a source tree. Source code can also be stored in a database (as is common for
stored procedure A stored procedure (also termed proc, storp, sproc, StoPro, StoredProc, StoreProc, sp, or SP) is a subroutine available to applications that access a relational database management system (RDBMS). Such procedures are stored in the database data dic ...
s) or elsewhere. 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 ''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
, might have portions written in
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
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 computer science, a library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and subro ...
. In some languages, such as Java, this can be done at runtime (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, 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.


Purposes

Source code is primarily used as input to the process that produces an executable program (i.e., it is compiled or interpreted). It is also used as a method of communicating algorithms between people (e.g.,
code snippets Snippet is a programming term for a small region of re-usable source code, machine code, or text. Ordinarily, these are formally defined operative units to incorporate into larger programming modules. Snippet management is a feature of some text ...
in books).Spinellis, D: ''Code Reading: The Open Source Perspective''. Addison-Wesley Professional, 2003. Computer 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. 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.


Legal aspects

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. 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".Lemley, Menell, Merges and Samuelson. ''Software and Internet Law'', p. 34. In 1983 in the United States court case ''
Apple v. Franklin ''Apple Computer, Inc. v. Franklin Computer Corp.'', 714 F.2d 1240 (3d Cir. 1983), was the first time an appellate level court in the United States held that a computer's BIOS could be protected by copyright. As second impact, this ruling clarifi ...
'' 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 ''Bernstein v. United States'' is a set of court cases brought by Daniel J. Bernstein challenging restrictions on the export of cryptography from the United States. History The case was first brought in 1995, when Bernstein was a student at ...
'' 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.EFF at 25: Remembering the Case that established Code as Speech
on EFF.org by Alison Dame-Boyle (16 April 2015)


Licensing

An author of a non-trivial work like software, has several exclusive rights, among them the copyright for the source code and object code. 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 free software 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, a software is free software if its users are free to use it for any purpose, study and change its source code, give or sell its exact copies, and give or sell its modified copies. Software is ''proprietary'' if it is distributed while 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 Trade secrets are a type of intellectual property that includes formulas, practices, processes, designs, instruments, patterns, or compilations of information that have inherent economic value because they are not generally known or readily as ...
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 Reverse engineering (also known as backwards engineering or back engineering) is a process or method through which one attempts to understand through deductive reasoning how a previously made device, process, system, or piece of software accompli ...
, 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.


Quality

The way a program is written can have important consequences for its maintainers. Coding conventions, which stress
readability Readability is the ease with which a reader can understand a written text. In natural language, the readability of text depends on its content (the complexity of its vocabulary and syntax) and its presentation (such as typographic aspects that a ...
and some language-specific conventions, are aimed at the maintenance of the software source code, which involves
debugging In computer programming and software development, debugging is the process of finding and resolving '' bugs'' (defects or problems that prevent correct operation) within computer programs, software, or systems. Debugging tactics can involve in ...
and updating. Other priorities, such as the speed of the program's execution, or the ability to compile the program for multiple architectures, often make code readability a less important consideration, since code ''quality'' generally depends on its ''purpose''.


See also

*
Bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (norma ...
* Code as data * Coding conventions * Computer code * Free software * Legacy code * Machine code *
Markup language Markup language refers to a text-encoding system consisting of a set of symbols inserted in a text document to control its structure, formatting, or the relationship between its parts. Markup is often used to control the display of the document ...
* Obfuscated code * Object code * Open-source software * Package (package management system) * Programming language * Source code repository * Syntax highlighting *
Visual programming language In computing, a visual programming language (visual programming system, VPL, or, VPS) is any programming language that lets users create programs by manipulating program elements ''graphically'' rather than by specifying them ''textually''. A VP ...


References


Sources

* (VEW04) "Using a Decompiler for Real-World Source Recovery", M. Van Emmerik and T. Waddington, the ''Working Conference on Reverse Engineering'',
Delft Delft () is a List of cities in the Netherlands by province, city and Municipalities of the Netherlands, municipality in the Provinces of the Netherlands, province of South Holland, Netherlands. It is located between Rotterdam, to the southeast, ...
, Netherlands, 9–12 November 2004
Extended version of the paper


External links



by The Linux Information Project (LINFO) *
Same program written in multiple languages
{{DEFAULTSORT:Source Code Text