Pascal (programming language)

ImprimirCitar

Pascal is a programming language created by the Swiss professor Niklaus Wirth between 1968 and 1969, and published in 1970. His goal was to create a language that would make it easier for his students to learn programming., using structured programming and data structuring. However, over time its use exceeded the academic field to become a tool for creating applications of all kinds.

Pascal is characterized as a strongly typed programming language. This implies that, on the one hand, the code is divided into easily readable portions called functions or procedures, which makes it easier to use structured programming as opposed to the old style of monolithic programming; and, on the other, that the data type of all the variables must be previously declared for their use to be enabled.

History

Prior to delving into Pascal design, Niklaus Wirth had developed Euler and ALGOL W, and later went on to develop the Pascal-style Modula-2 and Oberon languages.

Initially, Pascal was largely, but not exclusively, intended to teach students structured programming. A generation of students use Pascal as an introductory language for graduation courses. Pascal variants have also been used for everything from research projects to PC games and embedded systems. There are new Pascal compilers that are widely used.

Pascal was the primary high-level language used for development on the Apple Lisa, and in the early years of the Macintosh. Portions of the original Macintosh operating system are translated by hand into Motorola 68000 assembly language from its Pascal sources.

Also, Donald E. Knuth's TeX typesetting system was written on WEB, the original literary programming system, based on DEC PDP-10 Pascal.

For their part, applications like Total Commander, Skype and Macromedia Captivate were written in Delphi (Object Pascal). Object Pascal (Embarcadero Delphi) is still used for Windows app development, but it also has the ability to cross-compile the same code for Mac, iOS, and Android.

Another cross-platform version called Free Pascal, with the Lazarus IDE, is popular among GNU/Linux users, as it is also in line with the "write once, compile anywhere" (write once) philosophy., compile anywhere). CodeTyphon is one of the Lazarus distributions with the most pre-installed packages and cross-compilers.

Unique Features

Another important difference is that in Pascal the type of a variable is fixed in its definition; assigning values of incompatible types to variables is not allowed (in C, on the other hand, the compiler does its best to give an interpretation to almost all kinds of assignments). This prevents common errors where variables are used incorrectly because the type is unknown; and it also avoids the need for Hungarian notation, which is just prefixes added to variable names to indicate their type.

Implementations

Early versions of the Pascal compiler, including the most widely distributed was UCSD Pascal, translated the language into code for a virtual machine called a P-machine. The great advantage of this approach is that to have a Pascal compiler on a new machine architecture you only need to reimplement the P-machine. As a consequence of this, only a small part of the interpreter had to be rewritten towards many architectures.

In the 1980s, Anders Hejlsberg wrote the Blue Label Pascal compiler for the Nascom-2. He later went to work for Borland and rewrote his compiler, which became Turbo Pascal for the IBM PC. This new compiler sold for $49, a price geared toward mass distribution.

The inexpensive Borland compiler had a long influence on the Pascal community that began using it primarily on the IBM PC. In search of a structured language, many PC hobbyists replaced BASIC with this product. Since Turbo Pascal was only available for one architecture, it translated directly into Intel 8088 machine code, managing to build programs that ran much faster than those produced on the interpreted schematics.

During the 1990s the technology became available to build compilers that could produce code for different hardware architectures. This allowed Pascal compilers to translate directly into the code of the architecture it runs on.

With Turbo Pascal version 5.5, Borland added object-oriented programming to Pascal.

However, Borland later decided to improve on that extension of the language by introducing his Delphi product, modeled after the Object Pascal standard, proposed by Apple Inc. as a base. Borland also called it Object Pascal in early versions, but changed the name to 'Delphi programming language' in its latest versions.

Examples

Hello world

A simple example of the Hello World program:

PROGRAM Hello (OUTPUT);BEGIN WriteLn('Hello, world!'); { Since the following instruction is not executable, it is not  requires the "END" instruction, although it can be put  according to the programmer preferences. !END.

Sum

PROGRAM Summa (INPUT, OUTPUT);VAR Add.1, Sumando2, Summa:INTEGER;BEGIN Write('get a number: '); ReadLn(Add.1); Write('increase another number: '); ReadLn(Sumando2); Summa:=Add.1 + Sumando2; WriteLn ('The sum is:',Summa); WriteLn ('Pulse [Intro] to end...'); readlnEND.

Square root

PROGRAM Raiz (INPUT, OUTPUT);(* Get the square root of a real number x any.*)VAR Value, Outcome: REALLY;BEGIN WriteLn ('** Calculate the square root **'); Write ('Introduce the value:'); ReadLn (Value);(*) Square root of the absolute value of x to avoid imaginary roots *) Outcome := sqrt (abs (Value); IF Value  0 THEN (*) If positive, there is the result in real *) WriteLn ('The square root of ', Value, 'It's ',Outcome) ELSE (*) If negative, the result is imaginary *) WriteLn ('There is no square root of ',Value,'in the real ones. '); Write ('Pulse [Intro] to end...');END.

Loops

An example loop:

PROGRAM MultiplosDe3 (INPUT, OUTPUT);VAR Number, Cnt: INTEGER;BEGIN Cnt := 0; Writeln ('Enter the first number of the series:'); ReadLn (Number); WHILE Number  0 DO BEGIN IF (Number MOD 3) = 0 THEN INC (Cnt); Write ('Give me another number (0 to finish): '); ReadLn (Number); END; WriteLn ('The number of multiples of 3 entered is ', Cnt); Write ('Pulse [Intro] to end...')END.

An example loop:

program Table;Use crt;vari,n:integer;begin clrscr; write(income the Table of multiply that wish See: ); readln(n); for i:=1 to 10 do begin writeln( i, x,n, =,in) end;readlnend.
PROGRAM CalculateFactorial (INPUT, OUTPUT);(*) Function that calculates the factorial of n (n!) in a recursive way. *) FUNCTION Factor (CONST N: INTEGER): INTEGER; BEGIN IF N  1 THEN Factor := N  (Factor (N - 1) ELSE Factor := 1 END;VAR Base: INTEGER;BEGIN Write ('Value of N: '); ReadLn (Base); WriteLn ('N!, Factor (Base); Write ('Pulse [Intro] to end...')END.

Vectors

PROGRAM Notes;Use crt;Typepupils = array [chuckles]1..40] of string;varName, Surname: pupils;Note: array [chuckles]1..40] of Real;Beginclrscr; /*Clean screen*/For i:= 1 to 40 do begin write(Income Name: ); readln(Name[chuckles]i]); write(Income Surname: ); readln(Surname[chuckles]i]); write(Income Note: ); readln(Note[chuckles]i]); end;For i:= 1 to 40 do begin write(Name[chuckles]i],  ,Surname[chuckles]i]); if (Note[chuckles]i] 7) then writeln( aprobo') else writeln( No. aprobo'); end;writeln(');Write ('Pulse [Intro] to end...');ReadlnuntilwhileRepeat end.

Libraries

Libraries contain procedures and functions. The goal is to group functions associated with some context or functionality. For example, a library can contain all the transcendental functions. Yet another complex number arithmetic.

When planning to use libraries, refer to the USES section of the program.

For example, to use the clrscr procedure, which is responsible for clearing the terminal screen where the output of the program appears in text mode, and the readkey function, induces the program to stop and not continue until the user presses a key. key, the CRT library must be used. program Example;

Use CRT;var Name: string[chuckles]10];begin clrscr; Name:= 'Manuel'; writeln(Name); readkeyend.

Compilers

Several Pascal compilers are available for general public use:

  1. Delphi is a RAD (Rapid Application Development) product initially developed by Borland and currently by Embarcadero. It uses the programming language Delphi, descendant of Pascal, to create applications for the Windows platform. The latest versions also generate executables for MacOS X, Linux and.NET.
  2. Free Pascal is written in Pascal (the compiler is created using Free Pascal), it is a stable and powerful compiler. Also distributed freely under the GPL license. This system allows you to mix Turbo Pascal code with Delphi code, and supports many platforms and operating systems.
  3. GNU Pascal compiler (GPC), written in C, based on the GNU Compiler Collection (GCC). It is distributed under GPL license.
  4. Turbo Pascal was the dominant Pascal compiler for PC during the 1980s and until the early 1990s, very popular due to its magnificent extensions and very short compilation times. Currently, old versions of Turbo Pascal (up to 7.0) are available for free download from the Borland site (you need to register).
  5. Oxygene is a Pascal Object compiler for platforms.NET and Mono. Created by RemObjects Software. It includes modern features in syntax, with influences of C#, Eiffel, Java, F# and other lengaujes.

Modern Pascal is a cross-platform, p-code interpreter and compiler written in Free Pascal. It is intended as an alternative solution to PHP and node.js, using the ISO Pascal dialect or a hybrid dialect with JavaScript/C operators.

  1. Kylix was a Delphi version for the Linux operating system promoted by the former Borland reiterating the Pascal branch of its products. As a descendant of Delphi it has an enhanced object library called CLX, which is the Linux version of the VCL. However, the project had already been discontinued long before Borland sold all its development products to Embarcadero Technologies, the current owner of Delphi.
  2. MidletPascal for the J2ME platform.
  3. Turbo51 is a free Pascal compiler for the 8051 family microcontroller family, which runs the Turbo Pascal syntax.
  4. PIC Micro Pascal, for PIC microcontrollers.
  5. PicPas, multiplatform and open source compiler, for medium-range PIC microcontrollers. Includes an IDE and a simulator/debugger in the same application.
  6. Smart Mobile Studio translates a program in Object Pascal dialect to JavaScript, specially designed to be used on mobile devices.
  7. TMT. Pascal.

IDE

  • Delphi includes a modern and quite complete IDE, in addition to the compiler that is included as part of its commercial product.
  • Lazarus is a Delphi clone, based on Free Pascal is free software.
  • Dev-Pascal is an IDE to develop in Object Pascal that supports the Free Pascal and GNU Pascal compilers.
  • MSEide is a multi-platform IDE to develop on Free Pascal. It includes its own classroom library.
  • CodeTyphon is a multi-platform IDE to develop on Free Pascal, very similar to Lazarus, but includes a much greater number of visual components.

News

Currently this language continues to be used in the development of applications, thanks to the appearance of development tools for new platforms such as Oxygene or Smart Mobile Studio and the modernization of older compilers and environments such as Delphi, Free Pascal and Lazarus. Today the Free Pascal compiler and the like are used to teach programming in schools. Older compilers such as Turbo Pascal are also used.

Contenido relacionado

ISO 3166-2:JP

Main article: ISO...

Turbo Pascal

Turbo Pascal is a software development system that includes a compiler and an integrated development environment for the Pascal programming language...

ReactOS

ReactOS is a free and open source operating system for PCs. x86/x64 developed to be binary compatible with software and device drivers designed for Microsoft...
Más resultados...
Tamaño del texto:
Copiar