Subroutine

related topics
{math, number, function}
{system, computer, user}
{language, word, form}
{day, year, event}

In computer science, a subroutine (also called procedure, method, function, or routine) is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code.

As the name "subprogram" suggests, a subroutine behaves in much the same way as a computer program that is used as one step in a larger program or another subprogram. A subroutine is often coded so that it can be started ("called") several times and/or from several places during a single execution of the program, including from other subroutines, and then branch back (return) to the next instruction after the "call" once the subroutine's task is done.

Subroutines are a powerful programming tool,[1] and the syntax of many programming languages includes support for writing and using them. Judicious use of subroutines (for example, through the structured programming approach) will often substantially reduce the cost of developing and maintaining a large program, while increasing its quality and reliability.[2] Subroutines, often collected into libraries, are an important mechanism for sharing and trading software. The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).

In the compilation technique called threaded code, the executable program is basically a sequence of subroutine calls. Maurice Wilkes, David Wheeler, and Stanley Gill are credited with the invention of this concept, which they referred to as closed subroutine.[3]

Contents

Full article ▸

related documents
Obfuscated code
Gray code
RSA
Ruby (programming language)
Lua (programming language)
Web crawler
Binary-coded decimal
UTF-8
Garbage collection (computer science)
Nyquist–Shannon sampling theorem
XML
Huffman coding
Hash function
Numerical analysis
Kernel (algebra)
Cardinal number
Sequence alignment
Denotational semantics
Gaussian elimination
Complete lattice
Infinity
Artificial neural network
Stone–Čech compactification
REXX
Entropy (information theory)
Series (mathematics)
Interval (mathematics)
Newton's method
Logic programming
JavaScript