organization of programmming languages -1
organization of programmming languages -1
LANGUAGES
COURSE CODE: CMP 411
INTRODUCTION
Efficiency –An “efficient” language is one which permits fast compilation and execution on
the machines where it is implemented. Traditionally, FORTRAN and COBOL have been
relatively efficient languages in their respective application areas.
Generality
–This means that a language is useful in a wide range of programming applications. For
instance, APL has been used in mathematical applications involving matrix algebra and in
business applications as well.
Orthogonality: Orthogonality is the property that says " Changing A does not change B then
the features of a language are orthogonal, language is easier to learn, and programs are easier
to write because only few exceptions and special cases to be remembered.
Support for Abstraction: There is always found that a substantial gap remaining between
the abstract data structure and operations that characterize the solution to a problem and their
particular data structure and operations built into a language.
Programming Environment: A good programming language is such that has appropriate
programming environment (reliable documentation and testing packages) or integrated
programming environment.
1954 : FORTRAN
FORTRAN was developed in 1954 by John Backus and IBM. It was designed for numeric
computation and scientific computing. Software for NASA probes voyager-1 (space probe) and
voyager-2 (space probe) was originally written in FORTRAN. It is first high-level language. It
was developed using the first compiler and it is Machine Independent Language. In 1958
FORTRAN 2nd version was developed which introduces subroutines, functions, loops and
primitive for loop. It started as a Project and later renamed as ALGOL58.
1958: ALGOL
ALGOL stands for ALGOrithmic Language and was the initial phase of the most popular
programming languages of C, C++, and JAVA. It was also the first language implementing the
nested function and has a simple syntax than FORTRAN. The first programming language to
have a code block like “begin” that indicates that your program has started and “end” means you
have ended your code. ALGOL(ALGOrithmic Language) was a first "Block Structured Language
released in 1960.
It was Considered to be the first second generation Computer Language and Machine
Independent language. It introduced concepts like: Block structure code (Marked by BEGIN and
END), Scope
of variables (Scope of local variables inside blocks), BNF (Backus Naur Form), Notation for
defining syntax, Dynamic Arrays, Reserved words and IF THEN ELSE, FOR, WHILE loops
1959: COBOL
It stands for COmmon Business-Oriented Language. In 1997, 80% of the world’s business ran on
Cobol. The US internal revenue service scrambled its path to COBOL-based IMF (individual
master file) to pay the tens of millions of payments mandated by the coronavirus aid, relief, and
economic security. COBOL was rated in May 1959 by the Short-Range committee of the US
department of DOD.
1964: BASIC
BASIC (Beginner's All-purpose Symbolic Instruction Code). It was designed as a teaching
language in 1963 by John George Kemeny and Thomas Eugene Kurtz of Dartmouth college.
Intended to make it easy to learn programming. In 1991 Microsoft released Visual Basic, an
updated version of Basic but the first microcomputer version of Basic was co-written by Bill
Gates, Paul Allen, and Monte Davidoff for their newly-formed company, Microsoft.
1970: Pascal
Pascal is named after a French religious fanatic and mathematician Blaise Pascal. It was Created
in 1970 with the intension of replacing BASIC for teaching language. It was quickly developed as
a general-purpose language. It was Programs compiled to a platform-independent intermediate
pcode. The compiler for Pascal was written in Pascal.
1972: C
C is a general-purpose, procedural programming language and the most popular till now. All the
previous codes (like operating system and kernel) written in assembly language gets replaced by
the C language. C can be used to implementing operating system, embedded system, and on the
website using the Common Gateway Interface (CGI). C is the mother of almost all higher-level
programming languages like C#, D, Go, Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and
Unix’s C shell.
1. PROGRAMMING PARADIGMS
there are four groups of programming languages (and, therefore, programming styles)
distinguishable:
Imperative languages (sometimes also called procedural languages) are mostly influenced
by the von Neumann computer architecture. They express computation by fully specified and
controlled manipulation of named data in a stepwise fashion. In other words, data or values are
initially stored in variables (memory locations), taken out of (read from) memory, manipulated in
ALU (arithmetic logic unit), and then stored back in the same or different variables (memory
locations). Finally, the values of variables are sent to the I/O devices as output. Typical elements
of such languages are assignment statements, data structures and type binding, as well as
control mechanisms; active procedures manipulate passive data objects. Typical
representatives are FORTRAN or PASCAL.
1. Scientific Applications
6. Web software
1. Reliability Vs. Cost of Execution: For example, Java demands that all references to array
elements be checked for proper indexing, which leads to increased execution costs.
2. Readability vs. Writability: –APL provides many powerful operators land a large number
of new symbols), allowing complex computations to be written in a compact program but at
the cost of poor readability.
3. Writability (Flexibility) vs. reliability: The pointers in c++ for instance are powerful and
very flexible but are unreliable.
Data abstraction is a mechanism providing types and allowing the declaration of variables
of these types, as well as providing operations for the manipulation of these variables. Thus,
data abstraction in its simplest form is given by standard types such as real, for example. In
high level programming languages, the data type real allows the definition of floating-point
variables, and the set of operations on this data type allow the arithmetic manipulation of
objects of this type. As a form of user-defined data type, An abstract data type is a (user-
defined) data type and the set of permitted operations on objects of this type, by which the
internal representation is hidden to those using that type.
Control abstraction is the mechanism defining the order in which certain activities or
groups of activities should be performed. By this we mean not only control structures on the
statement level like conditional and unconditional branching, but also the construction of
subprograms up to concurrent programs. Control abstraction on the subprogram level was
already introduced in assembler languages by allowing macro definitions.
2. LANGUAGE STRUCTURE
The structures of programming languages are grouped into four structural layers which are
lexical, syntactic, contextual, and semantic.
Lexical structure
Lexical structure defines the vocabulary of a language. Lexical units are considered the building
blocks of programming languages. The lexical structures of all programming languages are
similar and normally include the following kinds of units:
1. Identifiers - Names that can be chosen by programmers to represent objects like
variables, labels, procedures, and functions. Most programming languages require that an
identifier start with an alphabetical letter and can be optionally followed by letters, digits,
and some special characters.
2. Keywords: Names reserved by the language designer and used to form the syntactic
structure of the language.
3. Operators: Symbols used to represent the operations. All general-purpose programming
languages should provide certain minimum operators such as mathematical operators like
+, −, *, /, relational operators like <, ?, ==, >, ?, and logic operators like AND, OR, NOT,
etc.
4. Separators: Symbols used to separate lexical or syntactic units of the language. Space,
comma, colon, semicolon, and parentheses are used as separators.
5. Literals: Values that can be assigned to variables of different types. For example, integer
type literals are integer numbers, character-type literals are any character from the
character set of the language, and string-type literals are any string of characters.
6. Comments: Any explanatory text embedded in the program. Comments start with a
specific keyword or separator. When the compiler translates a program into machine
code, all comments will be ignored.
7. Layout and spacing: Some languages are of free format such as C, C++, and Java. They
use braces and parentheses for defining code blocks and separations. Additional
whitespace characters (spaces, newlines, carriage returns, and tabs) will be ignored. Some
languages consider layout and whitespace characters as lexical symbols. For example,
Python does not use braces for defining the block of code. It uses indentation instead.
Different whitespace characters are considered different lexical symbols.
Syntactic structure
Syntactic structure defines the grammar of forming sentences or statements using the lexical
units. An imperative programming language normally offers the following basic kinds of
statements:
1. Assignments: An assignment statement assigns a literal value or an expression to a
variable.
2. Conditional statements: A conditional statement tests a condition and branches to a
certain statement based on the test result (true or false). Typical conditional
statements are if-then, if-then- else, and switch (case).
3. Loop statements: A loop statement tests a condition and enters the body of the loop or
exits the loop based on the test result (true or false). Typical loop statements are for-
loop and while-loop.
Contextual structure/ static semantics
Contextual structure (also called static semantics) defines the program semantics before
dynamic execution. It includes variable declaration, initialization, and type checking. Some
imperative languages require all variables be initialized when they are declared at the
contextual layer, while other don’t as long as the variables are initialized before their values
are used. This means that initialization can be done either at the contextual layer or at the
semantic layer. Contextual structure starts to deal with the meaning of the program. A
statement that is lexically correct may not be contextually correct. For example:
The declaration and the assignment statements are lexically and syntactically correct, but the
assignment statement is contextually incorrect because it does not make sense to add an integer
variable to a string variable.
Semantic structure
Semantic structure describes the meaning of a program, or what the program does during the
execution. The semantics of a language are often very complex. In most imperative
languages, there is no formal definition of semantic structure; informal descriptions are
normally used to explain what each statement does. The semantic structures of functional and
logic programming languages are normally defined based on the mathematical and logical
foundation on which the languages are based. For example, the meanings of Scheme
procedures are the same as the meanings of the lambda expressions in lambda calculus on
which Scheme is based, and the meanings of Prolog clauses are the same as the meanings of
the clauses in Horn logic on which Prolog is based.
The first rule defines that an integer is an unsigned integer with a leading sign. This
sign can be absent, or "+", or "_". The second rule shows that BNF allows recursive
Syntax graph
BNF notation provides a concise way to define the lexical and syntactic structures of
programming languages. However, BNF notations, especially the recursive definitions, are not
always easy to understand. A graphic form, called a syntax graph, also known as railroad tracks,
is often used to supplement the readability of BNF notation.
LANGUAGE PROCESSING
Syntax vs Semantics
Formal descriptions of the syntax of programming languages, for simplicity’s sake, often do not
include descriptions of the lowest-level syntactic units. These small units are called lexemes. The
description of lexemes can be given by a lexical specification, which is usually separate from the
syntactic description of the language. The lexemes of a programming language include its
numeric literals, operators, and special words, among others. One can think of programs as
strings of lexemes rather than of characters.
Lexemes are partitioned into groups—for example, the names of variables, methods, classes, and
so forth in a programming language form a group called identifiers. Each lexeme group is
represented by a name, or token. So, a token of a language is a category of its lexemes. For
example, an identifier is a token that can have lexemes, or instances, such as sum and total. In
some cases, a token has only a single possible lexeme. For example, the token for the arithmetic
operator symbol + has just one possible lexeme. Consider the following Java statement:
index = 2 * count + 17;
The lexemes and tokens of this statement are
Language Recognizers
The syntax analysis part of a compiler is a recognizer for the language the compiler
translates. In this role, the recognizer need not test all possible strings of characters from
some set to determine whether each is in the language. Rather, it need only determine
whether given programs are in the language. In effect then, the syntax analyzer determines
whether the given programs are syntactically correct.
The statement
A=B*(A+C)
is generated by the leftmost derivation:
Pass Tree
One of the most attractive features of grammars is that they naturally describe the hierarchical
syntactic structure of the sentences of the languages they define. These hierarchical structures
are called parse trees.
A grammar can be used to generate sentences of a specific language. However. a compiler
has to check strings of symbols to see whether they belong to that language. i.e. to find how a
sequence of symbols might be derived from the start symbol using the productions of the
grammar and to display the derivation (or to show that the sentence cannot be derived from
the start symbol). This problem is known as the parsing problem. pass tree of an expression x
+ y - x * y is given below as an example
Binding
Binding concept is the process of associating a variable, constant, expressions, functions and
procedures with their respective type, memory location and passing mechanism for
parameters, the association of such attributes or properties to an entity in a language is what
is known as binding. (or any suitable explanation)
types of binding
static binding is done before program execution and stay permanent through program
execution. dynamic binding is done and can be changed during program execution. Binding
can be perform during :
- Language definition time
- Language implementation time
- compile time
- run time.