Project 3

Group Members:

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

 

Compare and Contrast

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

 

Block Structure, Procedural and Object-Based

Pascal and Java

Reference:
Pascal compiled by Niraj Kapur, Nick Knipp, Jennifer Lascala and Matthew McDaniel
Java compiled by John Mohr, Madhukiran Moturu, Prashanth Narayanan and Carrie Neer

 

History

Pascal is a language named after Blaise Pascal a French scientist. It was first introduced in 1971. Later, I became a programming language used to do procedure software and used to teach basic of programming.

The development of Java was started on December 1990 containing 3 members in a group. Years after years, the group became bigger which have 14 members in 1992. Java was introduced on May 23, 1995. Originally, Java was called Oak. The name of Oak was changed by Sun Microsystem because of marketing purpose.

 

Overview of the Language

Pascal is one of the first programming languages that allowed 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.

Java is a software that can run on all different kinds of computers and electronic devices. Java allows computers and electronic devices to communicate with each other easily. Java has become the language, and the platform, and the architecture for computing on the network. Java is profitable for corporation by cutting the costs associated with developing software for multiple platforms. Also, Java is secure for use over the Internet. Java is accepted as a powerful fourth generation programming language.

 

Handling of Data Objects

Pascal support integer, boolean, string, character, real, array, record, and poiter variables. Pascal uses both static and dynamic variables allocation.

Java support comments, primitive types and reference types variable. Primitive types contain boolean, character, byte, short, integer, long integer, float and double. Reference types refer to objects and arrays. The referencing and dereferencing of objects and arrays is handled automatically by Java.

 

Handling of Sequence Control

Both Pascal and Java support mathematical operators such as addition, subtraction, multiplication and division. Both Pascal and Java uses mathematical symbols for Relational Operation to represent the relation between two variables expect "Not Equal" operator. Pascal uses "<>" and Java uses "!=". Pascal has Conditional Operation such as IF-THEN-ELSE statement, WHILE statement, GOTO statement, FOR statement, and REPEAT-UNTIL statement. While, Java has IF statement, WHILE statement, and SWITH statement.

 

Handling of Subprograms and Storage Management

Pascal contains both procedures and functions as subprogram of the language. Functions in Pascal will pass values back to the main program but procedures do not pass any value back to the main program. Variables of Pascal are passed by either pass-by-value or pass-by-reference paramemters when the main program calls the subprograms. Pascal contains static variables that are defined in the declaration section, while dynamic variables are created by NEW (pointer_variable) so that Pascall 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).

Java contain applets, servlets, and applications. Java application is a standalone program that runs directly on the Java platform. Some of the common types of programs being the applets and the applications. Object Store and Persistent Storage Engine (PSE) are used for storage management for Java. Both provide high performance object storage for Java programs and also provide atomic transactions in case of an absence of application or a system failure. Object Store applications make a backup copy of all the existing database before opening or appending and updaate session. PSE Pro has the capability to protects the database against corruption in the application or due to system failure.

 

Handling of Abstraction and Encapulation

Functions in Pascal allow abstraction. Every line of code in Java must be embeded in an object. Java also allows the user to use a variety of instructions and field modifiers to control access to the class members. A class can be defined as an abstractions for a collection of data and operations. Encapsulation allows the data to remain absolutely within the object. The property of inheritance allows the user to begin the declaration of the subclasses.

^ Back to Top

 

 

Block Structured, Procedural and Functional

Pascal and Scheme

Reference:
Pascal compiled by Niraj Kapur, Nick Knipp, Jennifer Lascala and Matthew McDaniel
Scheme compiled by Vamsidhar Valluri, Meng Yi Yee, Jingyuan Zhang and Wong, Mei Fun

 

History

Pascal was developed from the ideas in Algol 60 by Nicklaus Wirth and from the ideas in the paper by C.A.R. Hoare titled "Notes on Data Structuring". In January of 1971, Wirth produced the first official definition of Pascal by Wirth. Pascal became a programming language used to produce computer software and also as the language to teach basic programming with. Pascal is one of the first widely used high level programming languages.

Scheme was introduced in 1975 by Gerald J. Sussman and Guy L. Steele Jr. as the first dialect of Lisp. At first it was used for research and teaching, supports only a handful of predefined syntactic forms and procedures. Now, Scheme is a general purpose programming language

 

Overview of the Language

Both Scheme and Pascal are high level language that supports operation on structured data types.

Pascal allows hierarchical programming structure. Prominent feature of Pascal is structured programming where as Scheme is a functional programming language. Most Pascal programs are made up of smaller subprograms, which are structured programs themselves. Other feature of Pascal is that it requires explicit data declaration.

On the other hand, Scheme supports lexical scoping. Lexical scoping allows a compiler to determine before program evaluation the scope of all bindings and the binding which each identifier reference resolves. Other feature of Scheme is tail recursion used in express looping.

Another feature that Pascal and Scheme has in common is that they support control structures.

Pascal has built-in control structures that that allows the program to be built block structured. As for Scheme, it supports arbitrary control structures with continuation.

 

Handling of Data Objects

In handling data objects, Pascal utilizes record type to store different component types in the same unit. Records are organized in such a manner that data can be stored in a hierarchical format to minimize storage space.

Scheme utilizes the lexical scoping and first class handling in handling data objects. Objects in Scheme are first-class data values because they are heap allocated and retained indefinitely, they may be passed freely to procedures, returned as values from procedures and combined to form new objects.

The data objects in Pascal are Integers, Character, Boolean, Real, Enumerated data type, Array, String, Record, Set, Pointers, Word, Single, Extended, Double, Byte, LongInt, ShortInt and Packed.

The data objects in Scheme are List, Pair, Number, Character, String, Vector and Symbols.

 

Handling of Sequence Control

Pascal and Scheme has implicit simple sequence control structure. Pascal and Scheme uses the construct of begin for simple sequencing.

For example, in Pascal

begin { test}
….
end {test };

In Scheme,

{ begin expresion1, expression2, …}

The difference in Pascal and Scheme in sequence control is that for every procedure in Pascal, a name is assigned to each of them. Procedures in Scheme may or may not contain a name. Any list that has no other interpretation as a macro call or special form is taken to be a procedure application in Scheme.

In addition, Scheme does not has an explicit while_do loop like Pascal. The while_loop in Scheme can be improvised in Scheme using other existing statements such as the ( do ( var val update)… ) (test res… ) expression ) statement.

 

Handling of Subprograms and Storage Management

Handling of Subprograms

Pascal breaks down its language into procedures and functions as subprograms. Procedures and functions work independently in any program they are called.

Scheme breaks down its language into subprograms. The lambda syntactic form is used to create subprograms. The subprograms are treated as first-class objects like strings or numbers and variables are bound to subprograms the way they are bound to other objects.

The value in Pascal are passed can be either pass-by-value or pass-by-reference. Value in Scheme are bound at top level or locally because Scheme programs are block-structured.

Another difference between the subprograms between Pascal and Scheme is that subprograms in Scheme does not necessary to have a name.

Storage Management

The difference in Pascal and Scheme storage management is that storage in Pascal has to be explicitly allocated before the program is executed and Scheme does not. The computer allocates the amount of space needed on the system stack before the program is executed. Static variables are defined in the declaration section of the program and dynamic variables is derived at run time. In Scheme, variables are dynamically allocated in a heap where they are kept until no longer needed then automatically deallocated.

To reclaim storage, Pascal uses the keyword "DISPOSE(pointer_variable)". This statement frees up memory previously used by pointer_variable. Scheme employs garbage collection which automatically reclaims storage space. In fact, Scheme uses the procedure collect is used for garbage collection.

In addition, the keywords "MARK" and "RELEASE" help with storage management in Pascal. The term "MARK(high_water_mark)" allocates a block of memory using predefined integer value of high_water_mark. When the term "RELEASE(high_water_mark)" is used to reclaim memory. Scheme does not use the keywords "MARK" and "RELEASE" but it employs weak pairs and guardians to help in storage management. Weak pairs allow programs to maintain weak pointers to objects. A weak pointer to an object does not prevent the object from being reclaimed by the storage management system.Guardians allow programs to protect objects from deallocation by the garbage collector and determines when the objects would otherwise have been deallocated.

 

Handling of abstraction and encapsulation

Pascal and Scheme both allow abstraction through functions. The potential complexity of Pascal and Scheme, as functions are passed and returned frequently, dictates that much of the operation is kept hidden. With this feature, the programs can be very complex. Furthermore, both Pascal and Scheme allows abstraction and encapsulation through usage of advanced data type such as classes and the usage of recursions in their programs.

^ Back to Top

 

 

Block Structured, Procedural and Logic

Pascal and Prolog

Reference:
Pascal compiled by Niraj Kapur, Nick Knipp, Jennifer Lascala and Matthew McDaniel
Prolog compiled by Linda Shipp, Jie Song, Rong Hai Shi and Jamie Stephens

 

History

Pascal which belongs to block structured, procedural language family was designed in 1971 by Prof. Nicklaus wirth of Federal Institute of Technology, at Zurich, Switzerland. Later Modulo 2 was developed, which is based on Pascal. Modulo-2 was aimed at providing a suitable tool for large-scale projects, systems programming and creating a type-safe language. The block-structured procedural languages have been used more in the area of education.

Prolog which belongs to Logic based family was developed by Alain Colmerauer, Phillippe Roussel and Robert Kowalski during the very early 1970s. These languages are used in artificial intelligence. Prolog supplies to computer, relevant information and inferencing process for computing desirable results.

 

Overview of the Language

Block structured, procedural languages are mainly used for teaching i.e. in education. Logic based family is used in Intelligent machines and Relational database management systems. A logic-based program defines a series of axioms or facts, rules of inference, and a theorem or query to be resolved. Based on a subset of predicate calculus, these programming languages often include statements written in the form of Horn clauses. Block structured procedure languages are procedural. The programmer instructs the computer on exactly how the computation is to be done to get the desired results. Where as, the logic programming languages are non-procedural. Programs in logic based languages do not state exactly how a result is to be computed but rather describe the form of the result. Block structured, procedural are easy to program but logic family are complex.

 

Handling of Data Objects

In logic programming, a structured term f(t1,...,tn) (n>0) plays the role of a data structure. There are four basic data variables in logical programming- compound terms, atoms, numbers and lists. Term is expressed as name(arguments...). If the number of arguments is zero, then it is atom. Atoms are like identifiers and may contain symbols or numeric constants. A special type of atom is number. List is a widely used data structure found in a logical language. It is still a term, e.g., [1,2,3] is equivalent to '.'(1,'.'(2,'.'(3,nil))). Lists have the characteristic of dynamic linked-lists. It can be deleted, inserted, cross-reference and combined.

On the other hand, blocked procedural languages have integer, real/floating point, and double-precision floating point numbers, character values, string, array and record.

 

Handling of Sequence Control

In block structured procedure language groups, precedence is given left to right, and arithmetic and logical operators have an order of precedence. Operations inside parentheses are done first followed by exponential, multiplication/division, and addition/subtraction.

Statement level Sequence control of block structured, procedural language group has branching statements like IF, CASE, GOTO, and SWITCH. Execution is in a top-down fashion until a branch statement is encountered. Sequence control of these languages is either implicit or conditional and is categorized by these groups, like precedence rules, parentheses and statements. They are used between statements e.g., conditional and iteration statements.

In logic based language groups, presence of variables in propositions requires resolution to find out values for those variables that allow the matching process to succeed. The process of determining useful values for variables is called Unification. The temporary assigning of values to variables to allow unification is called Instantiation.

The phenomena of instantiating a variable in resolution, failing to complete the required matching, discarding the present value and rolling back is called Back-Tracking. Logic based programming language like Prolog supports ‘backtracking’. Its objective is to obtain a particular goal, which automatically do the backtracking to find the solutions. This method is different from the block structural procedure languages because prolog users logic statement and structures

In this programming approach (logic), we express programs in a symbolic form (horn clauses) and use a Logical Inferencing Process (resolution) to produce results. Thus, there is no explicit need for flow of control statements.

 

Handling of Subprograms and Storage Management

In block structured, procedural languages, subprograms comprise of functions, procedures and modules, which make the program modular and easy to understand. Functions are rather easy to debug and may or may not return a value. There exist both global variables and local variables. Modules in block structured procedural languages provide means of packaging global data, derived types and associated operations, interface blocks, and name list groups. Modula-2 uses modules for its subprograms, dividing them in local or library modules. Pascal uses procedures and functions.

In logic-based languages procedures are often recursive and include some built in predicates. They may be difficult to debug. Recursive functions are a useful tool but require a lot of storage space.

Logic based language Prolog has no dynamic allocation for storage management, where most block-structured languages have both static and dynamic allocation.

 

Handling of Abstraction and Encapsulation

Abstraction is done in the subprograms or functions of Block structured, procedural language. ADT, which stands for Abstract Data Types provide a method of data hiding (or abstractions) in Blocked-structured, procedural languages. Logic-based languages has no real abstraction because complex data structures is actually based on simple data structures of atomic prepositions while lists provide a type of abstraction.

In logic-based languages, data objects are encapsulated in structure and lists. In Block Structured based languages like Pascal, encapsulation occurs in the procedure, where all objects are hidden from other subprograms. Modula-2 uses its modules for this. If an object is in a local module, it can only be accessed by its own subprogram: if it’s in a library module, it can be globally referenced.

^ Back to Top

 

 

Additional References