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
Imperative programming
(section)
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!
==Rationale and foundations of imperative programming== The programming paradigm used to build programs for almost all computers typically follows an imperative model.<ref group=note>[[Reconfigurable computing]] is a notable exception.</ref> Digital computer hardware is designed to execute [[machine code]], which is native to the computer and is usually written in the imperative style, although low-level compilers and interpreters using other paradigms exist for some architectures such as [[lisp machine]]s. From this low-level perspective, the program state is defined by the contents of memory, and the statements are instructions in the native machine language of the computer. Higher-level imperative languages use [[variable (programming)|variable]]s and more complex statements, but still follow the same paradigm. [[Recipe]]s and process [[checklist]]s, while not [[computer program]]s, are also familiar concepts that are similar in style to imperative programming; each step is an instruction, and the physical world holds the state. Since the basic ideas of imperative programming are both conceptually familiar and directly embodied in the hardware, most computer languages are in the imperative style. [[Destructive assignment|Assignment statements]], in imperative paradigm, perform an operation on information located in memory and store the results in memory for later use. High-level imperative languages, in addition, permit the [[Evaluation (disambiguation)#Computer_science|evaluation]] of complex [[Expression (programming)|expressions]], which may consist of a combination of [[Arithmetic#Arithmetic operations|arithmetic operations]] and [[function (mathematics)|function]] evaluations, and the assignment of the resulting value to memory. Looping statements (as in [[while loop]]s, [[do while loop]]s, and [[for loop]]s) allow a sequence of statements to be executed multiple times. Loops can either execute the statements they contain a predefined number of times, or they can execute them repeatedly until some condition is met. [[Conditional (programming)|Conditional]] [[Branch (computer science)|branching]] statements allow a sequence of statements to be executed only if some condition is met. Otherwise, the statements are skipped and the execution sequence continues from the statement following them. Unconditional branching statements allow an execution sequence to be transferred to another part of a program. These include the jump (called ''[[goto]]'' in many languages), [[switch statement|switch]], and the subprogram, [[subroutine]], or procedure call (which usually returns to the next statement after the call). Early in the development of [[high-level programming language]]s, the introduction of the [[block (programming)|block]] enabled the construction of programs in which a group of statements and declarations could be treated as if they were one statement. This, alongside the introduction of [[subroutine]]s, enabled complex structures to be expressed by hierarchical decomposition into simpler procedural structures. Many imperative programming languages (such as [[Fortran]], [[BASIC]], and [[C (programming language)|C]]) are [[Abstraction (computer science)|abstraction]]s of [[assembly language]].<ref name=":0">{{cite book|author=Bruce Eckel|title=Thinking in Java|url=https://books.google.com/books?id=bQVvAQAAQBAJ&q=imperative&pg=PA24|publisher=[[Pearson Education]]|year=2006|isbn=978-0-13-187248-6|page=24}}</ref>
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)