Subroutine

functionfunctionssubroutinesprocedureproceduresfunction callroutinesprocedure callroutinecall
In computer programming, a subroutine is a sequence of program instructions that performs a specific task, packaged as a unit.wikipedia
835 Related Articles

Library (computing)

librarylibrariessoftware library
Subroutines may be defined within programs, or separately in libraries that can be used by many programs.
These may include configuration data, documentation, help data, message templates, pre-written code and subroutines, classes, values or type specifications.

Structured programming

structuredProgram structurestructured program
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.
Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection (if/then/else) and repetition (while and for), block structures, and subroutines.

Method (computer programming)

methodsmethodabstract method
In different programming languages, a subroutine may be called a procedure, a function, a routine, a method, or a subprogram. The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).
A method in object-oriented programming (OOP) is a procedure associated with a message and an object.

Threaded code

threadedthreaded interpreterToken threading
In the compiling method called threaded code, the executable program is basically a sequence of subroutine calls.
In computer science, the term threaded code refers to a programming technique where the code has a form that essentially consists entirely of calls to subroutines.

John Mauchly

John W. MauchlyJohn William MauchlyMauchly
The idea of a subroutine was initially conceived by John Mauchly during his work on ENIAC, and recorded in a January 1947 Harvard symposium on "Preparation of Problems for EDVAC-type Machines".
Together they started the first computer company, the Eckert-Mauchly Computer Corporation (EMCC), and pioneered fundamental computer concepts including the stored program, subroutines, and programming languages.

Object (computer science)

objectobjectsdata object
The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).
In computer science, an object can be a variable, a data structure, a function, or a method, and as such, is a value in memory referenced by an identifier.

Class (computer programming)

classclassesPartial class
The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).
In many languages, the class name is used as the name for the class (the template itself), the name for the default constructor of the class (a subroutine that creates objects), and as the type of objects generated by instantiating the class; these distinct concepts are easily conflated.

Object-oriented programming

object-orientedobject orientedobject-oriented programming language
The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).

David Wheeler (computer scientist)

David WheelerDavid John WheelerDavid J. Wheeler
Maurice Wilkes, David Wheeler, and Stanley Gill are generally credited with the formal invention of this concept, which they termed a closed subroutine, contrasted with an open subroutine or macro.
Along with Maurice Wilkes and Stanley Gill he is credited with the invention of the subroutine (which they referred to as the closed subroutine), and gave the first explanation of how to design software libraries; as a result, the jump to subroutine instruction was often called a Wheeler Jump.

Stanley Gill

S. Gill
Maurice Wilkes, David Wheeler, and Stanley Gill are generally credited with the formal invention of this concept, which they termed a closed subroutine, contrasted with an open subroutine or macro.
Professor Stanley Gill (26 March 1926 – 1975) was a British computer scientist credited, along with Maurice Wilkes and David Wheeler, with the invention of the first computer subroutine.

Recursion (computer science)

recursionrecursiverecursively
A subroutine can be coded so that it may call itself recursively, at one or more places, to perform its task.
At the opposite, recursion solves such recursive problems by using functions that call themselves from within their own code.

Macro (computer science)

macromacrosmacro language
Maurice Wilkes, David Wheeler, and Stanley Gill are generally credited with the formal invention of this concept, which they termed a closed subroutine, contrasted with an open subroutine or macro.
This gives the macro some of the power of a function.

Imperative programming

imperativeimperative programming languageimperative language
The widespread use of subroutines with side effects is a characteristic of imperative programming languages.
Procedural programming is a type of imperative programming in which the program is built from one or more procedures (also termed subroutines or functions).

Pascal (programming language)

PascalPascal programming languageISO 7185
Some programming languages, such as Pascal, Fortran, Ada and many dialects of BASIC, distinguish between functions or function subprograms, which provide an explicit return value to the calling program, and subroutines or procedures, which do not.
Unlike most languages in the C-family, Pascal allows nested procedure definitions to any level of depth, and also allows most kinds of definitions and declarations inside subroutines (procedures and functions).

ENIAC

Electronic Numerical Integrator And ComputerElectronic computerENIAC (Electronic Numerical Integrator and Computer)
The idea of a subroutine was initially conceived by John Mauchly during his work on ENIAC, and recorded in a January 1947 Harvard symposium on "Preparation of Problems for EDVAC-type Machines".
McNulty developed the use of subroutines in order to help increase ENIAC's computational capability.

Data structure

data structuresstructurestructures
A subroutine call may also have side effects such as modifying data structures in a computer memory, reading from or writing to a peripheral device, creating a file, halting the program or the machine, or even delaying the program's execution for a specified time.
The implementation of a data structure usually requires writing a set of procedures that create and manipulate instances of that structure.

Side effect (computer science)

side effectsside effectside-effects
A subroutine call may also have side effects such as modifying data structures in a computer memory, reading from or writing to a peripheral device, creating a file, halting the program or the machine, or even delaying the program's execution for a specified time. In strictly functional programming languages such as Haskell, subprograms can have no side effects, which means that various internal states of the program will not change.
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect) to the invoker of the operation.

Calling convention

callingprocedure callregister conventions
A language's compiler will usually translate procedure calls and returns into machine instructions according to a well-defined calling convention, so that subroutines can be compiled separately from the programs that call them.
In computer science, a calling convention is an implementation-level (low-level) scheme for how subroutines receive parameters from their caller and how they return a result.

C (programming language)

CC programming languageC language
Other languages, such as C and Lisp, do not distinguish between functions and subroutines.
In C, all executable code is contained within subroutines (also called "functions", though not strictly in the sense of functional programming).

Functional programming

functionalfunctional programming languagefunctional language
In strictly functional programming languages such as Haskell, subprograms can have no side effects, which means that various internal states of the program will not change.
Imperative programming has subroutines, but these are not mathematical functions.

Expression (computer science)

expressionexpressionsevaluation environment
In those languages, function calls are normally embedded in expressions (e.g., a function may be called as ).
An expression in a programming language is a combination of one or more constants, variables, operators, and functions that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value.

Statement (computer science)

statementstatementscompound statement
Procedure calls either behave syntactically as statements (e.g., a procedure may be called as or are explicitly invoked by a statement such as or (e.g., ).
Often statement keywords are reserved such that they cannot be used as names of variables or functions.

Call site

callcall-sitecalls
Subroutines could be implemented, but they required programmers to use the call sequence—a series of instructions—at each call site.
In programming, a call site of a function or subroutine is the location (line of code) where the function is called (or may be called, through dynamic dispatch).

Housekeeping (computing)

housekeepingcleaningmaintenance
A subroutine typically requires standard housekeeping code – both at entry to, and exit from, the function (function prologue and epilogue – usually saving general purpose registers and return address as a minimum).
In computer programming, housekeeping can refer to either a standard entry or exit routine appended to a user-written block of code (such as a subroutine or function, sometimes known as a function prologue and epilogue) at its entry and exit or, alternatively, to any other automated or manual software process whereby a computer is cleaned up after usage (e.g. freeing resources such as virtual memory).

Fortran

Fortran 77Fortran 90FORTRAN IV
Some programming languages, such as Pascal, Fortran, Ada and many dialects of BASIC, distinguish between functions or function subprograms, which provide an explicit return value to the calling program, and subroutines or procedures, which do not.