Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Procedural programming
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer programming paradigm}} {{About|the computer programming paradigm|the method of algorithmic content creation|Procedural generation}} {{More citations needed|date=April 2008}} '''Procedural programming''' is a [[programming paradigm]], classified as [[imperative programming]],<ref>{{cite web |url=https://cs.lmu.edu/~ray/notes/paradigms/ |title=Programming Paradigms }}</ref> that involves implementing the behavior of a [[computer program]] as [[Function (computer programming)|procedures (a.k.a. functions, subroutines)]] that call each other. The resulting program is a series of steps that forms a hierarchy of calls to its constituent procedures. The first major procedural programming languages appeared {{circa|1957}}–1964, including [[Fortran]], [[ALGOL]], [[COBOL]], [[PL/I]] and [[BASIC]].<ref name=":0">{{cite conference |book-title=Proceedings. The Seventh IEEE Conference on Artificial Intelligence Application |title=Welcome to IEEE Xplore 2.0: Use of procedural programming languages for controlling production systems |publisher=[[IEEE]] |doi=10.1109/CAIA.1991.120848 |s2cid=58175293 }}</ref> [[Pascal (programming language)|Pascal]] and [[C (programming language)|C]] were published {{circa|1970}}–1972. [[Computer processor]]s provide hardware support for procedural programming through a [[stack register]] and instructions for [[Subroutine#Jump to subroutine|calling procedures]] and returning from them. Hardware support for other types of programming is possible, like [[Lisp machines]] or [[Java processor]]s, but no attempt was commercially successful.{{Contradictory inline|article=Java processor|reason=It says they are today the most popular form of a high-level language computer architecture.|date=October 2017|section=}} == Development practices == Certain [[software development]] practices are often employed with procedural programming in order to enhance quality and lower development and maintenance costs. ===Modularity and scoping=== [[modularity (programming)|Modularity]] is about organizing the procedures of a program into separate modules—each of which has a specific and understandable purpose. Minimizing the [[scoping|scope]] of variables and procedures can enhance software quality by reducing the [[cognitive load]] of procedures and modules. A program lacking modularity or wide scoping tends to have procedures that consume many [[variable (programming)|variable]]s that other procedures also consume. The resulting code is relatively hard to understand and to maintain. ===Sharing=== Since a procedure can specify a well-defined interface and be self-contained it supports [[code reuse]]—in particular via the [[Library (computing)|software library]]. == Comparison with other programming paradigms == === Imperative programming === Procedural programming is classified as an [[imperative programming]], because it involves direct command of execution. Procedural is a sub-class of imperative since procedural includes [[Block (programming)|block]] and [[Scope (computer science)|scope]] concepts, whereas imperative describes a more general concept that does not require such features. Procedural languages generally use reserved words that define blocks, such as <code>if</code>, <code>while</code>, and <code>for</code>, to implement [[control flow]], whereas [[non-structured programming|non-structured]] imperative languages (i.e. [[assembly language]]) use [[goto]] and [[branch table]]s for this purpose. === Object-oriented programming === Also classified as imperative, [[object-oriented programming]] (OOP) involves dividing a program implementation into objects that expose behavior (methods) and data (members) via a well-defined interface. In contrast, procedural programming is about dividing the program implementation into [[variable (programming)|variables]], [[data structure]]s, and [[subroutine]]s. An important distinction is that while procedural involves procedures to operate on data structures, OOP bundles the two together. An object is a data structure and the behavior associated with that data structure.<ref>{{cite web |url=http://neonbrand.com/procedural-programming-vs-object-oriented-programming-a-review/ |title=Procedural programming vs object-oriented programming |publisher=neonbrand.com |access-date=2013-08-19 |last=Stevenson |first=Joseph |date=August 2013 }}</ref> Some OOP languages support the class concept which allows for creating an object based on a definition. Nomenclature varies between the two, although they have similar semantics: {| class="wikitable" |- ! width=33% |Procedural ! width=33% |Object-oriented |- | Procedure | [[Method (computer science)|Method]] |- | [[Record (computer science)|Record]] | Object |- | Module | Class |- | Procedure call | Message |} === Functional programming === The principles of modularity and code reuse in [[functional programming|functional]] languages are fundamentally the same as in procedural languages, since they both stem from [[structured programming]]. For example: * Procedures correspond to functions. Both allow the reuse of the same code in various parts of the programs, and at various points of its execution. * By the same token, procedure calls correspond to function application. * Functions and their modularly separated from each other in the same manner, by the use of function arguments, return values and variable scopes. The main difference between the styles is that functional programming languages remove or at least deemphasize the imperative elements of procedural programming. The feature set of functional languages is therefore designed to support writing programs as much as possible in terms of [[pure function]]s: * Whereas procedural languages model execution of the program as a sequence of imperative commands that may implicitly alter shared state, functional programming languages model execution as the evaluation of complex expressions that only depend on each other in terms of arguments and return values. For this reason, functional programs can have a free order of code execution, and the languages may offer little control over the order in which various parts of the program are executed; for example, the arguments to a procedure invocation in [[Scheme (programming language)|Scheme]] are evaluated in an arbitrary order. * Functional programming languages support (and heavily use) [[first-class function]]s, [[anonymous function]]s and [[Closure (computer programming)|closures]], although these concepts have also been included in procedural languages at least since [[Algol 68]]. * Functional programming languages tend to rely on [[tail call optimization]] and [[higher-order function]]s instead of imperative looping constructs. Many functional languages, however, are in fact impurely functional and offer imperative/procedural constructs that allow the programmer to write programs in procedural style, or in a combination of both styles. It is common for [[input/output]] code in functional languages to be written in a procedural style. There do exist a few [[esoteric programming language|esoteric]] functional languages (like [[Unlambda]]) that eschew [[structured programming]] precepts for the sake of being difficult to program in (and therefore challenging). These languages are the exception to the common ground between procedural and functional languages. === Logic programming === In [[logic programming]], a program is a set of premises, and computation is performed by attempting to prove candidate theorems. From this point of view, logic programs are [[Declarative programming|declarative]], focusing on what the problem is, rather than on how to solve it. However, the [[backward reasoning]] technique, implemented by [[SLD resolution]], used to solve problems in logic programming languages such as [[Prolog]], treats programs as goal-reduction procedures. Thus clauses of the form: :{{mono|1=H :- B<sub>1</sub>, …, B<sub>n</sub>.}} have a dual interpretation, both as procedures :to show/solve {{mono|1=H}}, show/solve {{mono|1=B<sub>1</sub>}} and … and {{mono|1=B<sub>n</sub>}} and as logical implications: :{{mono|1=B<sub>1</sub> and … and B<sub>n</sub> implies H}}. A skilled logic programmer uses the procedural interpretation to write programs that are effective and efficient, and uses the declarative interpretation to help ensure that programs are correct. == See also == * [[Declarative programming]] * [[Functional programming]] (contrast) * [[Imperative programming]] * [[Logic programming]] * [[Object-oriented programming]] * [[Programming paradigm]]s * [[Programming language]] * [[Structured programming]] * [[SQL#Procedural extensions|SQL procedural extensions]] ==References== {{reflist}} == External links == {{Programming paradigms navbox}} {{Types of programming languages}} [[Category:Programming paradigms]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Circa
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite web
(
edit
)
Template:Contradictory inline
(
edit
)
Template:Mono
(
edit
)
Template:More citations needed
(
edit
)
Template:Programming paradigms navbox
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Types of programming languages
(
edit
)