History
Block structured procedural programming
languages came later. They were first
introduced in 1971 with the creation of Pascal. Pascal was actually a modified version of ALGOL 60. In the creation of Pascal, Nicklaus Wirth
took the most popular parts of the most powerful programming languages of that
time and combined them all into the Pascal language. He took the CASE statement used in ALGOL-W, the user-defined data
types used in ALGOL-68, and the record structure similar to the one used in
COBOL and combined them all into Pascal.
It was to be both easy to teach and practical for writing systems and
applications programs.
The group of Object-Based languages
came much later than the Block Structured, Procedural languages. They were originally produced to take
advantage of object-based, or object-oriented ideals. These ideals made it possible for programmers to reuse code without
knowing the exact details of implementation behind it. This data abstraction makes
programming using objects very easy and very simple. Created efficiently, these objects can be created by someone and
then can be used by any programmer who has a minimal understanding of the
object. This group of languages
includes languages such as Ada, C++ and Smalltalk.
Overview
Block structured procedural languages, because they are
better able to demonstrate concepts such as structured programming and include
subprograms, are often used for the more complicated programs. Block structured languages have been used in
a wide area of applications in both education and industry. Pascal, for example, was designed
specifically for teaching beginning programmers concepts found in all
programming languages. Pascal programs
are easy to read and understand, and the language’s very design promotes
organization and good programming structure.
Object based languages have three identifying
characteristics: data abstraction,
inheritance, and dynamic type binding.
Abstract data types (ADTs) and their encapsulation abilities allow for
code reuse.
Inheritance allows a
hierarchy to be formed for the reuse of code and is one of the most important
advances in object oriented programming.
Dynamic type binding is achieved by encapsulating all data as objects
and sending messages to the objects performing all operations and functions.
Object oriented programming can be divided into two
distinct categories. First is pure
object oriented languages in which there is no typing system outside the class
structure. The pure object oriented
languages can be further divided into those that exclusively use dynamic type
binding, such as Smalltalk, and those that are statically typed, such as
Eiffel. Second, there are hybrid
languages, such as C++, which use a mixture of both static and dynamic type
binding and have type systems outside their class structures.
In block structured procedural languages, such as Pascal
and Modula-2, data objects are recognized within their specific block. Object based languages, due to the concept
of inheritance, take a broader view.
Inheritance allows a new ADT to inherit all the data and functionality
of an already existing type, giving the programmer the ability to add, delete,
or modify an existing type repeatedly in a program. This facilitates reuse in programs and makes coding faster and
easier. The concept of classes is also
used, extending the built-in capabilities of object based languages to assist
in the representation and solving of complex, real world problems.
Pascal and Modula-2 are nearly strongly typed, meaning
that nearly all types are known at compile time, but both fail in their design
of variant records because they allow omission of the tag that stores the
current type of a variable, which provides the means of checking for the
correct values. In languages such as
COBOL each name that is defined in a program unit needs to have a fixed data
type associated with it.
Both language groups have predefined data types, such as
real, integer, character, and boolean.
Most object based languages such C++, Modula-2, and Eiffel allows for
user defined data types, whereas JavaScript does not.
A block is specified in C as a segment
of code that begins with one or more data definitions and is enclosed in
braces. Block structured language execute sequentially, elements must appear in
certain order. This language groups support logical loop control statement,
do-while loops and IF-THEN-ELSE statement. Language like Pascal are designed so
that code is executed in a top-down format with exceptions made only when
conditional branches, such as if statements or switch structure. Block
structured language groups also support selection statements and subprograms,
and COBOL also has nested selection. It features algorithmic sequencing,
meaning that code is executed linearly until conditional branching is
encountered. However, block structured programs incorporate additional
functionality that allows for interrupts in sequence control so that blocks of
code stored outside of the primary block, or even in a separate file, may be
executed.
Object based languages are focus on
objects rather than procedure-oriented programming, which tend to lend itself
to less sophisticated procedure controls. With programs becoming increasingly
more complex, object based programming makes programming more powerful. Object
based languages may or may not require sequence control.
Handling of Subprograms and Storage Management
In Block Structured Languages, each
program must be broken into at least one block (main program). In an object based programming language,
subprograms are handled in a differently through the use of Inheritance. Inheritance is a relationship between
classes where one class is the parent of another class. Functions and procedures are available in
some Object-based languages, like C++, but others do not. Pointers are available in Block Structured
Procedural languages and Object-Based C++. Other Object-Based languages such as
Java and Eifel have automatic referencing and dereferencing of objects.
Both language groups provide the
programmer with storage manipulation capabilities that allow for the
reclamation and recycling of memory. The difference between the two is
that object-based languages provide an addition level of programmer memory
control through handles to objects in memory. These handles can either be
created or destroyed, therefore leaving the objects either accessible or
inaccessible to the program.
Block Structured procedural type languages do not support abstraction directly. However, Pascal supports a mild implication of abstraction through the use of the TYPE statement as in…
TYPE CHAR80
= PACKED ARRAY [1..80] OF CHAR;
Block structured procedural
type languages typically emulate encapsulation with the use of procedures and
functions where local data is not available to the global program. Pascal, for
instance, includes records as a form of data abstraction. All components of
records are visible within all procedures that have access to the type of the
record.
Abstraction
in an object based language is characterized by a structured collection of
objects, one of which must be specified by a class declaration at compile time
as the root class. Object creation implicitly includes initialization of
attributes using standard default values.
Constructor routines for classes can be defined by the user for
initialization with non-standard default values (Concepts of Programming
Languages, 4th edition, p.481).
Unlike Block Structured, Procedural languages, Functional languages were originally created in the 1950’s for its use in Artificial Intelligence. LISP for example was developed in 1958 at IBM in order to handle algebraic expressions and mathematical functions. Later Scheme was introduced in 1975 to fully support lexical scooping, first-class procedures, and continuations. At first it was used primarily for research and teaching and it only supported a handful of pre-defined syntactic forms and procedures. Now, however, it is a complete general-purpose language. The general purpose of these languages was to produce code that closely resembled English. One of the major differences in these to types of languages is the fact that they were created for two totally different programming types. Block Structured, Procedural languages were used for creating actual applications unlike the Functional language group that was created for use in mostly evaluating functions.
Block structured procedural languages are imperative in
nature, and were developed in response to the growing use of programming
languages to solve a wider array of programming domains than the predominately
numeric and scientific type applications of earlier years. Functional languages are nonimperative. They are applicative and are based on
mathematical functions, whereby members of a domain set are mapped to a range
set.
The objective of the design of a functional programming
language is to mimic mathematical functions to the greatest extent
possible. A functional language
provides a set of primitive functions, a set of functional forms to construct
complex functions from those primitive functions, a function application
operation, and some structure or structures for storing data. A well-defined functional language requires
only a small number of primitive functions.
Functional languages, such as LISP, are used primarily for artificial
intelligence (AI), and list processing applications.
Block structured procedural languages use constants and
variables which can be structured to represent many real world entities. The earliest version, ALGOL 60, used untyped
or primitive basic data structures. A
later version, ALGOL 68, introduced user-defined data types. This allowed users to combine primitive data
types into a large number of different structures to model the problem
domain. The use of assignment
statements on variables allow these variables to change value during
execution.
A purely functional language does not use variables or
assignment statements in the imperative language sense, however, most do retain
some notion of variable and assignment, and so are impure, but it is still
possible to program effectively using the pure approach. Functional languages, such as LISP, use
atoms and lists. A parameter for functional
languages can represent any member of the domain set. It is fixed to represent one specific element during the
evaluation of the functional expression.
The result is a member of the range set, which can then be the domain of
a larger or encompassing function.
Although ML is strongly typed, most functional languages
are typeless. Functional languages have
more dynamic binding. They do not bind
a type to storage until a value is assigned, at which time the type bound is
that of the assigned value. A program
written in a functional language consists of function definitions and
application specifications, with execution consisting of evaluating the
function applications.
Functional programming paradigm, which
is based on mathematical functions, is the design basis for one of the most
important nonimperative styles of languages. This style of programming is
supported by functional, or applicative, programming languages. LISP began as a
purely functional language, but it soon acquired some important imperative
features that increased its execution efficiency.
The control flow mechanisms of Scheme
are modeled after those of mathematical functions. Control flow in mathematical
function definitions is quite different from that in block structured,
procedural programming languages. Whereas functions in block structured
languages are defined as collections of statements that include several kinds
of sequence control flow, mathematical functions do not have multiple statements
and use only recursion and conditional expressions for evaluation flow. For
example, the factorial function can be defined with two operations in
functional language: F(n)= {1 if n=0 ;
n*f(n-1) if n>0 . Functional language use recursion to do repetition, while
block structured language use iteration. Functional languages can have a very
simple syntactic structure. The lost structure of LISP is an example. The
syntax of the block structured languages is much more complex.
Subprograms and functions are nearly
synonymous in functional languages. Subprograms may be named if they are to be
reused and are not locally scoped. PASCAL has procedures, which have no return
type, and functions that do return a type.
It also allows for recursion and dynamic storage through the use of
pointers. Again, pointers are available
in Block Structured Procedural, but Functional languages do not allow direct
access to memory. Functional languages,
in general, feature automatic memory management for the allocation and
de-allocation of memory and automatic garbage collection. Forth programs are synthesized layers of
subprograms. Forth maintains the LIFO
(Last-In-First-Out) stacks that operate on the parameters. Storage management is achieved using stacks
and the disk.
Block
structured procedural type languages do not support abstraction directly.
However, Pascal supports a mild implication of abstraction through the use of the
TYPE statement as in…
TYPE CHAR80
= PACKED ARRAY [1..80] OF CHAR;
Block structured procedural
type languages typically emulate encapsulation with the use of procedures and
functions where local data is not available to the global program. Pascal, for
instance, includes records as a form of data abstraction. All components of
records are visible within all procedures that have access to the type of the
record.
Functional
languages’ abstraction and encapsulation comes from its inherent use of
functions. For example LISP has a
function encapsulate, which as you would expect, encapsulates whatever function
it is applied to. The encapsulate function enables the programmer to hide the
information of the function. Functional languages hide fragments of the program
to improve clarity. This type of a
procedural abstraction to some extent hides complexity of the program
increasing readability and maintainability.
Logic
languages were first developed through early languages such as Micro-Planner
and Conniver. These languages, however,
were very inefficient so were unable to replace LISP as the most common
language used for Artificial Intelligence.
Soon Prolog grew out of these languages. The development of these languages is caused widely because of
its use in Artificial Intelligence.
Unlike, the Block Structured, Procedural languages, Logical languages
are not used to write applications.
They are used for the direction and manipulation of Artificial
Intelligence. Prolog for instance is
based on Selected Literal Define clause resolution, theorem proving, and
unification. The early implementations
of Prolog included C-Prolog, ESLPDPRO, Frolic, LM-Prolog, Open Prolog,
SB-Prolog, and UPMAIL Tricia Prolog.
Currently, the most common forms of Prolog are Quintus Prolog, SICSTUS,
Prolog, LPA Prolog, SWI Prolog, AMZI Prolog and SNI Prolog
Block structured procedural languages are imperative in
nature. They were developed because of the growing use of programming languages
to solve wider arrays of problems outside of the scientific areas, particularly
business and education. Logic
programming languages are nonimperative.
They are declarative and use formal logic notation to communicate
computational processes to a computer.
Predicate calculus is the notation used in current logic programming
languages.
In logic programming, specifications of desired results
are programmed, not the process to obtain the results. It is being used in the AI field because of
its ability to use its processes to determine the most correct result. In PROLOG, for example, the programmer first
defines objects and how they relate to one another and then defines rules that
the computer can use to deduct new facts.
“Facts” and “Rules” are the database, and running a program in PROLOG is
really querying that database. The main
objective of logic programming is to enhance the research and development of AI
and managing database systems.
Block structured procedural languages use set of
predefined data types: real, integer,
character, boolean, variables, constants and literals. The earliest version, ALGOL 60, used untyped
or primitive basic data structures, and a later version, ALGOL 68, introduced
user-defined data types. This allowed
users to combine primitive data types into a large number of different
structures to model the domain problem.
The use of assignment statements on variables allow them to change a
value during execution.
Logic based languages represent objects by using terms,
which are constructed from constants, variables, or structures. All three are different, as constants are
usually integers; variables are strings; and structures can be groups of
both. Each term has different rules as
to how characters are put together to form its name. PROLOG also supports simple arithmetic.
Logic language is based on logic, so
logic programs are likely to be more logically organized and written, which
should lead to fewer errors and less maintenance compare to block structured
language. The difference between block structured program and logic programs,
logic programs should be nonprocedural, which means that the characteristics of
the solution are given but the complete process of getting the solution is not.
In Prolog, there are two opposite approaches to attempting to match a given
goal to a fact in the database. The system can begin with the facts and rules
of the database and attempt to find a sequence of matches that lead to the
goal. This approach is called bottom-up resolution, or forward chaining. The
alternative is to begin with the goal and attempt to find a sequence of
matching propositions that lead to some set of original facts in the database. This
approach is called top-down resolution, or backward chaining.
Block
structured procedural languages have borrowed and learned from their
predecessors. They allow for recursive
calls, dynamic allocation of local variables, and functions as subprogram
parameters. Logic-Based languages do
not support subprograms. Their program is stored as a data structure such as a
tree or subtree and is handled as regular programs. Since there are no subprograms in Logic-Based languages, it is
difficult to create modular programs. The programmer must also be very familiar
with all of the types of data structures available with the languages and how
to use them properly.
Because logical languages must not only deal with data
storage, but the relationship between items of data, flexible storage modes are
required. Either structures may share
one instance of data, or duplicate values. In the first case, lists provide simple
mean to insert, delete, and link items that share a relationship with each
other. Unlike Block Structured,
Procedural languages, Logic-Based languages do not allow for dynamic storage
management at run-time (like pointers). This limits programming errors using pointers and other
structures, but also takes a lot memory.
Block
structured procedural type languages do not support abstraction directly.
However, Pascal supports a mild implication of abstraction through the use of
the TYPE statement as in…
TYPE CHAR80
= PACKED ARRAY [1..80] OF CHAR;
Block structured procedural
type languages typically emulate encapsulation with the use of procedures and
functions where local data is not available to the global program. Pascal, for
instance, includes records as a form of data abstraction. All components of
records are visible within all procedures that have access to the type of the
record.
Logic
programming languages do not have the software principles for modules, types,
and higher order programming and data abstraction. By nature, in logic
programming it is not needed for the programmer to see actual implementation.
Instead he can deal with the systems whose implementation methods are
abstracted. The programmer needs to supply information following a set of
rules, and ask questions - not worry about the ways the rules must be applied
to answer these questions.
References:
Robert w.Sebesta, Programming languages.
http://www2.cstp.umkc.edu/cgi~programs/process.com
Block Structured, Procedural
Languages - Pascal
http://www.kumc.edu/service/itc/people/nevans/Pascal.doc
Object Based Languages -
Eiffel
http://www.geocities.com/linxin66046/project_1.htm
http://www.eiffel.com/doc/manuals/technology/oo_comparison/index.html
Functional Languages – LISP,
yacc
http://www.geocities.com/weishao2001/project1_h.htm
http://www.cstp.umkc.edu/~jsukardi/cs441/proj1_historyoverview.htm
Logical Languages - Prolog
http://www.cstp.umkc.edu/personal/mwilson/cs441/proj1/cs441project1_prolog.htm