Source code

From Free net encyclopedia

Image:Html-source-code.png

Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. In modern programming languages, the source code which constitutes a program is usually in several text files, but the same source code may be printed in a book or recorded on tape (usually without a filesystem). The term is typically used in the context of a particular piece of computer software. A computer program's source code is the collection of files that can be converted from human-readable form to an equivalent computer-executable form. The source code is either converted into an executable file by a compiler for a particular computer architecture, or executed on the fly from the human readable form with the aid of an interpreter.

The code base of a programming project is the larger collection of all the source code of all the computer programs which make up the project. There is utility in this sort of aggregation as often the same source code file will be used by more than one of a project's different programs.

Contents

Purposes

Source code is either used to produce object code, or to be run by an interpreter. Modifications are not carried out on object code, but on source code, and then converted again.

Source code has a number of other uses. It can be used for the description of software. It can also be used as a tool of learning; beginning programmers often find it helpful to review existing source code to learn about programming techniques and methodology. It is used as a communication tool between experienced programmers, due to its (ideally) concise and unambiguous nature. The sharing of source code between developers is frequently cited as a contributing factor to the maturation of their programming skills. Source code can be an expressive artistic medium; consider, for example, obfuscated code or PerlMonks.Org.

Source code is a vital component in the activity of porting software to alternative computer platforms. Without the source code for a particular piece of software, portability is generally so difficult as to be impractical and even impossible. Binary translation can be used to run a program without source code, but not to maintain it. Decompilation can be used to generate source code where none exists, and with some manual effort, maintainable source code can be produced (VEW04). Programmers frequently borrow source code from one piece of software to use in other projects, a concept which is known as Software reusability.

Organization

The source code for a particular piece of software may be contained in a single file or many files. A program's source code is not necessarily all written in the same programming language; for example, it is common for a program to be written primarily in the C programming language, with some 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.

Moderately complex software customarily requires the compilation or assembly of several, sometimes dozens or even hundreds, of different source code files. This complexity is reduced considerably by the inclusion of a Makefile with the source code, which describes the relationships among the source code files, and contains information about how they are to be compiled. The revision control system is another tool frequently used by developers for source code maintenance.

Licensing

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. The provisions of the various copyright laws are often used for this purpose, though trade secrecy is also relied upon. For a further discussion of the differences between these paradigms, and the divisions within them, see software license.

Legal issues

As of 2003, court systems are in the process of deciding whether source code should be considered a Constitutionally protected form of free speech in the United States. Proponents of the free speech argument claim 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. The opposing view is that source code is functional, more than artistic speech, and is thus not protected by First Amendment Rights of the U.S. Constitution.

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.

In 2000, in a related court case, the issue was again brought under some scrutiny when the Motion Picture Association of America (MPAA) sued the 'hacker' magazine 2600 and a number of other websites for distributing the source code to DeCSS, an algorithm capable of decrypting scrambled DVD discs. The algorithm was developed to allow people to play legally purchased DVDs on the Linux operating system, which had no DVD software at the time. The US District court decision favored the MPAA; 2600 magazine was prohibited from posting or linking to the source code on their website. This ruling was widely considered a victory for the supporters of the Digital Millennium Copyright Act, as it established a legal precedent for the notion that source code is not Constitutionally protected free speech. It was affirmed by the Appeals Court and as of late 2003 is being appealed to the US Supreme Court.

Quality

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 issues also come into considering whether code is well written, such as the logical structuring of the code into manageable sections. See Software quality.

Usage

The word code is increasingly misused, as a noun and as a verb, in the context of software development. These examples help to clarify the subtle distinctions in meaning conveyed by proper and improper English grammar.

Examples of correct usage: (not needing clarification)

  • 1. "I wrote some code," meaning more precisely, "I wrote one or more software programs or fragments."
  • 2. "Where is the code for that application?" meaning, "Where are the source code files comprising that program or software product?"
  • 3. "You need a code to enter the building," meaning, "You need a security code or password to enter the building."
  • 4. "Be sure to code that module before sending us the update," meaning "Be sure to write the program which implements that module ...."


Examples of incorrect usage: (needing clarification by the speaker)

  • x1. "I wrote a code," meaning something like "I developed a cryptographic algorithm or password." The intended meaning, however, is usually that of the correct usage shown in example 1.
  • x2. "How many codes have you written," meaning "how many passwords or encrypted messages...." The intended meaning is as in example 2.
  • x3. "You need some code to enter the building," meaning, "You need a computer program to enter the building." The intended meaning is more like, "You need a security code or a password ...," as in the correct usage shown in example 3.
  • x4. "I am coding the deliverable now," probably meaning "I am writing the product to be delivered now." However, if the speaker is prone to loose usage of words like "code," the listener may wonder whether it means "encoding a copy of the software product," for security purposes prior to transmission; coding an entire product "now" is an unlikely meaning.

Each of the correct-usage examples needs no clarification. The "more precise" interpretations are offered here as an aid to those learning or perfecting their English.

This usage issue has become noticeable with the globalization of computer software development businesses. The errors around the word code, and similar usage errors involving other terms, place a new burden on native speakers of the English language to be responsible for disambiguating the verbal communication of some of their colleagues who are learning English in the workplace. However, since language is fluid, these new "erroneous" usages could become dominant as the number of members of the community shifts toward non-native English speakers.

Reference

(VEW04) "Using a Decompiler for Real-World Source Recovery", M Van Emmerik and T Waddington, the Working Conference on Reverse Engineering, Delft, Netherlands, 9th-12th November 2004. Extended version of the paper.

See also

External links

bg:Изходен код ca:Codi font cs:Zdrojový kód da:Kildekode de:Quelltext es:Código fuente et:Lähtekood fi:Lähdekoodi fr:Code source he:קוד מקור hu:Forráskód it:Codice sorgente ja:ソースコード lt:Išeitinis kodas lv:Pirmkods ms:Kod sumber nl:Broncode no:Kildekode pl:Kod źródłowy pt:Código fonte ru:Исходный код sk:Zdrojový kód sl:Izvorna koda sv:Källkod th:ซอร์สโค้ด vi:Mã nguồn zh:源代码