Lecture 02 Flashcards
(24 cards)
Algol
Algol (ALGOrithmic Language),
designed to overcome
the problems of FORTRAN in the late 50s.
Algol 60 Major Concepts
- use of formal notation for syntax (BNF notation - lecture 5);
– block structure (with locally-defined variables);
– recursive procedures; and
– “readable” if and for statements.
Pascal
It is a direct descendant of Algol, intended to be more
efficient in order to compete with Fortran as a general purpose language.
Pascal compiler was designed to be portable, by compiling to a virtual machine (the p-code system).
Pascal became popular in the late 70s as a teaching
language in universities
More recent versions of Pascal have added modules and classes (e.g., the Object Pascal language, also called
Delphi)
Pascal continued
The program statement is a required first line of every program.
Program must have a name.
- input means that the keyboard may be used to put information into the program.
– output means that the program may write information to the video display.
program must have a “begin” to mark, likewise with an “end” statement too.
C
Fortran and COBOL proved successful in the 60s.
C was developed in 1972, alongside UNIX OS at Bell Labs.
C has high-level features like functions, loops and has low-level operations like arithmetic on memory addresses.
Object Oriented Language
Major application of computers is simulation of real-world systems.
Early programming languages developed for simulation include GPSS (1961) and Simula 1 (1965).
Designers of Simula, Dahl, Nygaard added the concept of the “class” to represent simulated entitites.
Simula 67 is considered as orginial object oreintated language.
Influential object-orientated languages that followed Simula 67 include Smalltalk (1980) and Eiffel (1986).
Scripting Languages
They are used to write programs that run for a special run-time environment that automate execution of tasks, or alternatively be executed by one-by-one by a human operator. For example shell scripts (CLI).
Scripting Languages Examples
High Level languages such as Perl, Python, Ruby, PHP, JavaScript, and MatLab.
Scripting languages have a simple syntax and semantics, interpreted and intended to be very fast to learn and write in.
Logical Languages: Prolog
ProLog building blocks are variables, constants, and structures.
Variables begin with capital letter.
Constants are either atoms like words or integers.
Structures consist of functor and arguments.
Prolog Queries
Used to answer queries ( arithmetic operations possible)
Query is a fact or rule that initiates a search for success in Prolog program.
Language Evaluation Criteria
Simplicity
Lexical elements.
Orthogonality
Control Structures
Data Types
Expressiveness
Type Checking
Exception Handling.
Simplicity
Language with simple syntax and small number of constructs. Smalltalk is considered simple vs C++ which is complex/large.
Programmers tend to learn only a subset of large language.
An example is i++, i = i + 1 in C++ and Java.
Lexical Elements
Form of individual lexical elements (words, symbols) of language that can affect readability.
Lexical Elements in Fortran 77
Fortran 77, variable names of 6 characters, making use of informative names difficult.
Lexical Elements
meaning
In Java, the meanings of keywords class and if are obvious. The meaning of static is not.
This means that the symbol = (used in Pascal) is more easily recognised as equal term == in (C, C++, Java).
Orthogonality meaning
Relatively small number of control and data constructs. ( e.g. data types)
Combined in a relatively small number of ways.
Every possible combination is legal and meaningful.
Programmer not needed to remember a lot of special cases, with orthogonal language in its constructs.
Orthogonality example
Data Types in a procedural language:
- Several elementary data types (e.g int, double)
- Several ways to combine data types ( sets, arrays, records and pointers) in order to define compound data types.
Example of Non-Orthogonality in Paschal
- A set of char type is legal, but a set of integer data type is not permitted.
- A data type is valid as the type of a parameter to a function/procedure
(this is orthogonal); but arrays cannot be returned from functions
Example of Non-Orthogonality in Java
Java has several kinds of types: classes, arrays &
primitive types.
-Can have classes/methods that operate for any
kind of objects, but not for primitive types (because
they are not objects).
Impacts of Orthogonality
Influences both readability and writability of software.
If a language contains fewer special cases, it is easier to learn ( easier to read and write)
Impacts of Orthogonality - Java statement
Java statements deal with adding and retrieving ints from a Vector:
vector data = new vector();
data.add(new Integer(e));
return ((Integer) data.lastElement()).intValue();
Conversion of primitive data to/from objects clearly illustrate poor readability and writability.
Data Types
Rich enough set of data is important.
C ( until recently) included no Boolean type ( 0 was used for false and any nonzero integer for true)
It is clear which of the following are more readable:
finished = 1; finished = true;
Data Types Mechanisms
Mechanisms for combining types are also important.
- Fortran 77 doesn’t include a record mechanism, so to represent a
collection of, say, bank accounts, one has to use separate arrays:
integer number (100)
character (len = 30) name (100)
real bal (100), odlim (100)
- These arrays must be indexed separately (e.g., when sorting based
on balances, swaps need to be performed on all of them).
Expressiveness
Relates to how much code and effort is required to implement computations.
For example in Java, it is more convenient to write i++ than i = I + i
Versus even the TPK algorithm in C.
For this, Python is more expressiveness too.