Content deleted Content added
(edit summary removed) Tags: Reverted Mobile edit Mobile web edit |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1:
{{Short description|Type of programming paradigm in computer science}}
{{more citations needed|date=October
In [[computer science]], '''imperative programming''' is a [[programming paradigm]] of [[software]] that uses [[Statement (computer science)|statement]]s that change a program's [[state (computer science)|state]]. In much the same way that the [[imperative mood]] in [[natural language]]s expresses commands, an imperative program consists of [[command (computing)|command]]s for the [[computer]] to perform. Imperative programming focuses on describing ''how'' a program operates step by step (
The term is often used in contrast to [[declarative programming]], which focuses on ''what'' the program should accomplish without specifying all the details of ''how'' the program should achieve the result.<ref>{{Cite web |title=Imperative programming: Overview of the oldest programming paradigm |url=https://www.ionos.com/digitalguide/websites/web-development/imperative-programming/ |access-date=
==Procedural programming==
Line 22:
==History of imperative and object-oriented languages==
The earliest imperative languages were the machine languages of the original computers. In these languages, instructions were very simple, which made hardware implementation easier but hindered the creation of complex programs. [[FORTRAN]], developed by [[John Backus]] at [[International Business Machines]] (IBM) starting in 1954, was the first major programming language to remove the obstacles presented by machine code in the creation of complex programs. FORTRAN was a [[compiled language]] that allowed named variables, complex expressions, subprograms, and many other features now common in imperative languages. The next two decades saw the development of many other major high-level imperative programming languages. In the late 1950s and 1960s, [[ALGOL]] was developed in order to allow mathematical algorithms to be more easily expressed and even served as the [[operating system]]'s target language for some computers. [[MUMPS]] (1966) carried the imperative paradigm to a logical extreme, by not having any statements at all, relying purely on commands, even to the extent of making the IF and ELSE commands independent of each other, connected only by an intrinsic variable named $
The 1980s saw a rapid growth in interest in [[object-oriented programming]]. These languages were imperative in style, but added features to support [[object (computing)|objects]]. The last two decades of the 20th century saw the development of many such languages. [[Smalltalk]]-80, originally conceived by [[Alan Kay]] in 1969, was released in 1980, by the Xerox Palo Alto Research Center ([[PARC (company)|PARC]]). Drawing from concepts in another object-oriented language—[[Simula]] (which is considered the world's first [[object-oriented programming language]], developed in the 1960s)—[[Bjarne Stroustrup]] designed [[C++]], an object-oriented language based on [[C (programming language)|C]]. Design of [[C++]] began in 1979 and the first implementation was completed in 1983. In the late 1980s and 1990s, the notable imperative languages drawing on object-oriented concepts were [[Perl]], released by [[Larry Wall]] in 1987; [[Python (programming language)|Python]], released by [[Guido van Rossum]] in 1990; [[Visual Basic (classic)|Visual Basic]] and [[Visual C++]] (which included [[Microsoft Foundation Class Library]] (MFC) 2.0), released by [[Microsoft]] in 1991 and 1993 respectively; [[PHP]], released by [[Rasmus Lerdorf]] in 1994; [[Java (programming language)|Java]], by [[James Gosling]] ([[Sun Microsystems]]) in 1995, [[JavaScript]], by [[Brendan Eich]] ([[Netscape]]), and [[Ruby (programming language)|Ruby]], by Yukihiro "Matz" Matsumoto, both released in 1995. Microsoft's [[.NET Framework]] (
==Examples==
Line 44:
| year = 2001
| page = 16
| isbn = 0-
}}</ref>
However, non IBM vendors also wrote Fortran compilers, but with a syntax that would likely fail IBM's compiler.<ref name="cpl_3rd-ch2-16"/> The [[American National Standards Institute]] (ANSI) developed the first Fortran standard in
* [[Record (computer science)|records]]
* [[Pointer (computer programming)|pointers]] to arrays
Line 58:
| publisher = Addison-Wesley
| year = 2001
| page = 24
| isbn = 0-201-71012-9
Line 92 ⟶ 90:
Algol's direct descendants include [[Pascal (programming language)|Pascal]], [[Modula-2]], [[Ada (programming language)|Ada]], [[Delphi (software)|Delphi]] and [[Oberon (programming language)|Oberon]] on one branch. On another branch there's [[C (programming language)|C]], [[C++]] and [[Java (programming language)|Java]].<ref name="cpl_3rd-ch2-19"/>
===
[[BASIC]] (1964) stands for "Beginner's All Purpose Symbolic Instruction Code." It was developed at [[Dartmouth College]] for all of their students to learn.<ref name="cpl_3rd-ch2-30">{{cite book
| last = Wilson
Line 141 ⟶ 139:
* The ''global and static data'' region is located just above the ''program'' region. (The program region is technically called the ''text'' region. It's where machine instructions are stored.)
:* The global and static data region is technically two regions.<ref name="geeksforgeeks">{{cite web
| date = 12 September 2011
| access-date = 25 May 2022
| archive-date = 6 November 2021
| archive-url = https://web.archive.org/web/20211106175644/https://www.geeksforgeeks.org/memory-layout-of-c-program/
| url-status = live
}}</ref> One region is called the ''initialized [[data segment]]'', where variables declared with default values are stored. The other region is called the ''[[.bss|block started by segment]]'', where variables declared without default values are stored.
:* Variables stored in the ''global and static data'' region have their [[Memory address|addresses]] set at compile-time. They retain their values throughout the life of the process.
Line 182 ⟶ 184:
|title=The Linux Programming Interface
|last=Kerrisk
|first=
|publisher=No Starch Press
|year=
|isbn=978-1-59327-220-3
|page=122}}</ref> are called ''automatic variables''<ref name="cpl-
* The [[Manual memory management|heap]] region is
|title=The C Programming Language Second Edition
|last1=Kernighan
Line 195 ⟶ 197:
|first2=Dennis M.
|publisher=Prentice Hall
|year=
|isbn=0-13-110362-8
|page=185}}</ref> Like the stack, the
:* ''C''
|title=The C Programming Language Second Edition
|last1=Kernighan
|