Turbo Pascal

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search
Turbo Pascal
Turbo Pascal 4.0 (1987) startup screen.
Turbo Pascal 4.0 (1987) startup screen.
Developer(s) Borland
Operating system CP/M, CP/M-86, MS-DOS,
Windows 3.x, Macintosh
Platform 8080/Z80, 8085, x86
Type Integrated development environment

Turbo Pascal is a software development system that includes a compiler and an Integrated Development Environment (IDE) for the Pascal programming language running under CP/M, CP/M-86, and MS-DOS, developed by Borland under Philippe Kahn's leadership. The name Borland Pascal was generally reserved for the high-end packages (with more libraries and standard library source code) while the original cheap and widely known version was sold as Turbo Pascal. The name Borland Pascal is also used more generically for Borland's dialect of Pascal.

Turbo Pascal is generally considered to be the first popular Integrated Development Environment (IDE) of any type.[citation needed] Borland has released three old versions of Turbo Pascal free of charge because of their historical interest: versions 1.0, 3.02 and 5.5 for MS-DOS.

Motivation and release

Philippe Kahn first saw an opportunity for Borland, his newly formed software company, in the field of programming tools. Historically, the vast majority of programmers saw their workflow in terms of the edit/compile/link cycle, with separate tools dedicated to each task. Programmers wrote source code and entered it using a text editor, a compiler then created object code from source (often requiring multiple passes), and a linker combined object code with runtime libraries to produce an executable program.

In the IBM PC market of the early 1980s, the major programming tool vendors included IBM, Microsoft, and Lattice. They all made C compilers (and some made Pascal compilers), which all worked in a similar fashion. For example, the Microsoft Pascal system consisted of two compiler passes and a final linking pass (which could take minutes on systems with only floppy disks for secondary storage). This process was the cumbersome product of the extremely limited resources of the early IBM PC models. Vendors of software development tools aimed their products at professional developers, and the price for these basic tools plus ancillary tools like profilers ran into the hundreds of dollars.

Kahn's idea was to integrate these separate functions in a programming toolkit, have it run with much better performance, and charge one low price for it all. Instead of selling the kit through established sales channels (retailers or resellers), his new tool would be sold inexpensively via mail-order.

As an additional selling point against the bigger vendors, Turbo Pascal disks came with no copy protection of any sort. Turbo Pascal came with the famous "Book License": "You must treat this software just like a book ... [it] may be used by any number of people ... may be freely moved from one computer location to another". Since the first versions didn't have online help, copy protection was effectively enforced by possession of the Turbo Pascal reference manual (pictured below). So, treating it "like a book" was rather a redundant thing to ask, since one needed the real book anyway.

Versions 1 to 3

File:Turbo pascal 30 cover.jpg
Turbo Pascal 3.0 manual front cover

The Turbo Pascal compiler was based on the Blue Label Pascal compiler originally produced for the NasSys cassette-based operating system of the Nascom microcomputer in 1981 by Anders Hejlsberg. This was first rewritten as the Compas Pascal compiler for CP/M and then as the Turbo Pascal compiler for MS-DOS and CP/M. A version of Turbo Pascal was available for the Apple Macintosh from about 1986 but was discontinued around 1992. Another version was available for CP/M machines like the DEC Rainbow through several releases.

Borland licensed the PolyPascal compiler core, written by Anders Hejlsberg (Poly Data was the name of his company in Denmark), and added the user interface and editor. Anders joined the company as an employee and was the architect for all versions of the Turbo Pascal compiler and the first three versions of Borland Delphi.[1]

The first version of Turbo Pascal, later referred to as version 1, was very fast compared to other microcomputer Pascal compilers. It was available for the CP/M, CP/M-86, and MS-DOS operating systems, all widely used at the time. The CP/M version could be used on the very popular Apple II computer if fitted with a Z-80 SoftCard, the first hardware product of the small company Microsoft released in 1980.

At the time CP/M used a simple executable file format using the file name extension .COM; MS-DOS could use either .COM files (incompatible with CP/M) or the more flexible relocatable .EXE format used almost universally in later years. Turbo Pascal generated only .COM files, which was not a severe restriction for the computer world of the time. Turbo Pascal itself was a single .COM file about 38 kilobytes long. which included the editor, compiler, linker, and the library routines. The edit/compile/run cycle was fast compared to other Pascal implementations because everything related to building the program was stored in RAM, and because it was a one-pass compiler, that was written in assembler. Compilation was very quick compared to that for other languages (even Borland's own later compilers for C)[citation needed], and programmer time was also saved since the program could be compiled and run from the IDE. Writing the program to disk was a menu option.

When the first version of Turbo Pascal appeared on November 20, 1983, the type of IDE it used was relatively new. On its debut in the United States market, Turbo Pascal retailed for USD$49.99. The integrated Pascal compiler also was of very good quality compared to other Pascal products of the time and above all was affordable. The Turbo name alluded to its compilation speed as well as the speed of the executables it produced. The speed of these com executable files was a revelation for developers whose only previous experience programming microcomputers was with interpreted BASIC or UCSD Pascal, which compiled to p-code.

The IDE was very advanced for its day, when computing resources were very limited. The IBM PC and other machines were often sold with 64 kB of RAM; the IBM PC could be expanded to a maximum 640 kB. Many machines were equipped with only one or two floppy disc drives of 180 or 360 kilobytes capacity (depending on if the drive was single-sided or double-sided); and perhaps as a luxury a 5 or 10 MB hard disk. The IDE was simple and intuitive, and had a well-organized system of menus. Early versions of the editor used WordStar key functions, which was the de facto standard at the time. Later versions of the IDE, designed for PCs with more disk space and memory, could display the definitions of the keywords of the language by putting the cursor over a keyword and pressing the F1 key. The definitions also frequently included examples code. This let inexperienced programmers learn Pascal simply by using the IDE, without needing help from a book.

Versions 2 and 3 were improved versions of the same, basic all-in-one system, working in memory and producing .COM files for MS-DOS and CP/m, and.CMD files for CP/M-86.

The .COM format let programmers write Terminate and Stay Resident programs, small utilities that stayed in memory and let the computer do other tasks, something very popular in the days before multitasking systems such as Microsoft Windows. Borland itself produced a small application suite called SideKick that was a TSR letting the user keep a diary, notes, and so forth.

Later versions

Version 4, released in 1987, was a major rewrite of the whole system. The compiler generated executables in EXE format under MS-DOS, rather than the simpler but more restricted .COM executables. Support for the by-then obsolete CP/M and CP/M-86 operating systems was dropped. This version also introduced a full-screen user interface with pull-down menus; earlier versions had a text-based menu screen and a separate full-screen editor. (Microsoft Windows did not exist when the first version was released, and even mice were a rarity.)

Version 5.x introduced the familiar Borland blue screen, which would be the trademark of the company's MS-DOS compiler tools until the end of this product line in the middle 1990s.

Assembly language

While all versions of Turbo Pascal could include inline machine code, later versions had the ability to easily integrate assembly language within Pascal. In the earliest version, the hexadecimal machine code had to be written into the program. Later versions let assembly code be written. Assembly provides the lowest human-readable interface to the machine, and allows faster execution than can be generated by a compiler, with access to the machine at a very detailed level. Quality of code generated by even latest version of Borland Pascal was very poor compared to what one could do with assembly. Overall program execution could be improved by coding much-executed inner-loop code this way. Inline assembly also enabled the programmer to access hardware features that were otherwise not directly available. Inline assembly was in fact overused by experienced Turbo Pascal programmers, as it could be seen from the source code of Turbo Chess, Turbo Vision etc.

Support for the 8086 memory model was provided by inline assembly, compiler options, and language extensions such as the "absolute" keyword.

Debugging

The IDE allowed single stepping through a program for debugging, and now assembly-language blocks could be stepped through. The user could add watches on variables and registers in an IDE window. Programs using IBM PC graphics mode could flip between graphics and text mode automatically or manually.

The IDE also included a code profiler that could report on which parts of the program were using the most time. The books included with Borland Pascal had detailed descriptions of the Intel assembler language, going so far as to provide the clock cycles required by each instruction. Overall this system, as a whole, made for a relatively pleasant experience when trying to debug and optimize code; the user never had to leave the IDE.

Later versions also allowed for remote debugging via an RS232 communication cable.[citation needed]

Units

Over the years, Borland enhanced not only the IDE, but also the programming language. Borland's dialect of Pascal became a de facto industry standard (and is still implemented by modern compilers like Free Pascal), since ISO standard Pascal proved inadequate for real-world application development.

In particular, standard Pascal does not allow a large program to be split into separate compilation units. From version 4.0, the language introduced the concept of units. Units were used as external function libraries, like the object files used in other languages such as C, but maybe a little more high level.

So the line uses crt; included the unit called crt; the uses is the mechanism for using other compilation units. interface and implementation were the keywords used to specify, within the unit, what was (and what was not) visible outside the unit. So the programmer was able to define what was visible outside the unit and what not. This is similar to the public and private keywords in other languages such as C++ and Java.

Units in Borland's Pascal were similar to Modula-2's separate compilation system. In 1987, when Turbo Pascal 4.0 was released, Modula-2 was making inroads as an educational language which could replace Pascal. Borland, in fact, had a Turbo Modula-2 compiler, but this product ran only on CP/M and was never ported to MS-DOS (its user interface was almost identical to that of Turbo Pascal 3.x and earlier). Instead of porting their Modula-2 compiler to MS-DOS, Borland elected to implement separate compilation in their established Pascal product.

Separate compilation was not part of the standard Pascal language, but was already available in UCSD Pascal, which was very popular on 8-bit machines. Turbo Pascal syntax for units appears to have been borrowed from UCSD Pascal.[2] Earlier versions of Turbo Pascal, designed for computers with limited resources, had no real need for it, but with the new ability to generate large EXE files, programs of significant complexity could be written that, practically, needed separate compilation.

Object oriented programming

From version 5.5 some object oriented programming features were introduced: classes, inheritance, constructors and destructors. The IDE was already augmented with an object browser interface showing relations between objects and methods and allowing the programmer to navigate the modules easily. Some people call these extensions Object Pascal although that is more commonly used as a name for the language underlying Delphi (which has two totally separate OOP systems).

Windows versions

Two versions named Turbo Pascal for Windows 3.x were released: Turbo Pascal for Windows 1.0 (based on Turbo Pascal 6 but released about 2 years later), and 1.5 (released after Turbo Pascal 7); they were succeeded by Borland Pascal 7, which had Windows support. The Windows compiler in Pascal 7 was entitled Borland Pascal for Windows' but presumably was from the same code base as TPW 1.5.

Both versions built Windows-compatible programs, and featured a Windows-based IDE, as opposed to the DOS-based IDE in Turbo Pascal. The IDE and editor commands conformed to the Microsoft Windows user interface guidelines instead of the classic TP user interface. The support for Windows programs required the ObjectWindows library, similar but not identical to that for the first release of Borland C++, and radically different from the earlier DOS Turbo Vision environment. Turbo Pascal was superseded for the Windows platform by Delphi; the Delphi compiler can produce console programs in addition to GUI applications, so that the use of Turbo and Borland Pascal became unnecessary.

Apple Macintosh

Borland released Turbo Pascal for Macintosh in 1985. Much like versions 1 to 3 for other operating systems, it was written in compact assembly language and had a very powerful IDE, but not a good debugger. Borland did not support this product very well, although they issued a version 1.1, patched to run on the 32-bit Macintosh II. Macintosh support was dropped soon after.

Successors

By 1995 Borland had dropped Turbo Pascal and replaced it with the RAD environment Delphi, based on Object Pascal. 32-bit Delphi versions still support the more portable Pascal enhancements of the earlier products (i.e. those that are not specific to 16-bit code) including the earlier static object model.

Several other products compatible with Turbo Pascal also exist. The best-known are Free Pascal and Virtual Pascal.

In education

Borland Pascal is still taught at some secondary, sixth form and University levels in Malta, at colleges in Germany and the USA, and at secondary schools in Argentina, Belgium, Bulgaria, Croatia, Moldova, Romania, Serbia,France (Faidherbe) and Canada. It was the state-approved educational programming language for all South African secondary schools until 2002. Pascal is no longer taught in South Africa— Delphi and Java are the languages of choice in secondary schools. Today it continues to be taught in some universities around the world as an introduction to computer programming, usually continuing on to C or Java or both.

Some lecturers prefer to use Borland Pascal 7 or Turbo Pascal 5.5 because of its simplicity in comparison to more modern IDEs like Microsoft Visual Studio or Borland JBuilder, so it introduces students unfamiliar with computing to common tasks such as using the keyboard and keyboard shortcuts (TP 5.5 has no mouse support), familiarises them with DOS commands (which are largely the same as those of Microsoft Windows's Command Prompt), and lets them write programs without too much worry about simply getting the environment to work. It is legally available as a free download from Borland.

Issue with CRT unit on fast processors

Several versions of Turbo Pascal, including the latest version 7, include a CRT unit used by many fullscreen text mode applications. This unit contains code in its initialisation section to determine the CPU speed and calibrate delay loops to avoid flicker. This code fails on processors with a speed greater than about 200 MHz and aborts immediately with Runtime error 200. This is caused because a loop runs to count the number of times it can iterate in a fixed time, as measured by the real-time clock. When Turbo Pascal was developed it ran on machines with CPUs running at 1 to 8 MHz, and little thought was given to the possibility of vastly higher speeds, so at 200 MHz the 16-bit counter overflows. Several patches have been required as processor speeds increased.

Programs compiled with this error can be patched by a tool named TPPATCH or equivalent, or by loading a Terminate and Stay Resident program loaded before running the faulty program. In many cases MS-DOS programs known not to have been compiled with Turbo Pascal also fail with Runtime error 200; it's still worth trying this patch. To run the Turbo and Borland Pascal compilers on a fast machine, a version of TURBO.TPL patched with a corrected CRT unit to resolve the error can be used to generate programs compatible with fast machines. See the links at the end of the article. There used also to be TSR program called slow that deliberately just wasted machine cycles, which was useful for simulating slower systems when developing on faster ones. However, modern cache technology and loop prediction can make this almost worthless.

There are also patches to the TP7 compiler itself, thus if the Pascal source is available a new compilation's code will work without the compiled code having to be patched.

There have been cases where the above methods don't work, and running the program in a virtual machine with an older operating system as guest often is successful. Microsoft Virtual PC seems to have a higher success rate than Virtual Box and VMWare regarding this particular problem.

Floating point

There were several floating-point types, including single (the 4-byte [IEEE 754] representation) double (the 8-byte IEEE 754 representation), extended (a 10-byte IEEE 754 representation used mostly internally by numeric coprocessors) and Real (a 6-byte representation).

In the early days, Real was the most popular. Many PCs did not have a floating point coprocessor so all FP had to be done in software. Borland's own FP algorithms on Real were quicker than using the other types, though its library also emulated the other types in software.

Sample code

  • Pascal is not case sensitive.
  • Historically, Pascal comments are indicated { like this }, or (* like this *), and these can span any number of lines. Later versions of Borland Pascal also supported C++-style comments // like this, which finish at the end of the line.
  • The syntax for the statement case is more flexible than standard Pascal.
  • Sets may only have up to 28 (256) members.
  • Standard, fixed-length Pascal strings are supported, but there is also a more flexible String type.

This is the classic Hello world program in Turbo Pascal:

begin
WriteLn('Hello World');
end.

This asks for a person's name and writes it back to the screen a hundred times:

program WriteName;

var     i       :       Integer;        {variable to be used for looping}
        Name    :       String;         {declares the variable Name as a string}

begin
Write('Please give your name: ');
ReadLn(Name);                           {ReadLn returns the string entered by the user}
for i := 1 to 100 do begin
        WriteLn('Hello ', Name);
end;
end.

See also

References

External links


ca:Turbo Pascal cs:Turbo Pascal da:Turbo Pascal de:Turbo Pascal es:Turbo Pascal eo:Turbo Pascal fr:Turbo Pascal ko:터보 파스칼 id:Turbo Pascal it:Turbo Pascal he:טורבו פסקל nl:Turbo Pascal ja:Turbo Pascal no:Turbo Pascal pl:Turbo Pascal pt:Turbo Pascal ro:Borland Pascal ru:Turbo Pascal fi:Turbo Pascal sv:Turbo Pascal ta:டேர்போ பாசுகால் tr:Turbo Pascal vi:Turbo Pascal zh:Turbo Pascal

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...