Pascal (programming language)

From Wikipedia, the free encyclopedia

Jump to: navigation, search

Pascal is an influential imperative and procedural programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small and efficient language intended to encourage good programming practices using structured programming and data structuring.

A derivative known as Object Pascal was designed for object oriented programming.

Pascal
Paradigm imperative, structured
Appeared in 1970, last revised 1992
Designed by Niklaus Wirth
Typing discipline static, strong, safe
Major implementations CDC 6000, Pascal-P, PDP-11, PDP-10, IBM System/370, HP, GNU
Dialects UCSD, Borland, Turbo
Influenced by ALGOL
Influenced Modula-2, Ada, Object Pascal, Oxygene

Contents

[edit] History

Pascal is based on the ALGOL programming language and named in honor of the French mathematician and philosopher Blaise Pascal. Wirth subsequently developed the Modula-2 and Oberon, languages similar to Pascal. Before, and leading up to Pascal, Wirth developed the language Euler, followed by Algol-W.

Initially, Pascal was largely, but not exclusively, intended to teach students structured programming. Generations of students have "cut their teeth" on Pascal as an introductory language in undergraduate courses. Variants of Pascal have also frequently been used for everything from research projects to PC games and embedded systems. Newer Pascal compilers exist which are widely used.

Pascal was the primary high-level language used for development in the Apple Lisa, and in the early years of the Mac; parts of the original Macintosh operating system were hand-translated into Motorola 68000 assembly language from the Pascal sources. The popular typesetting system TeX by Donald E. Knuth was written in WEB, the original literate programming system, based on DEC PDP-10 Pascal, while an application like Total Commander was written in Delphi (i.e. Object Pascal).

[edit] Brief description

Wirth's intention was to create an efficient language (regarding both compilation speed and generated code) based on so-called structured programming, a concept which had recently become popular. Pascal has its roots in the Algol 60 language, but also introduced concepts and mechanisms which (on top of Algol's scalars and arrays) enabled programmers to define their own complex (structured) datatypes, and also made it easier to build dynamic and recursive data structures such as lists, trees and graphs. Important features included for this were records, enumerations, subranges, dynamically allocated variables with associated pointers, and sets. To make this possible and meaningful, Pascal has a strong typing on all objects, which means that one type of data cannot be converted or interpreted as another without explicit conversions. Similar mechanisms are standard in many programming languages today. Other languages that influenced Pascal's development were COBOL, Simula 67, and Wirth's own Algol-W .

Pascal, like many scripting languages of today (but unlike most languages in the C-family), allows nested procedure definitions to any level of depth, and also allows most kinds of definitions and declarations inside procedures and functions. This enables a very simple and coherent syntax where a complete program is syntactically nearly identical to a single procedure or function (except for the keyword itself, of course).

[edit] Implementations

The first Pascal compiler was designed in Zurich for the CDC 6000 series mainframe computer family. Niklaus Wirth reports that a first attempt to implement it in Fortran in 1969 was unsuccessful due to Fortran's inadequacy to express complex data structures. The second attempt was formulated in the Pascal language itself and was operational by mid-1970. Many Pascal compilers since have been similarly self-hosting, that is, the compiler is itself written in Pascal, and the compiler is usually capable of recompiling itself when new features are added to the language, or when the compiler is to be ported to a new environment. The GNU Pascal compiler is one notable exception, being written in C.

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. Pascal enjoyed great popularity throughout the 1970s and the 1980s.

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 Pascal-P system. Although the SC (Stack Computer) code was primarily intended to be compiled into true machine code, at least one system, the notable UCSD implementation, utilized it to create the interpretive UCSD p-System. The P-system compilers were termed P1-P4, with P1 being the first version, and P4 being the last to come from Zurich.

The P4 compiler/interpreter can still be run and compiled on systems compatible with original Pascal. However, it only itself accepts a subset of the Pascal language. A version of P4 that accepts the full Pascal language and includes ISO 7185 compatibility was created and termed the P5 compiler, which is available in source form. An alternative version known as the "model implementation" of Pascal also accepts and is written in ISO 7185, but is not available in computer readable form.

A version of the P4 compiler, which created native binaries, was released for the IBM System/370 mainframe computer by the Australian Atomic Energy Commission; it was called the "AAEC Pascal Compiler" after the abbreviation of the name of the Commission. A version of P4 from 1975-6 including source and binaries for the compiler and run-time library files for the PDP-10 mainframe may be downloaded from this link.

In the early 1980s, Watcom Pascal was developed, also for the IBM System 370.

IP Pascal was an implementation of the Pascal programming language using Micropolis DOS, but was moved rapidly to CP/M running on the Z80. It was moved to the 80386 machine types in 1994, and exists today as Windows/XP and Linux implementations. In 2008, the system was brought up to a new level and the resulting language termed "Pascaline" (after Pascal's calculator). It includes objects, namespace controls, dynamic arrays, along with many other extensions, and generally features the same functionality and type protection as C#. It is the only such implementation which is also compatible with the original Pascal implementation (which is standardized as ISO 7185).

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 compilers.

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. Additionally, it was written and highly optimized entirely in assembly language, making it smaller and faster than much of the competition. 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