CS441 Project 2

Compare and Contrast Language Groups

 

Group Members:

VALLURI Vamsidhar, WONG Mei Fun , YEE Meng Yi and ZHANG Jingyuan

 

Click below to see detailed comparisons

1. Simple Procedural and Block Structured, Procedural
2. Simple Procedural and Object-Based
3. Simple Procedural and Functional
4. Simple Procedural and Logic

 

 

Simple Procedural and Block Structured, Procedural

FORTRAN and Pascal

Reference:
FORTRAN compiled by Charles Foushee, Aaron Goedken, Tom Heffron and Michael Hoyt
Pascal compiled by Niraj Kapur, Nick Knipp, Jennifer Lascala and Matthew McDaniel

History

Pascal is a language named after a French scientist, Blaise Pascal. But, FORTRAN is not. FORTRAN came from the title of "The IBM Mathematical FORmula TRANslating System." Pascal was first introduced in 1971 while FORTRAN was introduced in 1954. Pascal became a programming language used to produce software and used to teach basic of programming. FORTRAN used only for the IBM machines, developers had no intention to implement it on other computers.

 

Overview

FORTRAN is a simple procedure programming language. Also, FORTRAN is the first high-level programming language. In each newer version of FORTRAN, it contains new features such as built-in function and conditional statements.

Pascal I s one of the first languages that allowed for hierarchical programming structure. Pascal programs are made up of smaller subprogram which themselves are structured programs. Those subprograms can be combine into a big program.

 

Handling of Data Objects

Both Pascal and FORTRAN support integer, boolean, string, character, real, array, record, and pointer data type objects. Pascal uses both static and dynamic variables allocation while FORTRAN only uses static variables allocation.

 

Handling of Sequence Control

Both Pascal and FORTAN have mathematical operators such as addition (+), subtraction (-), multiplication (*), and division (/). Precedence of these mathematical operations are the same for both Pascal and FORTRAN. In addition, both of them also have parenthesis to change the precedence of the operator. Whatever in the parenthesis should be process first.

FORTRAN did not use mathematical symbol representation for Relational Operators until FORTRAN 90. Basically, both Pascal and FORTRAN 90 have the same kind of symbols to represent the relation between variables except "Not Equal" operator. Pascal uses "<>" but FORTRAN 90 uses "/=".

Furthermore, both Pascal and FORTRAN support Conditional Operations such as IF-THEN-ELSE statement, WHILE statement, and GOTO statement.

 

Handling of Subprogram and Storage Management

Pascal contains both procedures and functions as subprogram of the language. FORTRAN only have functions or subroutines as subprogram. Both functions in Pascal and FORTRAN will pass values back to the main program. But, procedures in Pascal does not pass any value back to the main program. Variables of Pascal are passed by either pass-by-value or pass-by-reference parameters when the main program calls the subprograms. Only call-by-reference in earlier FORTRAN and the newer method is called pass-by-value-result which is use in FORTRAN 90.

Pascal contain static variables that are defined in the declaration section, while dynamic variables are created by NEW (pointer_variable) so that Pascal will create a memory allocation for the variables during run-time. Memory allocation can be reclaim back to the operating system by DISPOSE (pointer_variable).

For FORTRAN, it only support static allocation variables because there could only be one instance of a subprogram record at any time.

 

Handling of Abstraction and Encapsulation

Pascal allows for abstraction through the use of functions. Unfortunately, this is one of few examples of Pascal in abstraction and encapsulation. FORTRAN uses COMMON blocks to encapsulate data that could be passed within functions. The same variable could belong to several COMMON blocks.

 

Simple Procedural and Object-Based

FORTRAN and Java

Reference:
FORTRAN compiled by Charles Foushee, Aaron Goedken, Tom Heffron and Michael Hoyt
Java compiled by John Mohr, Madhukiran Moturu, Prashanth Narayanan and Carrie Neer

History

Programming languages are part of the computer tool set used to solve problems. Most computer programming languages have a mathematical foundation. The advances in computing and the requirements of scientific applications necessitated the development of simple procedural languages such as FORTRAN followed by other procedural languages like ALGOL, BASIC etc. FORTRAN came into existence in 1950s ,designed for IBM 704, it was used mostly for scientific computations. ALGOL was developed in an attempt to create a universal language with a mathematical syntax. In 1950s COBOL was developed specifically for Business applications.

Simple procedure languages are followed by Object oriented languages . The first Object Oriented Programming Language was Simula 67, later a language called Smalltalk was developed . Delphi, Java, Eiffel, C++ are some of the languagues which belong to object oriented family. Delphi was developed in 1994, Eiffel was developed in 1985 and Java was introduced in 1995. Object Oriented

Programming deals with reusing code for data types. Inheritance, polymorphism and encapsulation of data also are important issues in OOP.

 

Overview of Language

Simple procedural languages are used in Engineering scientific computations and business fields. FORTRAN stands for Formula Transalator , which is used in engineering. ALGOL is used in scientific applications like Aerospace industry. BASIC for everyday applications. The simple procedural language format has main program , subroutines, functions and modules which is not as complex as object oriented languauge format.

Object oriented languages are used to model real world problems. JAVASCRIPT used for web page development . Java has become the language, and the platform, and the architecture for computing on the network. Its popularity is because of its platform independence. DELPHIs area of application includes database and web. Eiffel has the ability to produce components that may be used in many different applications . Object-based languages have three main characteristics: data abstraction, inheritance, and dynamic type binding. The reason for these is to allow for the reuse of code.

 

Handling of Data Objects

The simple procedural languages use the following data types - floating point, integer, double precision, characters, real constants, complex types, logical types and arrays. Most of the standard data types are present in the object-based languages.

In the Object-Based language group, the concept of classes is used. Classes give rise to abstraction of data. Java provides a large number of classes which include date, form, string etc. which makes programming much easier. Classes allows for Inheritance (and mutiple inheritance) is also used extensively in object-based languages. It allows a new abstract data type to inherit all the data and functionality of some already existing type. This facilitates reuse in programs. Classes help in modeling the real world situations/environment.

 

Handling of Sequence Control

In both the language groups, precedence is given left to right, arithmetic and logical operators have an order of precedence.

Sequence control in Simple Procedural:

Statements are executed in a top-down fashion. In order for a statement to be executed, the statements before it must have been executed. When a procedure is called, execution in the calling procedure halts until the called procedure completes the task and returns its value.

In addition to procedure calls, standard decision statements are included. They are the If, Case and Goto statements. Also standard are iterative methods which include While, For and Do statements.

In the Arithmetic operations * and / have the highest precedence then + and - follow. When two values of the same precedence exist, the order is from right to left. In addition, () can be added around an operation. This allows the operation inside the () to be carried out before the information inside is used in other operations.

 

Sequence control in Object-based group:

Object oriented languages also have the same decision statements as Simple Procedural ( i.e. If, case, Goto) and iterative methods like While, For, do. But the difference stems because of certain properties of classes and objects. Which can be seen is the handling of data. Simple Procedural stores all data inside global or local variables which are manipulated at will. On the other hand, in Object oriented languages Data is stored inside the object only changed through the interface methods provided by the object. This takes direct manipulation of the data away from the main program and gives that responsibility to the object. In addition Object Oriented languages such as C++ allow overloading of operators. But, Object-Oriented Languages may or may not be sequential in nature. Even in a language like Ada there are two different types of control. The first is sequential moving from one procedure to the next. The other is concurrent control which allows for concurrent/parallel processing of functions.

 

Handling of Subprograms and Storage Management

Simple Procedural

The simple procedural language group supports both functions and procedures. FORTRAN has a wider range of subprograms: functions, which allow a return value, subroutines for larger processes, statement functions, which is a function whose value may be computed by a single arithmetic or logical expression, and modules for providing means of packaging global data. BASIC uses subprograms, referenced with GOSUB statements which are executed conditionally.

Simple procedural languages often use stacks with nonrecursive function calls for storage. Unreferenced storage areas in these programs can often lead to serious problems. As for storage management, the user is not required to implement any storage management techniques themselves. It is possible to manipulate storage at a low level with the right functions.

 

Object-Based

The object based family supports functions and procedures like the simple procedural languages, but is much advanced. These subprograms can be defined in different ways such as public, private and protected. They can also be overloaded. These means several functions can be declared alike but work on different data types depending on the arguments passed to the functions. The classes in the object-based family contains in it functions, procedures and methods that can be used to define ADT's.

The programmer can have greater flexibility in storage management when it comes to the object-oriented group. Garbage collection routines and individual storage can be defined by the programmer for more precise control over how the data gets stored and deleted. Java- Object Store, and the Persistent Storage Engine product, PSE, both provide high performance object storage for Java programs.

 

Handling of Abstraction and Encapsulation

Simple procedural languages allows for some kind of encapsulation but not as advanced as object oriented group. In FORTRAN all references to non-local variables were through COMMON Blocks which are encapsulation of data that could be passed from one function to another. They usually follow subroutines. A procedure is a type of encapsulation because it combines a series of computer instructions. Likewise, a complex data type, such as a record or class, relies on encapsulation. Object-oriented programming languages rely heavily on encapsulation to create high-level objects. Abstraction is not such a problem for simple procedural languages, since subprograms have the same data type as the main programs.

Object Oriented Languages support a high level of abstraction. Ada, for example, supports four forms of abstraction: the package, overloading a built-in type or operation, generic definitions, and using a subprogram to intercept and handle

requests for a particular resource, function, or piece of information. A class can be defined as an abstraction for a collection of data and operations. Encapsulation allows the data to remain absolutely within the object. Inheritance allows the user to begin the declaration of the subclasses. Object based group also offers the ability to make data public or private in nature meaning that only the ADT can access its fields unlike simple procedural group.

 

 

Simple Procedural and Functional

FORTRAN and Scheme

Reference:
FORTRAN compiled by Charles Foushee, Aaron Goedken, Tom Heffron and Michael Hoyt
Scheme compiled by Vamsidhar Valluri, Meng Yi Yee, Jingyuan Zhang and Wong, Mei Fun

History

FORTRAN and Scheme has both evolved from a newly developed language to a complete and powerful language. FORTRAN was first developed under environments where small, slow and relatively unreliable computers are used. These computers are used specifically for scientific computations and there is no existing efficient way of programming a computer. Now, FORTRAN is given credit as being the first compiled high level language.

The sequence of development for FORTRAN is outlined as below:

FORTRAN 0
FOTRAN 1 (1956)
FORTRAN II (1956)
FORTRAN IV (1958)
FORTRAN 77 (1978)
FORTRAN 90 (1992)

Scheme has evolved from a small language from which was used for teaching, support only a handful of syntactic forms and procedures. Now, Scheme is a general purpose programming language

 

Overview

Both FORTRAN and Scheme are high level language supporting operation on structured data such as strings, numbers and characters.

FORTRAN 90 contains new features such as built in functions, case statements and loop exit statements and a module family that allows data and subprogram declaration to be either private or public.

In the next version, FORTRAN 90 plans to get rid of it depreciated elements in the next version, e.g. IF and GO TO statements.

As for Scheme, Scheme programs are highly portable across implementations of the same Scheme system on different machines. Machine dependencies are almost completely hidden from the programmer.

 

Handling of Data Objects

FORTRAN and Scheme both support dynamic allocation and deallocation for data objects handling. FORTRAN uses dynamic arrays through the use of the ALLOCTABLE label and the ALLOCATE statement and DEALLOCATE for memory recovery. Objects in Scheme are dynamically allocated in heap where they are retained until no longer needed then automatically deallocated. On the other hand, FORTRAN also supports statistically bound arrays and subscripts. These arrays are initialized using the DATA statement.

 

Handling of Sequence Control

FORTRAN and Scheme both has their own unique way of synchronizing the sequence control in their programs. FORTRANS and Scheme both supports conditionals statements such as the IF statement and supports recursion and iteration in their own syntax. The only difference that I found is that FORTRAN does not support logical loops. FORTRAN 77 and FORTRAN 90 do not provide posttest or pretest logical loops as part of their language. These statements are constructed using DO loops, IF statements and GO TO exits. Scheme need only the IF statement to for logical loops. This IF statements posses as a pretest for the logical loops.

 

Subprograms and Storage Management

Subprograms in FORTRAN are created using FUNCTION and SUBROUTINE. These subprograms are usually given a name. As for Scheme, subprograms are created using the lambda syntactic form. The subprograms are in block structured and does not necessary to have a name. Identifiers in for subprograms in both languages can be bounded either locally or globally.

FORTRAN allows static or stack-dynamic allocation. Scheme supports dynamic allocation. For both languages, storage is reclaimed periodically. Scheme uses weak pairs and guardians to help with storage management while FORTRAN uses ALLOCATE statement and DEALLOCATE for memory recovery.

 

Abstraction and Encapsulation

In FORTRAN, all references to non-local variables were made possible through the COMMON blocks. These blocks that encapsulates and abstracts the data could be passed from one function to another as needed. In addition, FORTRAN allows user to derive types that are to be used.

Scheme uses syntactic extension that facilitates the definition of simple abstract of objects. Scheme has built-in procedures to process data. Unlike FORTRAN, Scheme does not support user-derived types.

 

 

Simple Procedural and Logic

FORTRAN and Prolog

Reference:
FORTRAN compiled by Charles Foushee, Aaron Goedken, Tom Heffron and Michael Hoyt
Prolog compiled by Linda Shipp, Jie Song, Rong Hai Shi and Jamie Stephens

History

Simple Procedural language was designed for scientific applications. Therefore they have foundations in scientific and mathematics. Some example of Simple Procedural languages includes FORTRAN, ALGOL, and PL/I. John Backus and his design group at IBM designed FORTRAN in 1954. It was intended to be able to eliminate coding error and debugging process. It was originally intended to be used on IMB machines only. FORTRAN is given the credit as being the first compiled high-level language. The first version of ALGOL, ALGOL 58 was developed in an international attempt to create a universal programming language. The goals of the design of ALGOL were to have a mathematical syntax, be self-documenting, set a standard for publications, and a language that was translatable into machine code. With its international support and formal definition, ALGOL 60 became the standard for publication, and initiated new approaches to language and compiler design. Logic programming language, on the other hand, is designed to be used for the development of artificial intelligent machines and natural language understanding. Its implementation as roots in research on theorem proving. Prolog for example is one of the programming languages in the logic family. It was first developed in the early 1970s by Alain Colmerauer and Phillippe Roussel in the Artificial Intelligence Group at the University of Aix-Marseille. In 1981, the Japanese government launched a large research project to use Prolog as the basis for the effort of developing intelligent machines. The contribution of Prologs participation to logic programming is that it aroused interest in artificial intelligence and logic programming.

 

Overview of Languages

Simple procedural languages are used in areas of science and engineering. FORTRAN for example was originally designed for this purpose. It was designed to be used on the IBM 704 machine. The announcement of the IBM 704 system, with both indexing and floating-point instructions in hardware, proclaimed the end of the interpretive era for scientific computation. The creators of the original FORTRAN stated that FORTRAN would provide the efficiency of hand-code programs and the ease of programming of the interpretive pseudocode systems. Languages used for logic programming are called declarative languages because programs written in them consist of declarations rather than assignments and control flow statements. One of the essential characteristics of logic programming languages is their semantics, which is called declarative semantics. The basic concept of this semantics is that there is a simple way to determine the meaning of the each statement, and it does not depend on how the statement might be used to solve a problem. Declarative semantics is considerably simpler than the semantics of the imperative languages. Compared to other non-imperative languages such as simple procedural programming language, logic-based programming languages is not very efficient. Also the use of predicate calculus to express specifications for problem solving is one of the greatest contribution of logic programming language to computer science and to artificial intelligence. Benefits of using predicate calculus include clean and elegant syntax and well-defined semantics. Unlike simple procedural programs, the characteristics of the solutions of logic programs are given but the complete process of getting the solutions is not. Instead of scientific applications as in simple procedural language, applications of logic programming deal with relational database management, expert systems, and natural language processing.

 

Handling of Data Objects

Because of its use in scientific applications, simple procedural languages allow you to use data objects such as integers, real, complex (for mathematical numbers), Boolean, character, string (run-time adjustable or compile-time fixed length strings), void, assignment, arrays, pointers and references, and logical types. Because of its application area, simple procedural programming languages usually comes with a library of already created functions. The approach of logic programming on the other hand is to use as a database a collection of facts and rules that state relationships between facts, and to used an automatic inferencing process to check the validity of new propositions. Because of its area of applications and that it has its basis in predicate calculus, logic programming languages data objects contains a database of predicates, rule statements and facts. Therefore, it uses a lot of logic data types. Prolog is the most widely used logic programming languages. Compared to the simple procedural programming languages and modern languages, Prolog has a limited data structures. In Prolog, only a structured term plays the role of a data structure. There are four basic types of terms in Prolog, which are variables, compound terms, atoms, and numbers. In general, the data structures of other logic languages are similar to Prolog.

 

Handling of Sequence Control

In simple procedural language, rules of general algebra apply to arithmetic expressions. That is, the expressions in parenthesis are evaluated first, followed by the exponential expression, then by the multiplication/division, finally by addition/subtraction. There are not many fancy tools for sequence control in simple procedural languages. Both FORTRAN and ALGOL include gotos, if-then-else statements, mathematics operators, and iterations such as do-loops, while-loops, and for-loops. In logic programming language, non-arithmetic expression form, arithmetic expressions, pattern matching and back tracking is used to handle sequence control. The major feature of Prolog is to use pattern matching to discover if a query is solved by a fact in the database or if the fact can be deduced using the rules in the database applied to other facts or rules.

 

Handling of Subprograms and Storage Management

Simple procedural language group supports both functions and procedures. Because of their scientific application, many functions are already provided for in simple procedural languages. These include mathematical functions, trig functions, character operations, and operations for complex numbers. Programmers are also allowed to define their own functions. Parameters can be passed through by pass-by-reference or pass-by-value. Some languages in the family may or may not allow recursion. Early versions of FORTRAN for example do not allow recursion while ALGOL does. Both static and dynamic allocations of memory are allowed although it seems that most languages of this family use dynamic allocation. Like simple procedural languages, logic-programming languages also allow dynamic allocation of memory. Garbage collection is used in this language family to manage storage and keep the system from running out of memory location. Unlike simple procedural languages, logic programming language does not provide many ready to use subprograms.

 

Handling of Abstraction and Encapsulation

Simple procedural languages provide module to allow blocks of parameters, variables, and subprograms to be both shared and re-used. Modules also allow for the passing of arrays whose size is not specified in the program that is referencing them. ALGOL however, dose not provide for good encapsulations constructs. Instead, programs can be organized by nesting subprogram definitions using static scoping. Logic programming language provides modules. They provide the capability for modules that allow a program to consist of one or more modules. Each module has an interface section that contains the declaration for the types, functions and predicates exported from the module. Prolog for example uses modules to implement encapsulation and abstraction. Some logic programming languages may provide for strong typing while others may not. Prolog modules for example do not provide for strong data typing while Mercury, another logic language does.

 

Additional References:

http://www.bit.umkc.edu/vu/course/cs441/Lessons/

http://www.eiffel.com/doc/manuals/technology/oo_comparison/index.html

http://bit.umkc.edu/vu/course/cs441/Lessons/

Sebesta, Robert W. Concepts of Programming Languages. Berkeley: Addision-Wesley Longman, Inc., 1999.