Pascal is based on the ALGOL programming language and named in honor of
mathematician and philosopher Blaise Pascal. Wirth subsequently developed
Modula-2 and Oberon, languages similar to Pascal.
Initially, Pascal was a language intended to teach students structured
programming, and generations of students have "cut their teeth" on Pascal as
an introductory language in undergraduate courses. Variants of Pascal are still
widely used today, for example Free Pascal can be used in both 32 and 64 bit
formats, and all types of Pascal programs can be used for both education and
Parts of the original Macintosh operating system were hand-translated into
Motorola 68000 assembly language from the Pascal code used in the Apple
Lisa (though later versions incorporated substantial amounts of C++ as well),
and the most frequent high-level language used for development in the early
Mac community was Pascal. In addition, the popular typesetting
system TeX was written by Donald E. Knuth in WEB, a variant of Pascal
designed for literate programming.
The first Pascal compiler was designed in Zurich for the CDC 6000 computer
family, and it became operational in 1970.
The first successful port of the CDC Pascal compiler to another mainframe
was completed by Welsh and Quinn at the Queen's University of Belfast in
1972. The target was the ICL 1900 computer.
The first Pascal compiler written in North America was constructed at the
University of Illinois under Donald B. Gillies for the PDP-11 and generated
native machine code.
In order to rapidly propagate the language, a compiler "porting kit" was
created in Zurich that included a compiler that generated code for a "virtual"
stack machine (i.e. code that lends itself to reasonably efficient interpretation),
along with an interpreter for that code - the p-code system. Although the p-
code was primarily intended to be compiled into true machine code, at least
one system, the notable UCSD implementation, utilized it to create an
interpretive system UCSD p-System. The P-system compilers were termed P1-
P4, with P1 being the first version, and P4 being the last.
Watcom Pascal was developed for the IBM mainframe in the early 1980s.
IP Pascal was an implementation of the Pascal programming language using
Micropolis DOS, but was moved rapidly to CP/M running on the Z80.
In the early 1980s, UCSD Pascal was ported to the Apple II and Apple III
computers to provide a structured alternative to the BASIC interpreters that
came with the machines.
Apple Computer created its own Lisa Pascal for the Lisa Workshop in 1982
and ported this compiler to the Apple Macintosh and MPW in 1985. In 1985
Larry Tesler, in consultation with Niklaus Wirth, defined Object Pascal and
these extensions were incorporated in both the Lisa Pascal and Mac Pascal
In the 1980s Anders Hejlsberg wrote the Blue Label Pascal compiler for the
Nascom-2. A reimplementation of this compiler for the IBM PC was marketed
under the names Compas Pascal and PolyPascal before it was acquired by
Borland. Renamed to Turbo Pascal it became hugely popular, thanks in part
to an aggressive pricing strategy and in part to having one of the first full-
screen Integrated development environments. In 1986 Anders ported Turbo
Pascal to the Macintosh and incorporated Apple's Object Pascal extensions
into Turbo Pascal. These extensions were then added back into the PC
version of Turbo Pascal for version 5.5.
The inexpensive Borland compiler had a large influence on the Pascal
community that began concentrating mainly on the IBM PC in the late 1980s.
Many PC hobbyists in search of a structured replacement for BASIC used this
product. It also began adoption by professional developers. Around the same
time a number of concepts were imported from C in order to let Pascal
programmers use the C-based API of Microsoft Windows directly. These
extensions included null-terminated strings, pointer arithmetic, function
pointers, an address-of operator and unsafe typecasts.
However, Borland later decided it wanted more elaborate object-oriented
features, and started over in Delphi using the Object Pascal draft standard
proposed by Apple as a basis. (This Apple draft is still not a formal standard.)
Borland also called this Object Pascal in the first Delphi versions, but changed
the name to Delphi Programming Language in later versions. The main
additions compared to the older OOP extensions were a reference-based
object model, virtual constructors and destructors, and properties. There are
several other compilers implementing this dialect, see Object Pascal.
Turbo Pascal, and other derivatives with units or module concepts are
modular languages. However, it does not provide a nested module concept or
qualified import and export of specific symbols.
Super Pascal was a variant which added non-numeric labels, a return
statement and expressions as names of types.
The universities of Zurich, Karlsruhe and Wuppertal have developed an
EXtension for Scientific Computing (Pascal XSC) based on Oberon, which
provides a free solution for programming numerical computations with
Pascal, in its original form, is a purely procedural language with the standard
array of if, while, for, and related constructs.
Syntactically, Pascal is distinguished from languages in the C family by a
preference for (sometimes abbreviated) English keywords in places where C
uses special punctuation; for example, Pascal's remainder operator is the
keyword mod, but C's is the single character %. Another, subtle, difference is
the role of the semicolon. In Pascal semicolons separate statements (of any
kind) within a compound statement, whereas in C semicolons are part of
expression statements. This difference is not apparent when looking at a
sequence of assignments and calls, because each line typically ends in a
semicolon in either style. It manifests itself primarily in two situations, namely
that there can never be a semicolon directly before else in Pascal (whereas a
semicolon there is mandatory in C unless a block statement is used), and that
the last statement before an end is not followed by a semicolon. Some Pascal
programmers nevertheless as a matter of style put a semicolon on the last
line before end, thereby formally inserting an empty statement at the end of
the compound statement. Some educators discourage this style, worried that
it may confuse students' perception of the formal role of the semicolon.
 Hello world
All Pascal programs start with the "Program" keyword, an optional list of
external file descriptors and then a block of code is indicated with the "Begin"
and "End" keywords. Semicolons separate statements, and the full stop ends
the program (or unit). Letter case is ignored in Pascal source.
Here is an example of the source code in use for a very simple program:
 Data structures
Pascal has real, integer, character and boolean as the simple types, plus
enumerations, a new type introduced with Pascal.
e: (one, two, three, four, five);
A "subrange" of the "ordinal" types can be made.
Types can be built from other types by the type declaration.
x = integer;
y = x;
Further, complex types can be constructed from simple types:
a = array [1..10] of integer;
b = record
c = file of a;
As shown in the example above, Pascal files are sequences of components.
Every file has a buffer variable which is denoted by f^. The procedures get
(for reading) and put (for writing) move the buffer variable to the next
element. Read is introduced such that read(f, x) is the same as x:=f^; get(f);.
Write is introduced such that write(f, x) is the same as f^ := x; put(f); The
type text is predefined as file of char. While the buffer variable could be used
to inspect the next character that would be used (check for a digit before
reading an integer), this concept leads to serious problems with interactive
programs. Pascal 6000 and VAX Pascal had incompatible solutions for this
problem and most other implementations omit the get and put procedures.
In Jensen & Wirth Pascal, strings are represented as packed arrays of chars;
they therefore have fixed length and are usually space-padded. Later dialects
commonly add a string type where the length of the contents can vary up to
a declared maximum length. These are usually implemented by a length byte
(limiting the maximum length to 255) and a fixed array of payload characters,
and are therefore space-inefficient if the maximal length is seldom used in
Pascal supports the use of pointers:
a = ^b;
b = record
Here the variable pointer_to_b is a pointer to the data type b, a record. To
create a new record and assign the values 10 and A to the fields a and b in
the record, the commands would be;
pointer_to_b^.a := 10;
pointer_to_b^.b := 'A';
pointer_to_b^.c := nil;
Linked lists can be created by including a pointer type field (c) in the record
(see also nil and null (computer)).
 Control structures
Pascal is a structured programming language, meaning that the flow of
control is structured into standard statements, ideally without 'go to'
while a <> b do writeln('Waiting');
if a > b then
for i := 1 to 10 do writeln('Iteration: ', i:1);
repeat a := a + 1 until a = 10;
 Procedures and functions
Pascal structures programs into procedures and functions.
var i : integer;
procedure print(var j: integer);
function next(k: integer): integer;
next := k + 1
writeln('The total is: ', j);
j := next(j)
i := 1;
while i <= 10 do print(i)
Procedures and functions can nest to any depth, and the 'program' construct
is the logical outermost block.
Each block can have its own declarations of goto labels, constants, types,
variables, and other procedures and functions, which must all be in that order.
This ordering requirement was originally intended to allow efficient single-
pass compilation. However, in most modern dialects the strict ordering
requirement of declaration sections has been abandoned.