Pascal (programming language)

This is an old revision of this page, as edited by Jim McKeeth (talk | contribs) at 17:06, 11 August 2003 (clarify Delphi programming language link). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, Pascal is one of the landmark programming languages which has defined computer programming and is still in use today.

Niklaus Wirth developed it to enable structured programming that would be easier for a compiler to process. Pascal is based on the Algol programming language and is named in honor of mathematician Blaise Pascal. Wirth also developed Modula-2 and Oberon, languages similar to Pascal which also supports object-oriented programming.

Unique Features

Unlike programming languages descended from C, Pascal uses := for assignment instead of =. This is an advantage in differentiating comparisons and assignments. In C == is comparison, but = is an assignment. These can be easily interchanged resulting in an inline assignment instead of a comparison. This syntax leads to many hard-to-track bugs in C code. Since Pascal does not allow inline assignments, and uses distinct syntax for assignments and comparisons, it does not suffer from these bugs.

Another major difference is that Pascal is strongly typed. This means that all variables must be defined with a specific type before they can be used. Also, incompatible variable assignments are not allowed without an explicit type-cast. This prevents common errors where variables are used incorrectly because the type is unknown. It also alleviates the need for Hungarian notation - the practice of suffixing variable names with type-identifying letters.

Implementations

Early approaches (most notably the UCSD p-System) translated Pascal code into a machine-independent p-Code representation. This intermediate code was then interpreted by a program specific to each architecture. As a consequence, only the small interpreter part had to be ported to many architectures.

In the 1980s Anders Hejlsberg wrote the Blue Label Pascal compiler for the Nascom-2. Later he went to work for Borland and rewrote his compiler to become Turbo Pascal for the IBM PC. This new compiler sold for $49, which was much less than the price Hejlsberg originally asked for the Blue Label Pascal compiler.

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. Turbo Pascal, being available only on one architecture, translated directly to Intel 8088 machine code, making it much faster than interpreted schemes.

During the 1990s compilers that could be re-targeted to different hardware architectures became more prevalent. This allowed for Pascal translation to native machine code that was at the same time easily ported to new hardware.

With Turbo Pascal version 5 Borland added object orientation to Pascal.

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 isn't a formal standard yet.) Borland also called this Object Pascal in the first Delphi versions, but changed the name to Delphi programming language in later versions. The main changes 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 Delphi programming language.

Publicly available compilers

Several Pascal compilers are available for the use of general public:

  • GNU Pascal Compiler (GPC) is an additional front-end to the GNU Compiler Collection (GCC), and is written in C. Distributed freely under the GNU General Public License. The Borland/Turbo Pascal support is somewhat limited though.
  • FreePascal is written in Pascal (so that it compiles itself), and is aimed at providing a convenient and powerful compiler, able both to compile legacy applications and to be the means of develop new ones. Also distributed freely under the GNU GPL. It can mix Turbo Pascal with Delphi code, and supports a lot of platforms and operating systems.
  • Turbo Pascal was the dominant Pascal compiler for PCs during the 80s and early 90s, popular both because of its powerful extensions and extremely low compilation times. Currently, older versions of Turbo Pascal (up to 5.5) are available for free download from Borland's site (registration required).
  • Delphi is Borland's flagship RAD (Rapid Application Development) product. It uses the Delphi programming language, descended from Pascal, to create applications for the windows platform. The latest version also supports compiling to the .NET platform
  • Kylix is Borland's newest reiteration of the Pascal branch of their products. It is the descendant of Delphi, with support for the Linux operating system and an improved object library. The compiler and the IDE are available now for non-commercial use. The compiler (but not the library or the IDE) is supposed to become Open Source software some time soon.

Past Criticism

While very popular (although more so in the 1980s and early 1990s than at the time of writing), early versions of Pascal have been widely criticised for being unsuitable for "serious" use outside of teaching. Brian Kernighan, co-creator of the C programming language, outlined his most notable criticisms of Pascal as early as 1981, in his paper Why Pascal Is Not My Favorite Programming Language. Since that time Pascal has continued to evolve and most of his points do not apply to current implementations.

Many uninformed people still subscribe to the old belief that Pascal is not for "serious" programming and do not realize the benefits it currently offers. This stigma, more than any actual deficiency, is Pascal's biggest liability.

Further reading

See also