Content deleted Content added
Add Wirth quote about motivation for the name "Pascal" |
+cat. |
||
(26 intermediate revisions by 16 users not shown) | |||
Line 39:
| license =
| website =
| file_ext = .pas
| wikibooks = Pascal Programming
}}
'''Pascal''' is an [[Imperative programming|imperative]] and [[Procedural programming|procedural]] [[programming language]], designed by [[Niklaus Wirth]] as a small, efficient language intended to encourage good programming practices using [[structured programming]] and [[data structure|data structuring]]. It is named after French mathematician, philosopher and physicist [[Blaise Pascal
Pascal was developed on the pattern of the [[ALGOL 60]] language. Wirth was involved in the process to improve the language as part of the [[ALGOL X]] efforts and proposed a version named [[ALGOL W]]. This was not accepted, and the ALGOL X process bogged down. In 1968, Wirth decided to abandon the ALGOL X process and further improve ALGOL W, releasing this as Pascal in 1970.
On top of ALGOL's [[variable (computer science)|scalar]]s and [[array (data type)|arrays]], Pascal enables defining complex datatypes and building dynamic and recursive data structures such as [[list (abstract data type)|list]]s, [[tree (data structure)|tree]]s and [[graph (abstract data type)|graph]]s. Pascal has [[strong and weak typing|strong typing]] on all objects, which means that one type of data cannot be converted to or interpreted as another without explicit conversions. Unlike C (and also unlike most other 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). A program is thus syntactically similar to a single procedure or function. This is similar to the block structure of ALGOL 60, but restricted from arbitrary block statements to just procedures and functions.
Pascal became very successful in the 1970s, notably on the burgeoning [[minicomputer]] market. [[Compiler]]s were also available for many [[microcomputer]]s as the field emerged in the late 1970s. It was widely used as a teaching language in [[university]]-level programming courses in the 1980s, and also used in production settings for writing commercial software during the same period. It was displaced by the [[C (programming language)|C programming language]] during the late 1980s and early 1990s as [[UNIX]]-based systems became popular, and especially with the release of [[C++]].
A derivative named [[Object Pascal]] designed for [[object-oriented programming]] was developed in 1985. This was used by [[Apple Inc.|Apple Computer]] (for the [[Apple Lisa|Lisa]] and [[Mac (computer)|Macintosh]] machines) and [[Borland]] in the late 1980s and later developed into [[Delphi (software)|Delphi]] on the [[Microsoft Windows]] platform. Extensions to the Pascal concepts led to the languages [[Modula-2]] and [[Oberon (programming language)|Oberon]], both developed by Wirth.
==History==
Line 61 ⟶ 63:
===Pascal===
Pascal was influenced by the ALGOL W efforts, with the explicit goals of teaching programming in a [[structured programming|structured fashion]] and for the development of system software.<ref>{{Cite book|chapter-url=https://link.springer.com/chapter/10.1007/10722581_1|doi = 10.1007/10722581_1|chapter = The Development of Procedural Programming Languages Personal Contributions and Perspectives|title = Modular Programming Languages|series = Lecture Notes in Computer Science|year = 2000|last1 = Wirth|first1 = Niklaus|volume = 1897|pages = 1–10|isbn = 978-3-540-67958-5}}</ref> A generation of students used Pascal as an introductory language in undergraduate courses. Other goals included providing a reliable and efficient tool for writing large programs,<ref>{{cite journal |last1=Wirth |first1=N. |title=The Programming Language Pascal |journal=Acta Informatica |date=1971 |volume=1 |issue=1 |pages=35–63 |doi=10.1007/BF00264291|hdl=20.500.11850/68712 |hdl-access=free }}</ref> and bridging the canyon between scientific and commercial programming, as represented by the then-widespread languages Fortran and COBOL, with a general-purpose language.<ref>{{cite book |last1=Wirth |first1=N. |chapter=Recollections about the development of Pascal |title=History of programming languages---II |date=January 1996 |pages=97–120 |doi=10.1145/234286.1057812|isbn=0-201-89502-1 }}</ref>
One of the early successes for the language was the introduction of [[UCSD Pascal]], a version that ran on a custom [[operating system]] that could be ported to different platforms. A key platform was the [[Apple II]], where it saw widespread use as [[Apple Pascal]]. This led to Pascal becoming the primary [[high-level language]] used for development in the [[Apple Lisa]], and later, the [[Mac (computer)|Macintosh]]. Parts of the original [[Classic Mac OS|Macintosh operating system]] were hand-translated into [[Motorola 68000]] [[assembly language]] from the Pascal [[source code]].<ref>Hertzfeld, Andy. "[http://www.folklore.org/StoryView.py?project=Macintosh&story=Hungarian.txt&topic=Software%20Design&sortOrder=Sort%20by%20Date&detail=medium Hungarian folklore.org] {{webarchive|url=https://web.archive.org/web/20151118082558/http://www.folklore.org/StoryView.py?project=Macintosh&story=Hungarian.txt&topic=Software%20Design&sortOrder=Sort%20by%20Date&detail=medium |date=2015-11-18}}: Macintosh Stories. Retrieved 2012-03-06.</ref>
Line 82 ⟶ 83:
===Object Pascal===
During work on the Lisa, [[Larry Tesler]] began corresponding with Wirth on the idea of adding object-oriented extensions to the language, to make Pascal a [[Programming paradigm|
The Object Pascal extensions were added to [[Turbo Pascal]] with the release of version 5.5 in 1989.<ref>{{cite web|title=Antique Software: Turbo Pascal v5.5|url=http://edn.embarcadero.com/article/20803|access-date=2018-05-17|archive-date=2010-11-24|archive-url=https://web.archive.org/web/20101124090934/http://edn.embarcadero.com/article/20803|url-status=dead}}</ref> Over the years, Object Pascal became the basis of the [[Delphi (software)|Delphi]] system for [[Microsoft Windows]], which is still used for developing Windows applications, and can [[cross-compile]] code to other systems. [[Free Pascal]] is an open source, cross-platform alternative with its own graphical [[integrated development environment|IDE]] called [[Lazarus (IDE)|Lazarus]].
Line 95 ⟶ 96:
A completely new compiler was completed by Welsh et al. at QUB in 1977. It offered a source-language diagnostic feature (incorporating profiling, tracing and type-aware formatted postmortem dumps) that was implemented by Findlay and Watt at Glasgow University. This implementation was ported in 1980 to the [[ICL 2900]] series by a team based at [[Southampton University]] and Glasgow University. The Standard Pascal Model Implementation was also based on this compiler, having been adapted, by Welsh and Hay at [[Manchester University]] in 1984, to check rigorously for conformity to the BSI 6192/ISO 7185 Standard and to generate code for a portable abstract machine.
The first Pascal [[compiler]] written in North America was constructed at the [[University of Illinois at Urbana–Champaign|University of Illinois]] under [[Donald B. Gillies#Later career|Donald B. Gillies]] for the [[PDP-11]] and generated native machine code. Microsoft had Pascal compilers for IBM PCs, see [[Microsoft Pascal]].
==={{anchor|Pascal-P}}The Pascal-P system===
Line 172 ⟶ 173:
|-
| [[Array data type|array]]
| a countable group of any of the preceding data types,
|-
| [[Record (computer science)|record]]
| A collection of any of the preceding data types or of other records
|-
| [[string (computer science)|string]]
Line 181 ⟶ 182:
|}
The range of values allowed for the basic types (except Boolean) is implementation defined. Functions are provided for some data conversions. For conversion of <code>real</code> to <code>integer</code>, the following functions are available: <code>round</code> (
The programmer has the freedom to define other commonly used data types (e.g. byte, string, etc.) in terms of the predefined types using Pascal's type declaration facility, for example
Line 283 ⟶ 284:
end;
c = file of a;
</syntaxhighlight>
Further, complex types can be constructed from other complex types recursively:
:<syntaxhighlight lang="pascal">
const
Jack = 11;
Queen = 12;
King = 13;
Ace = 14;
type
valueType = 2..Ace;
suitType = club, diamond, heart, spade;
cardType = record
suit: suitType;
value: valueType;
end;
deckType = array [1..52] of cardType;
person = record
surname: packed array [1..20] of char;
age: integer;
end;
table = record
hands: array [1..3] of deckType;
players: array [1..4] of person;
end;
</syntaxhighlight>
Line 387 ⟶ 419:
end;
function triple(
begin
triple := x * 3
Line 416 ⟶ 448:
Several Pascal compilers and interpreters are available for general use:
* [[Delphi (software)|Delphi]] is Embarcadero's (formerly Borland/CodeGear) flagship [[rapid application development]] (RAD) product. It uses the Object Pascal language (termed 'Delphi' by Borland), descended from Pascal, to create applications for [[Microsoft Windows|Windows]], [[macOS]], [[iOS]], and [[Android (operating system)|Android]]. The [[.NET]] support that existed from D8 through D2005, D2006, and D2007 has been terminated, and replaced by a new language (Prism, which is rebranded Oxygene, see below) that is not fully backward compatible. In recent years [[Unicode]] support and [[Generic programming|generics]] were [[Generic programming#In Delphi|added]] (D2009, D2010, Delphi XE).
* [[Free Pascal]] is a [[Cross-platform software|cross-platform]] compiler written in [[Object Pascal]] (and is [[Self-hosting (compilers)|self-hosting]]). It is aimed at providing a convenient and powerful compiler, both able to compile legacy applications and to be the means to develop new ones. It is distributed under the [[GNU General Public License]] (GNU GPL), while packages and runtime [[Library (computing)|library]] come under a modified [[GNU Lesser General Public License]] (GNU LGPL). In addition to compatibility modes for [[Turbo Pascal]], Delphi, and Mac Pascal, it has its own procedural and object-oriented syntax modes with support for extended features such as [[operator overloading]]. It supports many platforms and operating systems. Current versions also feature an ISO mode.
* [[Turbo51]] is a free Pascal compiler for the [[Intel 8051]] family of microcontrollers, with [[Turbo Pascal]] 7 syntax.
* [[Oxygene (programming language)|Oxygene]] (formerly named ''Chrome'') is an Object Pascal compiler for the [[
* [[Kylix (software)|Kylix]] was a descendant of [[Delphi (software)|Delphi]], with support for the [[Linux]] operating system and an improved object library. It is no longer supported. Compiler and IDE are available now for non-commercial use.
* [[GNU Pascal]] Compiler (GPC) is the Pascal compiler of the [[GNU Compiler Collection]] (GCC). The compiler is written in C, the runtime library mostly in Pascal. Distributed under the [[GNU General Public License]], it runs on many platforms and operating systems. It supports the ANSI/ISO standard languages and has partial Turbo Pascal dialect support. One of the more notable omissions is the absence of a fully Turbo Pascal-compatible (short)string type. Support for Borland Delphi and other language variants is quite limited. There is some support for Mac-pascal, however.
Line 505 ⟶ 537:
===Early criticism===
===Rising popularity in the 1970s and 1980s===
In the two decades after 1975, Pascal gained increasing attention and became a major programming language for important platforms (including Apple II, Apple III, Apple Lisa, Commodore systems, Z-80-based machines and IBM PC) due to the availability of UCSD Pascal and Turbo Pascal.<ref>{{cite web |last1=Crespo |first1=Diego |title=Pascal: The language that almost took over the world part 1 |url=https://www.deusinmachina.net/p/pascal-the-language-that-almost-took?utm_source=publication-search |website=www.deusinmachina.net |access-date=4 January 2025 |language=en}}</ref>
Despite initial criticisms, Pascal continued to evolve, and most of Kernighan's points do not apply to versions of the language which were enhanced to be suitable for commercial product development, such as Borland's [[Turbo Pascal]]. As Kernighan predicted in his article, most of the extensions to fix these issues were incompatible from compiler to compiler. Since the early 1990s, however, most of the varieties seem condensed into two categories: ISO and Borland-like. Extended Pascal addresses many of these early criticisms. It supports variable-length strings, variable initialization, separate compilation, short-circuit Boolean operators, and default (<code>otherwise</code>) clauses for case statements.<ref>{{Cite web |url=http://pascal-central.com/ppl/chapter3.html#Extended |title=Extended Pascal |url-status=dead |archive-url=https://web.archive.org/web/20151018023934/http://www.pascal-central.com/ppl/chapter3.html |archive-date=2015-10-18 |access-date=2015-10-17 }}</ref>
Some of the problems arising from the differences in the implementations of Pascal were later partly solved by the advent of Free Pascal, which supports several dialects with mode directives.<ref>{{cite web |last1=Crespo |first1=Diego |title=Pascal: The language that almost took over the world part 2 |url=https://www.deusinmachina.net/p/pascal-the-language-that-almost-took-56a?utm_source=publication-search |website=www.deusinmachina.net |access-date=4 January 2025 |language=en}}</ref>
==Notes==
Line 533 ⟶ 570:
* C. A. R. Hoare: "Notes on data structuring". In O.-J. Dahl, E. W. Dijkstra and C. A. R. Hoare, editors, ''Structured Programming'', pages 83–174. Academic Press, 1972.
* C. A. R. Hoare, Niklaus Wirth: ''An Axiomatic Definition of the Programming Language Pascal''. 335–355, Acta Informatica, Volume 2, 1973.
* Kathleen Jensen and Niklaus Wirth: ''[https://web.archive.org/web/20050314152247/http://www.cs.inf.ethz.ch/~wirth/books/Pascal/ Pascal – User Manual and Report]''. Springer-Verlag, 1974, 1985, 1990, 1991, {{ISBN|0-387-97649-3}} and {{ISBN|3-540-97649-3}}.
* Niklaus Wirth: ''[[Algorithms + Data Structures = Programs]]''. Prentice-Hall, 1975, {{ISBN|0-13-022418-9}}.
* Niklaus Wirth: ''An assessment of the programming language Pascal''. 23–30 ACM SIGPLAN Notices Volume 10, Issue 6, June 1975.
Line 553 ⟶ 590:
[[Category:Academic programming languages]]
[[Category:Systems programming languages]]
[[Category:Articles with example Pascal code]]▼
[[Category:Educational programming languages]]
[[Category:High-level programming languages]]
Line 559 ⟶ 595:
[[Category:Programming languages with an ISO standard]]
[[Category:1970 software]]
<!-- Hidden categories below -->
▲[[Category:Articles with example Pascal code]]
[[Category:Compiled programming languages]]
|