Pascal (programming language)

The Pascal programming language (named after the mathematician Blaise Pascal ) was introduced by Niklaus Wirth at ETH Zurich in 1971 as a teaching language to teach structured programming.

General information on the language

Pascal is a further development of Algol 60 It leans in its syntax very similar to the English grammar. This is to improve readability for programming beginners and therefore makes it particularly suitable as a teaching language. Its widespread use in professional programming found it as Borland / Turbo Pascal ( Object Pascal later ) - compared to the original Pascal much more enhanced and improved versions.

An important concept that brought Wirth apply strong typing (English " strong typing" ) is: variables have already been assigned to a particular data type at compile time, and this can not be changed later. Type rigor means that value assignments are allowed only among variables of the same type. In Pascal, there is this strict constraint of only a few exceptions:

  • Value assignments of the form [ variable of type real]: = [ value of type integer].
  • In Extended Pascal value assignments of integer or real numbers to variables of type Complex.
  • Value assignments of limited ranges of ordinal type. Example: type INT10 = 1 .. 10; Values ​​of this type Integer variables can then be assigned.
  • Value assignments of amounts of a restricted range of values ​​of an ordinal type. Example: type = set10 set of 1 .. 10; Set20 = set of 1 .. 20; Values ​​of type set10 can then be assigned to variables of type Set20.
  • Value assignments to restricted ranges of values ​​of an ordinal type or quantity. In this case, values ​​or amounts of elements call outside the target range produces a runtime error.
  • Value assignments between different string types, including char, character arrays, standard Pascal and the different string types in Extended Pascal, Borland Pascal, etc. If the length of the value is not in accordance within the capacity of the target, also arises here a runtime error.

Today Pascal is in the university sector ( development / training) and in safety-critical applications (such as transportation, energy, medical technology, aerospace, military, partly in the banking and insurance) application. This is mainly due to the good testability and maintainability of the code and the clear assignment of the variables. Thus, the operation control system, introduced in 2005 IV of the Transrapid Test Facility Emsland is programmed in Pascal. A pascal -like notation is used from time immemorial in the computer science and mathematics to represent algorithms. For didactic reasons, here are the type of austerity, high fail-safety and freely available portable Pascal compiler ( Free Pascal, GNU Pascal ) called, is also frequently used in current computer science teaching Pascal. In the hobby area Pascal became temporarily a very wide distribution, but went back with newer Microsoft Windows versions.

Data types

A data type specifies what values ​​a variable can take and what operations can be used on you. The simple data types in Pascal are:

The length of the various data types besides Boolean dependent on the compiler. Furthermore, many implementation have additional predefined primitive data types.

From the simple ordinal data types (all except real) types can be derived, which are subsets of these data types. example:

Type byte = 0 .255; / / Variable of type "byte " can now enjoy the whole numbers from 0 to 255 to accept as a value                       / / Which is a subset of integers. Furthermore, the data structures can array and set ( quantity) can be used.

Pointer may also be used in Pascal. However, there is no pointer arithmetic.

Program Structures

Characteristic of Pascal is the concept of nesting of procedures and functions. In a procedure or function declaration part of other procedures and functions can be defined that are not visible outside. example:

Hello World program;      procedure foo;          procedure bar;          begin              writeln ( 'Hello World' );          end;      begin          bar ();      end; begin      foo (); / / no compiler error      bar (); / / Compiler error because bar is not visible end. control structures

For branches can be used in Pascal if-else and case. For loops exist while, repeat-until and for. Jump instructions can be goto also used, its use is controversial (see articles on jump instructions ).

Compiler

The first Pascal compiler itself was built on the CDC Cyber ​​6000 ETH Zurich. This then was Pascal 6000, which can be seen as a first operational version of a compiler of the language.

A second Pascal Compiler - P4 "Portable Pascal Compiler" by Urs Ammann, Kesav Nori and Christian Jacobi - also came from the ETH Zurich. The P4 produced a cross-platform, designed as assembly language, intermediate language, the P- code (a program ) is interpreted by a virtual machine. Later developed compilers based on P4. The most common version was known under the name of UCSD Pascal, which was implemented on many systems, including the Apple II and Texas Instruments TI-99/4A and significantly to the spread of the language both ( first) in the United States, and later contributed in Europe. In May 2006, the sources from UCSD Pascal were released.

Most Pascal compilers it was single-pass compiler, that is, the compiler must read and analyze a single time source. The design of the tongue was held so as to enable just that. These were times of low speed of the computer, this was a great advantage.

Differences to C

Standards

There are three standards that relate to Pascal:

However - as with most other programming languages, too - only a few compiler to these standards fully compatible. This fact misled Scott A. Moore to the biting remark " Pascal is, unfortunately, very much a great improvement on its Successors " ( " Pascal is unfortunately pretty much a big improvement to its successor " - at that time already a winged set).

Even large compilers such as Delphi or Free Pascal are still missing some elements of standard Pascal, while Extended Pascal is hardly supported by a. Only Prospero Pascal is fully compatible with Extended Pascal, GNU Pascal while also seeking full compatibility.

Pascal and Mac OS

Historically interesting is the fact that Apple had put in the development of the operating system and the applications running on the Apple II successor Macintosh Pascal. For this purpose was developed at Apple in a register held by Larry Tesler team consultation by Niklaus Wirth own Object Pascal variant, which was derived from an earlier object-oriented Pascal variant called Clascal, which was already available on Lisa. Object Pascal was necessary for the support of MacApp, a Macintosh application framework that would today fall under the concept class library. Object Pascal was completed in 1986. Apple ended the Focus on Object Pascal with the transition from Motorola 68K CPUs and PowerPC CPUs from IBM in 1994 with the operating system version of Mac OS 7.5. For the purpose of backward compatibility, the transfer of parameters for operating system calls until the last Mac OS version 9.2.2 of the year remained similar to Pascal conventions in 2002.

Implementations ( compilers, interpreters and IDEs)

Pascal had in academia huge success, which, inter alia, was also reflected in the programming language Ada, which is very closely based on the syntax of Pascal from the beginning. Also it became widespread, even in the commercial sector, with the products of the company Borland Turbo Pascal, Borland Pascal and Delphi. These versions are characterized by strong extensions of the original language standards. Object orientation was here introduced with version 5.5.

Today there are several free implementations:

Integrated development environments:

Hello World

A Hello World program in Pascal looks like this:

Program Hello (output);   begin    writeln ( 'Hello World' );   end. or in newer versions of Pascal, the program like this:

Program Hello;   begin    writeln ( 'Hello World' );   end. A side note: In some old samples, we find a READLN after WRITELN command. It was only necessary because the I / O architecture of the CDC Cyber ​​6000, on the landlord the first Pascal compiler developed that needed to the internal buffer to empty - otherwise no output would be in interactive mode have been seen. IDEs could be forced with this READLN, at the end of program execution does not immediately switch back to the editor mode, which the output in some IDEs (eg Turbo Pascal ) otherwise would disappear. In batch mode, it never was necessary anyway.

Criticism

Since the language was designed as a teaching language, the standard Pascal had some features that made ​​it difficult for commercial use: The concept for file access ("file I / O") was not powerful, the runtime library not very extensive, and strings could only be indirectly ( packed array ) can be used directly in your code. This meant that virtually every commercial implementation of this offering their own solutions, which initially (similar to the diversification C) to own Pascal dialects and thus led to compatibility problems. With the monopoly-like dominance of Turbo Pascal Borland products of these differences disappeared almost completely.

Another major drawback was that a modularization in the sense of separate compilation was not intended - what has changed with the development of Modula -2. Platform-specific implementations looked for own solutions (eg the units of Turbo Pascal, or later the modules in ANSI / ISO Extended Pascal ).

Developments

  • Oberon, Oberon -2
  • POW! - Based on Oberon and Pascal
  • Component Pascal - based on Oberon
  • Embarcadero Delphi - Object-Oriented Pascal as an evolution of Borland Pascal.
  • Free Pascal - Delphi to a large extent compatible free implementation. There is also the Delphi IDE like Lazarus.
  • RemObjects Chrome, Oxygene, now licensed as Delphi Prism by CodeGear
  • Pocket Studio
  • StatPascal
  • Modula-2
635464
de