Docsity

Turbo Pascal - Programming Languages - Lab | CSC 415, Lab Reports of Programming Languages

Partial preview of the text

Download Turbo Pascal - Programming Languages - Lab | CSC 415 and more Lab Reports Programming Languages in PDF only on Docsity!

Turbo Pascal

By: Traci Glass

CSC 415 Programming Languages

November 5

th

History of Turbo Pascal

In August of 1965, Niklaus Wirth and C.A.R “Tony” Hoare presented a modest proposal for modifications and additions to ALGOL 60. This proposal was rejected and instead a more complex version, ALGOL 68, arose. Wirth and Hoare disagreed with the panel’s decision, so they changed the name from ALGOL 60 to ALGOL-W. ALGOL-W, which was designed as a teaching tool, was much less than successful. Their next effort was Pascal which was more successful. In 1971, the first published definition of Pascal appeared. Features in Pascal were derived from many languages, such as ALGOL 60, ALGOL 68, ALGOL-W, COBOL, and PL/I. Since Pascal was widely used as a teaching tool, it lacked some of the features that are essential for many kinds of applications. Due to this, many non standard dialects began to appear. Turbo Pascal is one such dialect of Pascal (Sebesta 77-78). Turbo Pascal was developed by Borland Software Corporation under Philippe Kahn’s leadership. Kahn saw a significant opportunity in the programming marketplace, which lead to the development of Turbo Pascal. At the time programmers were stuck writing source code in a text editor, then a compiler created object code from the source, and then a linker combined the object code with runtime libraries to produce an executable program. This process was extremely cumbersome, so Kahn had the idea to integrate all of these separate functions into one package. He decided to sell this new package inexpensively through mail-order instead of to retailers. Turbo Pascal was the first popular Integrated Development Environment or IDE. This feature was very exciting and extremely advanced for its time. This dialect of Pascal was the original widely known inexpensive version, while the more expensive version was sold as Borland Pascal. An additional selling point to Turbo Pascal was that it came with a “Book License” and no copy protection at all. The term “Book License” meant that you should treat the software like

of a variable at runtime based on the calling order of subprograms (Sebesta 232). Turbo Pascal is statically scoped using the method of binding names to non local variables. Data Types When Turbo Pascal was introduced, with it came new data types as seen in the figure to the right. Those included the Longint and String types. The Longint type allows the length to be twice as long as an integer with a 32 bit value. The string type allows no more than 255 characters. As with Pascal, integers are allowed up to a 16 bit value, real types are floating point values, and the char type is a single character (Data Types). Turbo Pascal also has Programmer Defined Data Types which include records and enumerated types. Turbo Pascal is not strongly typed so errors are not always detected. Turbo Pascal does not require explicit variable type declarations because it can automatically convert the value of any variable to the necessary type on demand. Turbo Pascal provides for the use of pointers. Pointers in Turbo Pascal can be used before they are declared. Below is a snippet of code illustrating how that would be done. The carat symbol is used to dereference pointer variables (Pascal Wikipedia). type a = ^b; b = record a: Integer; b: Char; c: a end; var mypointer: a; Pascal Turbo Pascal Integer Integer Real Real Boolean Boolean Char Char Longint String

Turbo Pascal has the ability to read and write to an external file. In the variable declaration section, the programmer would declare the input and the output file both of type text. In the constant, const, declaration section, the programmer could declare the file path name as a variable. Arrays in Turbo Pascal are structured much like the ones that we would see in Ada today. Inside of the type declaration block, the array is assigned a type name. Then the size of the array is usually declared, but is not required. Lastly in the declaration, the type of the array is declared. Expressions and Assignment Statements Variable declaration in Turbo Pascal is structured like this, Var1:type1; Var2, var3:type2;. Each line in Turbo Pascal ends with a semi-colon. An example of the structure of assignment statements is as follows: X:=23;. The math operators in Turbo Pascal are +,-,*,/,div, and mod. Mathematic functions in Turbo Pascal are SQR (square) SQRT(square root), SIN, COS, ARCTAN. The arithmetic expressions include real and integer (Tutorial). Statement-Level Control Structures Turbo Pascal is a structured language meaning that it enforces a logical structure on the program being written to make it more efficient and easier to understand and modify (Structured Programming). The selection statements in Turbo Pascal include if statements and case statements. Unlike other languages, the if statements do not have an end if. The if statements are structured as shown below.

state of an instance of an abstract data type. An iterator is an operation that allows the programmer to process all of the components sequentially. Input transformations take input values and convert them into an instance of an abstract data type. Output transformations take an instance of an abstract data type and convert it to a representation that can be output (Laboratory). In Turbo Pascal, a unit is a form of encapsulation which has a structure similar to the package in Ada. A unit is a construct that allows a programmer to name a collection of related data and subprograms, compile the collection separately, and give the user access to the collection while keeping the implementation details hidden. The composition of a unit begins with a heading, then an interface section followed by an implementation section and lastly an initialization section (Laboratory). Support for Object-Oriented Programming Turbo Pascal is a procedural language with no support for object-oriented programming. In version 5.5, it was advertised as having object orientation with inheritance, but it does not have polymorphism which is one of the requirements to consider it as having support for object oriented programming. However, it has always supported encapsulation. Concurrency Turbo Pascal does not support concurrency because it was designed to run in DOS. Since there were no facilities in the operating system for concurrency, there were none available to any programs running under DOS. Exception Handling and Event Handling

In Turbo Pascal there are very few outlets for exception handling. The outlets that are included in Turbo Pascal are mainly input and output error messages. There were compile and runtime error handlers in later versions as well (Antique Software). As for event handling, it can done with the if..then statement or the if..then..else statement. Other Aspects of Turbo Pascal In Turbo Pascal, comments are done like this {comment} or like this (* comment*). Note that with both styles the comments are allowed to carry over onto multiple lines (Tutorial). This style of comments is considered to be block style. An example of a program written in Turbo Pascal would be similar to the one below. begin writeln(‘Hello World’); end. Turbo Pascal was a revolutionary programming language. It allowed graphical games to be created in DOS.

Evaluation of Turbo Pascal

Readability Turbo Pascal is a simple language to read and to understand. It is much like Ada in that aspect. The syntax has the feel of plain English. Also, as referenced earlier the language is case insensitive which makes it much easier for the programmer to read. Case insensitivity also makes it easier to comprehend. It also makes it easier on the programmer by not having to focus too much on using the variable incorrectly. Writability

Turbo Pascal was revolutionary in many ways as expressed earlier. One of the other ways that it was revolutionary was in price. Turbo Pascal was extremely affordable at $49.99. Also, Turbo Pascal had an exceptional compile time, hence the name “Turbo” (Turbo Pascal). In another aspect of cost, time, with Turbo Pascal being based almost entirely off of Pascal there was not much training involved for the programmer.

Bibliography and References

A Tutorial in Turbo Pascal. . Antique Software: Turbo Pascal v 3.

Borland. Turbo Pascal. Borland, 1989. Borland®/Inprise® Pascal Versions. 29 September 2009 . Calvert, J. B. Pascal Notes. 28 August 2004. 29 September 2009 . Dale, Nell. A Laboratory Course for Turbo Pascal. Jones and Bartlett Publishers, 1997. Data Types in Turbo Pascal. 23 January 2002. 29 Septemeber 2009 . Learn Pascal Page. 1 November 2009. . Pascal for Beginners. 2005. 29 September 2009 . Pascal Tutorial. 16 March 1997. 29 September 2009 . Pascal- Wikipedia. 29 October 2009. 1 November 2009. . Savitch, Walter J. An Introduction to the Art and Science of Programming: Turbo Pascal Editon. The Benjamin/Cummins Publishing Company Inc, 1986. Sebesta, Robert A. Concepts of Programming Languages. Boston: Pearson Education, 2009. Structured Programming. 31 August 2005. 27 October 2009.

Turbo Pascal. 31 May 2001. 26 October 2009.

Turbo Pascal Programmers Page. 16 June 2004. 29 September 2009 .