SlideShare a Scribd company logo
Principles of Programming
Languages
SE Sem II
Fundamentals of Programming
• Importance of Studying Programming Languages
• History of Programming Languages
• Impact of Programming Paradigms
• Role of Programming Languages
• Programming Environments
• Impact of Machine Architectures
1. The operation of a computer
2. Virtual Computers and Binding Times
• Programming paradigms
• Introduction to four main Programming paradigms
1. Procedural
2. Object oriented
3. Functional
4. Logic and rule based.
Importance of Studying Programming Language
1. To improve your ability to develop effective algorithms
• Many languages provide features, that when used properly, are of benefit to the programmer
but, when used improperly, may waste large amounts of computer time or lead the
programmer into time-consuming logical errors
• Even a programmer who has used a language for years may not understand all of its
features
• A typical example is recursion—a handy programming feature that, when properly used,
allows the direct implementation of elegant and efficient algorithms. When used
improperly, it may cause an astronomical increase in execution time
Importance of Studying Programming Language
2. To improve your use of your existing programming language
• By understanding how features in your language are implemented, you greatly increase
your ability to write efficient programs
• For example, understanding how data such as arrays, strings, lists, or records are
created and manipulated by your language, knowing the implementation details of
recursion, or understanding how object classes are built allows you to build more
efficient programs consisting of such components.
Importance of Studying Programming Language
3. To increase your vocabulary of useful programming constructs
• By studying the constructs provided by a wide range of languages, a programmer
increases his programming vocabulary.
• The understanding of implementation techniques is particularly important because, to
use a construct while programming in a language that does not provide it directly, the
programmer must provide an implementation of the construct in terms of the primitive
elements actually provided by the language languages provide a coroutine feature
directly
Importance of Studying Programming Language
4. To allow a better choice of programming language
• A knowledge of a variety of languages may allow the choice of just the right language
for a particular project, thereby reducing the required coding effort.
• Applications requiring numerical calculations can be easily designed in languages like
C, FORTRAN, or Ada
• Developing applications useful in decision making, such as in artificial- intelligence
applications, would be more easily written in LISP, ML, or Prolog.
• Internet applications are more readily designed using Perl and Java. Knowledge of the
basic features of each language's strengths and weaknesses gives the programmer a
broader choice of alternatives
Importance of Studying Programming Language
5. To make it easier to learn a new language
• a thorough knowledge of a variety of programming language constructs and
implementation techniques allows the programmer to learn a new programming
language more easily when the need arises.
6. To make it easier to design a new language
• A designer of a user interface for a large program such as a text editor, an operating
system, or a graphics package must be concerned with many of the same issues that are
present in the design of a general-purpose programming language
• Many new languages are based on C or Pascal as implementation models. This aspect of
program design is often simplified if the programmer is familiar with a variety of
constructs and implementation methods from ordinary programming languages.
A brief history
of programming languages
Software Evolution
9
Fig: Layers of Computer Software
Machine Language
Assembly Language
Procedure Oriented Language
Object Oriented Language
1 / 0
10
Levels of Programming Languages
High-level program class Triangle {
...
float surface()
return b*h/2;
}
Low-level program LOAD r1,b
LOAD r2,h
MUL r1,r2
DIV r1,#2
RET
Executable Machine code 000100100100010100100100111011
0010101101001...
Evolution of computer languages
00000000 00000100 0000000000000000
01011110 00001100110000100000000000000010
11101111 000101100000000000000101
11101111 10011110 0000000000001011
11111000 10101101 11011111 0000000000010010
0110001011011111 0000000000010101
11101111 00000010 11111011 0000000000010111
11110100 1010110111011111 0000000000011110
0000001110100010 11011111 0000000000100001
11101111 00000010 11111011 0000000000100100
01111110 11110100 10101101
11111000 10101110110001010000000000101011
0000011010100010 11111011 0000000000110001
11101111 00000010 11111011 0000000000110100
00000100 0000000000111101
00000100 0000000000111101
Program in machine language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
13
Levels of Programming Languages
High-level program class Triangle {
...
float surface()
return b*h/2;
}
Low-level program LOAD r1,b
LOAD r2,h
MUL r1,r2
DIV r1,#2
RET
Executable Machine code 000100100100010100100100111011
0010101101001...
Evolution of computer languages
00000000 00000100 0000000000000000
01011110 00001100110000100000000000000010
11101111 000101100000000000000101
11101111 10011110 0000000000001011
11111000 10101101 11011111 0000000000010010
0110001011011111 0000000000010101
11101111 00000010 11111011 0000000000010111
11110100 1010110111011111 0000000000011110
0000001110100010 11011111 0000000000100001
11101111 00000010 11111011 0000000000100100
01111110 11110100 10101101
11111000 10101110110001010000000000101011
0000011010100010 11111011 0000000000110001
11101111 00000010 11111011 0000000000110100
00000100 0000000000111101
00000100 0000000000111101
Program in machine language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
The only language understood by
a computer is machine language.
Note:
Entry main, ^m<r2>
subl2 #12,sp
jsb C$MAIN_ARGS
movab $CHAR_STRING_CON
pushal -8(fp)
pushal (r2)
calls #2,read
pushal -12(fp)
pushal 3(r2)
calls #2,read
mull3 -8(fp),-12(fp),-
pushal 6(r2)
calls #2,print
clrl r0
ret
Program in symbolic language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Symbolic languages
• Assembly language is a symbolic language.
• An assembler is used to translate symbolic code into machine
language.
/* This program reads two integer numbers from the
keyboard and prints their product.
*/
#include <iostream.h>
int main (void)
{
// Local Declarations
int number1;
int number2;
int result;
// Statements
cin >> number1;
cin >> number2;
result = number1 * number2;
cout << result;
return 0;
} // main
Program in C++ language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
• High-level language is a computer language which can be understood by the users.
• The high-level language is very similar to human languages and has a set of grammar rules that are
used to make instructions more easily.
• Every high-level language has a set of predefined words known as Keywords and a set of rules
known as Syntax to create instructions.
• The high-level language is easier to understand for the users but the computer can not understand
it.
• High-level language needs to be converted into the low-level language to make it understandable
by the computer.
• We use Compiler or interpreter to convert high-level language to low-level language.
• Languages like FORTRAN,C, C++, JAVA, Python, etc., are examples of high-level languages.
• All these programming languages use human-understandable language like English to write
program instructions.
• These instructions are converted to low-level language by the compiler or interperter so that it can
be understood by the computer.
• g++ main.cpp
High-level language
Assembly language
• Middle-level language is a computer language in which the instructions are created using symbols
such as letters, digits and special characters.
• Assembly language is an example of middle-level language. In assembly language, we use
predefined words called mnemonics.
• Binary code instructions in low-level language are replaced with mnemonics and operands in
middle-level language.
• But the computer cannot understand mnemonics, so we use a translator called Assembler to
translate mnemonics into machine language.
• Assembler is a translator which takes assembly code as input and produces machine code as
output.
• That means, the computer cannot understand middle-level language, so it needs to be translated
into a low-level language to make it understandable by the computer.
• Assembler is used to translate middle-level language into low-level language.
• g++ -S main.cpp -o main.s
Low-level language
• It requires an assembler that would translate instructions
• It is not portable
• It is difficult to understand.
• Low-Level language is the only language which can be understood by the computer.
• Low-level language is also known as Machine Language.
• The machine language contains only two symbols 1 & 0.
• All the instructions of machine language are written in the form of binary numbers 1's &
0's.
• A computer can directly understand the machine language.
ASSEMBLY LEVEL LANGUAGE HIGH-LEVEL LANGUAGE
It needs an assembler for conversion It needs a compiler/interpreter for conversion
In this, we convert an Assembly level language to
machine level language
In this, we convert a high-level language to Assembly
level language to machine level language
It is machine dependent It is machine-independent
In this mnemonics, codes are used In this English statement is used
It supports low-level operation It does not support low-level language
In this, it is easy to access hardware component In this, it is difficult to access hardware component
In this more compact code No compactness
PPL_Unit01 for the insem study first year.pptx
Pioneers of programming
• Charles Babbage:
Invented the Analytical Engine. His companion, Ada Augusta Lovelace, is
considered the first programmer in history.
• Konrad Zuse:
Designed Plankalkül. This notation (never implemented) has features than can
be found in many existing programming languages.
Very low-level languages
• Those are machine languages and assembly languages, machine-dependent
coding systems. They were initially fully binary, and then symbolic.
• There is one native machine language, and usually one assembly language per
processor model.
• Upward compatibility can be a nightmare. Was moving from 386 to 486
painless? From 486 to Pentium?
Fortran
• Fortran was originally developed by IBM in the 1950s for scientific and
engineering applications, and subsequently came to dominate scientific
computing.
• It has been in use for over six decades in computationally intensive areas such
as numerical weather prediction, finite element analysis, computational fluid
dynamics, geophysics, computational physics, crystallography and computational
chemistry. It is a popular language for high-performance computing and is used
for programs that benchmark and rank the world's fastest supercomputers.
Fortran
• Fortran was the first effectively implemented high-level language that introduced
variables as we know them now, loops, procedures, statement labels and much
more.
• The earliest versions of Fortran had many unique features, often awkward, later
kept along for compatibility. It is still widely used in engineering applications that
require much array manipulation.
• The newest version, Fortran 90, has converged toward other popular programming
languages.
Algol 60
• It was the first to have block structure, recursion, and a formal definition. It is
not used now, but it is the ancestor of most contemporary languages.
• As far as design goes, Algol 60 was without doubt the most important
innovation in the history of programming languages (so far ).
CSI 3125, History, page 30
Cobol
• Business-oriented computations
• very strict program organization
• poor control structures
• elaborate data structures, record type introduced for the first time.
Used to be very popular in business and government, much less at
universities.
• Revived for a while during the Y2K scare—why?
PL/I
• A combination of features believed (at the time) best in Fortran, Algol 60,
Cobol.
• the first language designed to be completely general, good for all
possible applications
• actively promoted by IBM
• not used much today.
• An interesting feature introduced in PL/I: event handling.
Basic
Beginners' All-purpose Symbolic Instruction Code
• Is a family of general-purpose, high-level programming languages
• The original version was designed by John G. Kemeny and Thomas E. Kurtz and released
at Dartmouth College in 1964
• The first in history language of personal computing.
• The first programming language for many programmers: designed to be easy to learn.
• Very simple, limited, though still general-purpose.
• Present-day versions of Basic are full-fledged languages—not "basic", and not easy to learn any
more.
CSI 3125, History, page 33
Simula 67
• Simula is the name of two simulation programming languages, Simula I and Simula 67, developed in
the 1960s at the Norwegian Computing Center in Oslo, by Ole-Johan Dahl and Kristen Nygaard. ...
Simula is considered the first object-oriented programming language.
• An extension of Algol 60 designed for simulation of concurrent processes.
• Introduced the central concepts of object orientation: classes and encapsulation.
• Predecessor of Smalltalk and C++.
• Now unused.
Algol 68
• ALGOL 68 (short for Algorithmic Language 1968) is an imperative programming language that was
conceived as a successor to the ALGOL 60 programming language, designed with the goal of a much
wider scope of application and more rigorously defined syntax and semantics.
• Imperative programming is a programming paradigm that uses statements that change a program's state
• A very elegant design, unmatched till today.
• Full orthogonality.
• Extremely difficult to implement.
• A very clever formal description, unfortunately hard to understand for most potential users.
• Completely unused.
Pascal
• A conceptually simplified and cleaned-up successor of Algol 60.
• A great language for teaching structured programming.
• An excellent first language to learn: teaches good programming habits.
• Its later extensions (for example, Delphi) are full-fledged systems
programming packages, as powerful as any Java kit.
Modula-2
• A better, conceptually uniform successor of Pascal.
• Mechanisms to program concurrency (many processes running in parallel).
• Not used as much as it deserves.
• Its successors, Modula-3 and Oberon, are even more conceptually appealing,
practically useful—and almost not used at all. (They lost the popularity contest
with C++.)
Ada
• The result of an elaborate, multi-stage design process, and a more successful
attempt at generality than PL/I.
• Completely standard: there can be no dialects (like Java, except that
Microsoft...).
• There are, however, two standards: Ada 83 (the original), and Ada 95.
• Ada has been designed to support concurrency in a very neat, systematic way.
C-language
• The implementation language of Unix.
• A great tool for systems programming and a software development
language on personal computers.
• Once fashionable, still in use, but usually superseded by C++.
• Dangerous if not used properly: not recommended to novice
programmers.
• Relatively low-level.
Lisp
• One of the earliest programming languages.
• Based on the concept of computing by evaluating functions. Very good for symbolic
computing.
• For years, the only language for Artificial Intelligence work. (Prolog is 12 years
younger.)
• Many dialects, two standards (Scheme, Common Lisp). Nice programming
environments.
• Lisp's successors are very elegant (Miranda, ML, Haskell) but not nearly as widely
used.
Prolog
• A very high-level programming language.
• Declarative, based on a subset of logic, with proofs interpreted as computation.
• Very powerful:
• Non-deterministic (built-in backtracking).
• Elaborate, flexible pattern matching.
• Associative memory.
• Pattern-directed procedure invocation.
• In skilled hands, it is a very strong tool.
Smalltalk
• It is the purest object-oriented language ever designed (till now),
cleaner than Java, much cleaner than C++.
• Comes complete with a graphical interface and an integrated
programming environment.
• In skilled hands, a powerful tool.
C++
• An object-oriented extension of the imperative language C.
• This is a hybrid design, with object orientation added to a completely different base language.
• Complicated syntax, difficult semantics.
• Very fashionable, very much in demand.
• Java did not (yet?) push it out.
Java
• A neat, cleaned up, sized-down reworking of C++.
• Full object orientation (though not as consistent as Smalltalk)
• Designed for Internet programming, but general-purpose.
• It is said (not quite correctly) to be slow.
• New fashion: maybe the next de-facto standard?
Scripting languages
• Text processing:
• Perl
• Python
• Web programming
• JavaScript
• PHP
Role of Programming
Language
Role of Programming Languages
Just like natural languages, programming languages evolve and eventually pass out of use.
Algol from 1960 is no longer used, replaced by Pascal, which in turn is being replaced by
CH—I- and Java. COBOL use is dropping for business applications, also being replaced by
C++. APL, PL/I, and SNOBOL4, all from the 1960s, and
Pascal from the 1970s have all but disappeared.
The older languages still in use have undergone periodic revisions to reflect changing
influences from other areas of computing. Newer languages like C++, Java, and ML reflect
a composite of experience gained in the design and use of these and the hundreds of other
older languages. Some of these influences include
the following:
Influences
1. Computer capabilities.
2. Applications.
3. Programming methods.
4. Implementation methods.
5. Theoretical studies.
6. Standardization.
Attributes of a Good Language
1. Clarity, simplicity, and unity.
A programming language provides both a conceptual framework for thinking about algorithms and
a means of expressing those algorithms. The language should be an aid to the programmer long
before the actual coding stage. It should provide a clear, simple, and unified set of concepts that
can be used as primitives in developing algorithms.
2. Orthogonality.
• The term orthogonality refers to the attribute of being able to combine various features of a
language in all possible combinations, with every combination being meaningful.
• When the features of a language are orthogonal, the language is easier to learn and programs are
easier to write because there are fewer exceptions and special cases to remember.
Attributes of a Good Language
3. Naturalness for the application.
A language needs a syntax that, when properly used, allows the program structure to reflect the
underlying logical structure of the algorithm. Ideally, it should be possible to translate such a
program design directly into appropriate program statements that reflect the structure of the
algorithm. Sequential algorithms, concurrent algorithms, logic algorithms, and others all have
differing natural structures that are represented by programs in those languages.
4. Support for abstraction.
• Even with the most natural programming language for an application, there is always a substantial gap
remaining between the abstract data structures and operations that characterize the solution to a problem
and the particular primitive data structures and operations built into a language.
• Ideally, the language should allow data structures, data types, and operations to be defined and maintained
as self-contained abstractions. The programmer may use them in other parts of the program knowing only
their abstract properties without concern for the details of their implementation.
Attributes of a Good Language
5. Ease of program verification.
• The reliability of programs written in a language is always a central concern. There are many
techniques for verifying that a program correctly performs its required function.
• A language that makes program verification difficult may be far more troublesome to use than
one that supports and simplifies verification, even though the former may provide many more
features that superficially appear to make programming easier.
6. Programming environment.
• The availability of a reliable, efficient, and well-documented implementation of the language
must head the list.
• Special editors and testing packages tailored to the language may greatly speed the creation and
testing of programs.
• Facilities for maintaining and modifying multiple versions of a program may make working
with large programs much simpler.
Attributes of a Good Language
7. Portability of programs.
• One important criterion for many programming projects is the transportability of the resulting
programs from the computer on which they are developed to other computer systems
• A language that is widely available and whose definition is independent of the features of a
particular machine forms a useful base for the production of transportable programs.
8. Cost of use.
Cost is certainly a major element in the evaluation of any programming language, but cost
means many different things:
(a) Cost of program execution.
(b) Cost of program translation.
(c) Cost of program creation, testing, and use.
(d) Cost of program maintenance.
Programming Environment
Programming Environments
• A programming environment is the collection of tools used in
the development of software
• This collection may consist of only a file system, a text editor, a
linker, and a compiler.
• Text editor is software that is used to write computer program.
Ex Notepad, text editor.
• The conversion of program text file into binary format you need
software called compiler
Impact of Machine
Architectures
THE OPERATION OF A COMPUTER
• A computer is an integrated set of algorithms and data structures capable of storing and
executing programs.
• A computer may be constructed as an actual physical device using wires, integrated circuits,
circuit boards, and the like, in which case it is termed an actual computer or hardware computer.
• It may also be constructed via software by programs running on another computer, in which
case it is a software-simulated computer.
• A programming language is implemented by construction of a translator, which translates
programs in the language into machine language programs that can be directly executed by
some computer.
• The computer that executes the translated programs may either be a hardware computer or a
partially of software.
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
• A main memory contains programs and data to
be processed.
• Processing is performed by an interpreter,
which takes each machine language instruction
in turn, decodes it, and calls the designated
primitive operation with the designated
operands as input.
• The primitives manipulate the data in main
memory and in high-speed registers and also
may transmit programs or data between
memory and the external operating
environment.
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
A computer consists of six major
components that correspond closely to
the major aspects of a programming
language:
 Data
 Primitive Operations
 Sequence Control
 Data Access
 Storage Management
 Operating Environment
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
1. Data.
Three major data storage components: main
memory, high-speed registers, and external files.
Main memory is usually organized as a linear
sequence of bits subdivided into fixed-length
words (typically 32 or 64 bits) or 8-bit bytes
(typically 4 or 8 bytes per word).
The high-speed registers consist of word-length
bit sequences and may have special subfields that
are
directly accessible. The contents of a register may
represent data or the address in main memory
containing the data or next instruction.
External files, stored on magnetic disk,
magnetic tape, or CD-ROM,
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
2. Operations.
A computer must contain a set of built-in primitive
operations, usually paired one to one with the operation
codes that may appear in machine language instructions.
Primitives for arithmetic e.g., real and integer
addition, subtraction, multiplication, and division
Primitives for testing various properties of data
items e.g., test for zero, positive and negative numbers
Primitives for accessing and modifying various
parts of a data item e.g., retrieve or store a character in
a word and retrieve or store an operand address in an
instruction
Primitives for controlling input-output (I/O) devices
Primitives for sequence control e.g., unconditional
and return jumps.
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
3. Sequence control .
• The control of execution of the operations, both
primitive and user defined, is termed as
sequence control.
• The interpreter is central to the operation of a
computer. Typically, the interpreter executes the
simple cyclic algorithm
• During each cycle, the interpreter gets the
address of the next instruction from the
program address register (and increments the
register value to be the next instruction
address)
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
4. Data access.
• Typically an operand might be in main memory
or in a register.
• the result of a primitive operation must be
stored in some designated location.
• We term these facilities the data access control
of the computer.
• The conventional scheme is to simply associate
integer addresses with memory locations and
provide operations for retrieving the contents of
a location given its address.
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
5. Storage management.
To balance the internal speed of a microprocessor
and the speed of a disk appropriately, various
storage management facilities are employed.
For speeding up the imbalance between main
memory and the central processor, a cache
memory is used.
A cache memory is a small high-speed data storage
that is between main memory and the central
processor.
A cache allows the computer to operate as if the
main memory had essentially the same speed as
the central processor.
THE OPERATION OF A COMPUTER
Organization of a conventional computer.
6. Operating environment.
The operating environment of a computer
ordinarily consists of a set of peripheral storage
and I/O devices.
These devices represent the outside world to the
computer, and any communication with the
computer must be by way of the operating
environment.
Often there are hardware distinctions between
various classes of devices in the environment
based on differences in use or speed of access e.g.,
high-speed storage [extended memories], medium-
speed storage [magnetic disks, CD-ROM], low-
speed storage [tapes], and I/O devices [readers,
printers, displays, data communication lines].
Alternative computer architectures
von Neumann architecture.
The von Neumann computer is named after the
mathematician John von Neumann, who developed this
initial design in the early 1940s as part of the design of
ENIAC, which was one of the first electronic computers.
A computer, in his design, consisted of a small controlling
central processing unit (CPU) consisting of the primitive
operations, sequence control and registers for storing the
results of the primitive operations, a larger main memory,
and a process for retrieving and storing words of data
between the CPU and larger memory.
Alternative computer architectures
Multiprocessors.
As we just discussed, one problem with the von Neumann
design is the great imbalance in the slow speed of external
data devices and the high speed of the CPU registers.
An alternative approach toward this imbalance is the use
of multiple CPUs in a given system. Such multiprocessing
systems have been in use for over 30 years.
By coupling several relatively inexpensive CPUs with
single sets of memory, disks, tapes, and so on, an effective
system can be designed.
The operating system runs different programs on different
CPUs in the system and overall performance is improved.
Language Implementations
Language Implementations
1. Translation (or compilation).
A translator could be designed to translate programs in the high-level language into equivalent programs in
the machine language of the actual computer.
• An assembler is a translator whose object language is also some variety of machine language for an actual
computer but whose source language, an assembly language, represents for the most part a symbolic
representation of the object machine code.
• A compiler is a translator whose source language is a high-level language and whose object language is close to
the machine language of an actual computer, either being an assembly language or some variety of machine
language.
• A loader or link editor is a translator whose object language is actual machine code and whose source language
is almost identical; it usually consists of machine language programs in relocatable form together with tables of
data specifying points, where the relocatable code must be modified to become truly executable.
• A preprocessor or a macroprocessor is a translator whose source language is an extended form of some high-
level language such as C++ or Java and whose object language is the standard form of the same language.
Language Implementations
2. Software simulation (software interpretation).
• Rather than translating the high-level language programs into equivalent machine-language programs, we
might instead simulate, through programs running on another host computer, a computer whose machine
language is the high-level language.
• To do this, we construct a set of programs in the machine language of the host computer that represent the
algorithms (and data structures) necessary for the execution of programs in the high-level language.
• The main simulator program performs an interpretation algorithm decoding and executing each statement
of the input program in the appropriate sequence and producing the specified output from the program.
• we say that the host computer creates a virtual machine simulating the high-level language. When the host
computer is executing the high-level program, it is not possible to tell whether the program is being
executed directly by the hardware or is first converted to the low-level machine language of the hardware
computer.
Virtual Computers
Definition of virtual computer
 Virtual machine is piece of software which simulates the actual machine environment. An
implementation of programming language require program in language are analysed and
then translated into a form that can be interpreter i.e. virtual machine first and then real
machine.
 For virtual machine environment the source program first translated into an intermediary
abstract from which is then interpretively executed.
 Example :- Java Virtual Machine (JVM)
Virtual Computers
 What is JVM?
 Java Virtual Machine (JVM) is a engine that
provides runtime environment to drive the Java
Code or applications. It converts Java bytecode
into machines language. JVM is a part of Java
Run Environment (JRE). In other programming
languages, the compiler produces machine code
for a particular system. However, Java compiler
produces code for a Virtual Machine known as
Java Virtual Machine.
 Here is how JVM works
First, Java code is complied into bytecode. This
bytecode gets interpreted on different machines
Between host system and Java source, Bytecode
is an intermediary language.
JVM in Java is responsible for allocating
memory space.
Binding Time
 Any program contain various entities such as variables, routines, control statements and so on.
 These entities have special properties called as attributes.
 Specifying the nature of attributes called as binding.
 The time at which the choice for binding occurs is called binding times.
 Although there is no simple categorization of the various types of bindings, a few main binding
times may be distinguished if we recall our basic assumption that the processing of a program,
regardless of the language, always involves a translation step followed by execution of the
translated program
Binding Time
1. Execution time (run time).
Many bindings are performed during program execution. These include bindings of variables to their values, as
well as (in many languages) the binding of variables to particular storage locations.
Two important subcategories may be distinguished:
 On entry to a subprogram or block.
In most languages, bindings are restricted to occur only at the time of entry to a subprogram or block during
execution
 At arbitrary points during execution.
Some bindings may occur at any point during execution of a program. The most important example here is the
basic binding of variables to values through assignment.
Binding Time
Binding Time
2. Translation time (compile time).
 Bindings chosen by the programmer.
In writing a program, the programmer consciously makes many decisions regarding choices of variable names,
types for variables, program statement structures, and so on, that represent bindings during translation.
 Bindings chosen by the translator.
Some bindings are chosen by the language translator without direct programmer specification.
How arrays are stored and how descriptors for the arrays are created are decisions made by the language ranslator.
 Bindings chosen by the loader.
A program usually consists of several subprograms that must be merged into a single executable program. The
translator typically binds variables to addresses within the storage designated for each subprogram.
Binding Time
3. Language implementation time.
 Some aspects of a language definition may be the same for all programs that are run using a particular
implementation of a language, but they may vary between implementations.
 A program written in the language that uses a feature whose definition has been fixed at implementation
time will not necessarily run on another implementation of the same language; even more troublesome, it
may run and give different results.
4. Language definition time.
 Most of the structure of a programming language is fixed at the time the language is defined, in the sense
of specification of the alternatives available to a programmer when writing a program.
 For example, the possible alternative statement forms, data structure types, program structures, and so on
are all often fixed at language definition time.
Binding Time
To illustrate the variety of bindings and binding times, consider the simple assignment statement
X = X + 10
written in a language L. We might inquire into the bindings and binding times of the following elements of this
statement:
1. Set of types for Variable X. : The set of allowable types for X is often fixed at language definition time (e.g.,
only types real, integer, Boolean, set, and character might be allowed).
2. Type of variable X. : The particular data type associated with variable X is often fixed at translation time.
3. Set of possible values for variable X. : If X has data type real, then its value at any point during execution is
one of a set of bit sequences representing real numbers.
4. Value of Variable X. : At any point during program execution, a particular value is bound to Variable X. This
value is determined at execution time through assignment of a value to X.
5. Representation of the constant 10. : The integer 10 has both a representation as a constant in the text of the
program, using the string 10, and a representation at execution time, commonly as a sequence of bits.
6. Properties of the operator +. :The choice of symbol + to represent the addition operation is made at language
definition time.
Binding Time
 Paradigm can also be termed as method to
solve some problem or do some task.
 Programming paradigm is an approach to solve
problem using some programming language or
also we can say it is a method to solve a problem
using tools and techniques that are available to
us following some approach.
 There are lots for programming language that
are known but all of them need to follow some
strategy when they are implemented and this
methodology/strategy is paradigms.
Introduction of Programming Paradigms
Introduction of Programming Paradigms
What is Declarative Programming?
 Declarative programming can be explained using a real-world scenario.
 Assume that the user needs to check for new emails. One method is by enabling the inbox notifications. The
user has to enable the notifications only once, and each time a new email arrives, he gets a notification
automatically. Declarative programming is similar to that.
 It provides simplicity.
 Declarative programming expresses what required result is. It explains the logic of a computation without
describing the control flow.
What is Imperative Programming?
 Imperative programming can be explained using a real-world scenario as before.
 To check the new emails, the user can login to gmail and keep refreshing the page to check whether he got
new emails or not.
 This is similar to imperative programming.
 It explains each and every step involved to achieve the result.
 It uses statements to express the changes in the program state.
Introduction of Programming Paradigms
Introduction of Programming Paradigms
1. Procedural Programming
 Procedural programming can also be referred to as imperative programming.
 It is a programming paradigm based upon the concept of procedure calls, in which statements are
structured into procedures (also known as subroutines or functions).
 They are a list of instructions to tell the computer what to do step by step, Procedural programming
languages are known as top-down languages.
 Most of the early programming languages are all procedural.
Introduction of Programming Paradigms
Introduction of Programming Paradigms
Introduction of Programming Paradigms
Features of Procedural Code
 Procedural Programming is excellent for general-purpose programming.
 The coded simplicity along with ease of implementation of compilers and interpreters.
 A large variety of books and online course material available on tested algorithms, making it easier to learn.
 The source code is portable.
 The code can be reused in different parts of the program, without the need to copy it.
 The program flow can be tracked easily as it has a top-down approach.
Introduction of Programming Paradigms
2. Object-Oriented Programming
 In this framework, all real-world entities are represented by Classes.
 Objects are instances of classes so each object encapsulates a state and behavior.
 State implies the fields, attributes of the object and behavior is what you do with the state of the
object and they are the methods.
 Objects interact with each other by passing messages.
Introduction of Programming Paradigms
Introduction of Programming Paradigms
Features of OO
 Encapsulation – This is a fundamental feature of Object-Oriented Programming. Here you hide unnecessary
details in classes and deliver a simple and clear interface for working. It describes the idea of bundling data
and methods that work on that data within one unit. This concept is also often used to hide the internal
representation, or state, of an object from the outside
 Inheritance - Inheritance is one of the core concepts of object-oriented programming (OOP) languages. It is a
mechanism where you can derive a class from another class for a hierarchy of classes that share a set of
attributes and methods. It explains how the class hierarchies develop code readability and support to the reuse
of functionality.
 Data Abstraction - to Data abstraction is the reduction of a particular body of data to a simplified
representation of the whole. Data abstraction is usually the first step in database design.
 Polymorphism - Polymorphism is an object-oriented programming concept that refers to the ability of a
variable, function or object to take on multiple forms.
Introduction of Programming Paradigms
3. Functional Programming
 The functional programming paradigms has its roots in mathematics and it is language independent.
 The key principal of this paradigms is the execution of series of mathematical functions.
 The central model for the abstraction is the function which are meant for some specific computation and not
the data structure. Data are loosely coupled to functions.
 The function hide their implementation. Function can be replaced with their values without changing the
meaning of the program. Some of the languages like perl, javascript mostly uses this paradigm.
Introduction of Programming Paradigms
Introduction of Programming Paradigms
•Pure functions – As seen above, if the input is an array, the output will be a new array and the input array will not be
modified. So in case of pure functions, the output depends only on the input.
•Recursion-A recursive function is a function that calls itself during its execution. This enables the function to repeat
itself several times, the result being outputted at the end of each iteration.
•Referential transparency-An expression is said to be referentially transparent if it can be replaced with its
corresponding value without changing the program's behavior. As a result, evaluating a referentially transparent function
gives the same value for fixed arguments. In functional programming, only referentially transparent functions are
considered. They are a lot easier to read and understand.
•Variables are Immutable-In functional programming you cannot modify a variable after it has been initialized. You
can create new variables and this helps to maintain state throughout the runtime of a program.
•Functions are First-Class and can be Higher-Order-A programming language is said to have First-class functions
when functions in that language are treated like any other variable. For example, in such a language, a function can be
passed as an argument to other functions, can be returned by another function and can be assigned as a value to a
variable. Higher-order functions are functions that take at least one first-class function as a parameter.
Features of Functional Programming
Introduction of Programming Paradigms
 It can be termed as abstract model of computation.
 It would solve logical problems like puzzles, series etc.
 In logic programming we have a knowledge base which we know before and along with the question and
knowledge base which is given to machine, it produces result.
 In normal programming languages, such concept of knowledge base is not available but while using the
concept of artificial intelligence, machine learning we have some models like Perception model which is
using the same mechanism.
 In logical programming the main emphasize is on knowledge base and the problem. The execution of the
program is very much like proof of mathematical statement, e.g., Prolog
4. Logic programming paradigms
Introduction of Programming Paradigms
Features of Logical Programming
 Logical programming can be used to express knowledge in a way that does not depend on the
implementation, making programs more flexible, compressed and understandable.
 It enables knowledge to be separated from use, i.e. the machine architecture can be changed without changing
programs or their underlying code.
 It can be altered and extended in natural ways to support special forms of knowledge, such as meta-level of
higher-order knowledge.
 It can be used in non-computational disciplines relying on reasoning and precise means of expression.

More Related Content

PPTX
programming.pptx
PDF
sege.pdf
PDF
Introduction to computer programming
PPTX
EVALUTION OF COMPUTER LANGAGES
PPTX
Computer Languages & its genearations.pptx
PPTX
Lec21&22.pptx programing language and there study
PPTX
INTRODUCTION TO COMPUTER PROGRAMMING.pptx
PPTX
COM 113 INTRO TO COMPUTER PROGRAMMING-PRT2.pptx
programming.pptx
sege.pdf
Introduction to computer programming
EVALUTION OF COMPUTER LANGAGES
Computer Languages & its genearations.pptx
Lec21&22.pptx programing language and there study
INTRODUCTION TO COMPUTER PROGRAMMING.pptx
COM 113 INTRO TO COMPUTER PROGRAMMING-PRT2.pptx

Similar to PPL_Unit01 for the insem study first year.pptx (20)

PPT
Introduction Programming Languages
PPTX
Programming languages,compiler,interpreter,softwares
PPT
English de lenguaje de programacion
PPT
Lect 1. introduction to programming languages
PPTX
Computer language
PPTX
Lesson 2.pptx
PPTX
Intro to programming languages by 4.pptx
PPTX
Python Programming-Skill Course - unit-i.pptx
PPTX
Programming languages.pptx
PPTX
Presentation-1.pptx
PPTX
Python-unit -I.pptx
PPT
software principle programming language
PPT
Python and principle of programming language.ppt
PPT
Programming Language Introduction Lecture
PPT
Programming Language Introduction Lecture
DOCX
Fundamentals of Programming language.docx
PPTX
Agro informatics centre up State of Lec 6.pptx
PPTX
Language processors
PPTX
week 2 - INTRO TO PROGRAMMING.pptx
PDF
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
Introduction Programming Languages
Programming languages,compiler,interpreter,softwares
English de lenguaje de programacion
Lect 1. introduction to programming languages
Computer language
Lesson 2.pptx
Intro to programming languages by 4.pptx
Python Programming-Skill Course - unit-i.pptx
Programming languages.pptx
Presentation-1.pptx
Python-unit -I.pptx
software principle programming language
Python and principle of programming language.ppt
Programming Language Introduction Lecture
Programming Language Introduction Lecture
Fundamentals of Programming language.docx
Agro informatics centre up State of Lec 6.pptx
Language processors
week 2 - INTRO TO PROGRAMMING.pptx
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
Ad

Recently uploaded (20)

PPTX
Internship_Presentation_Final engineering.pptx
PPTX
TE-AI-Unit VI notes using planning model
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Top 10 read articles In Managing Information Technology.pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
PDF
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
PPTX
Practice Questions on recent development part 1.pptx
PPTX
Chapter----five---Resource Recovery.pptx
PPTX
Security-Responsibilities-in-the-Cloud-Azure-Shared-Responsibility-Model.pptx
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PPTX
Glazing at Facade, functions, types of glazing
PPTX
Ship’s Structural Components.pptx 7.7 Mb
PPTX
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
Internship_Presentation_Final engineering.pptx
TE-AI-Unit VI notes using planning model
Lesson 3_Tessellation.pptx finite Mathematics
Top 10 read articles In Managing Information Technology.pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
Practice Questions on recent development part 1.pptx
Chapter----five---Resource Recovery.pptx
Security-Responsibilities-in-the-Cloud-Azure-Shared-Responsibility-Model.pptx
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
Glazing at Facade, functions, types of glazing
Ship’s Structural Components.pptx 7.7 Mb
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
6th International Conference on Artificial Intelligence and Machine Learning ...
Ad

PPL_Unit01 for the insem study first year.pptx

  • 2. Fundamentals of Programming • Importance of Studying Programming Languages • History of Programming Languages • Impact of Programming Paradigms • Role of Programming Languages • Programming Environments • Impact of Machine Architectures 1. The operation of a computer 2. Virtual Computers and Binding Times • Programming paradigms • Introduction to four main Programming paradigms 1. Procedural 2. Object oriented 3. Functional 4. Logic and rule based.
  • 3. Importance of Studying Programming Language 1. To improve your ability to develop effective algorithms • Many languages provide features, that when used properly, are of benefit to the programmer but, when used improperly, may waste large amounts of computer time or lead the programmer into time-consuming logical errors • Even a programmer who has used a language for years may not understand all of its features • A typical example is recursion—a handy programming feature that, when properly used, allows the direct implementation of elegant and efficient algorithms. When used improperly, it may cause an astronomical increase in execution time
  • 4. Importance of Studying Programming Language 2. To improve your use of your existing programming language • By understanding how features in your language are implemented, you greatly increase your ability to write efficient programs • For example, understanding how data such as arrays, strings, lists, or records are created and manipulated by your language, knowing the implementation details of recursion, or understanding how object classes are built allows you to build more efficient programs consisting of such components.
  • 5. Importance of Studying Programming Language 3. To increase your vocabulary of useful programming constructs • By studying the constructs provided by a wide range of languages, a programmer increases his programming vocabulary. • The understanding of implementation techniques is particularly important because, to use a construct while programming in a language that does not provide it directly, the programmer must provide an implementation of the construct in terms of the primitive elements actually provided by the language languages provide a coroutine feature directly
  • 6. Importance of Studying Programming Language 4. To allow a better choice of programming language • A knowledge of a variety of languages may allow the choice of just the right language for a particular project, thereby reducing the required coding effort. • Applications requiring numerical calculations can be easily designed in languages like C, FORTRAN, or Ada • Developing applications useful in decision making, such as in artificial- intelligence applications, would be more easily written in LISP, ML, or Prolog. • Internet applications are more readily designed using Perl and Java. Knowledge of the basic features of each language's strengths and weaknesses gives the programmer a broader choice of alternatives
  • 7. Importance of Studying Programming Language 5. To make it easier to learn a new language • a thorough knowledge of a variety of programming language constructs and implementation techniques allows the programmer to learn a new programming language more easily when the need arises. 6. To make it easier to design a new language • A designer of a user interface for a large program such as a text editor, an operating system, or a graphics package must be concerned with many of the same issues that are present in the design of a general-purpose programming language • Many new languages are based on C or Pascal as implementation models. This aspect of program design is often simplified if the programmer is familiar with a variety of constructs and implementation methods from ordinary programming languages.
  • 8. A brief history of programming languages
  • 9. Software Evolution 9 Fig: Layers of Computer Software Machine Language Assembly Language Procedure Oriented Language Object Oriented Language 1 / 0
  • 10. 10 Levels of Programming Languages High-level program class Triangle { ... float surface() return b*h/2; } Low-level program LOAD r1,b LOAD r2,h MUL r1,r2 DIV r1,#2 RET Executable Machine code 000100100100010100100100111011 0010101101001...
  • 12. 00000000 00000100 0000000000000000 01011110 00001100110000100000000000000010 11101111 000101100000000000000101 11101111 10011110 0000000000001011 11111000 10101101 11011111 0000000000010010 0110001011011111 0000000000010101 11101111 00000010 11111011 0000000000010111 11110100 1010110111011111 0000000000011110 0000001110100010 11011111 0000000000100001 11101111 00000010 11111011 0000000000100100 01111110 11110100 10101101 11111000 10101110110001010000000000101011 0000011010100010 11111011 0000000000110001 11101111 00000010 11111011 0000000000110100 00000100 0000000000111101 00000100 0000000000111101 Program in machine language 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • 13. 13 Levels of Programming Languages High-level program class Triangle { ... float surface() return b*h/2; } Low-level program LOAD r1,b LOAD r2,h MUL r1,r2 DIV r1,#2 RET Executable Machine code 000100100100010100100100111011 0010101101001...
  • 15. 00000000 00000100 0000000000000000 01011110 00001100110000100000000000000010 11101111 000101100000000000000101 11101111 10011110 0000000000001011 11111000 10101101 11011111 0000000000010010 0110001011011111 0000000000010101 11101111 00000010 11111011 0000000000010111 11110100 1010110111011111 0000000000011110 0000001110100010 11011111 0000000000100001 11101111 00000010 11111011 0000000000100100 01111110 11110100 10101101 11111000 10101110110001010000000000101011 0000011010100010 11111011 0000000000110001 11101111 00000010 11111011 0000000000110100 00000100 0000000000111101 00000100 0000000000111101 Program in machine language 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • 16. The only language understood by a computer is machine language. Note:
  • 17. Entry main, ^m<r2> subl2 #12,sp jsb C$MAIN_ARGS movab $CHAR_STRING_CON pushal -8(fp) pushal (r2) calls #2,read pushal -12(fp) pushal 3(r2) calls #2,read mull3 -8(fp),-12(fp),- pushal 6(r2) calls #2,print clrl r0 ret Program in symbolic language 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • 18. Symbolic languages • Assembly language is a symbolic language. • An assembler is used to translate symbolic code into machine language.
  • 19. /* This program reads two integer numbers from the keyboard and prints their product. */ #include <iostream.h> int main (void) { // Local Declarations int number1; int number2; int result; // Statements cin >> number1; cin >> number2; result = number1 * number2; cout << result; return 0; } // main Program in C++ language 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  • 20. • High-level language is a computer language which can be understood by the users. • The high-level language is very similar to human languages and has a set of grammar rules that are used to make instructions more easily. • Every high-level language has a set of predefined words known as Keywords and a set of rules known as Syntax to create instructions. • The high-level language is easier to understand for the users but the computer can not understand it. • High-level language needs to be converted into the low-level language to make it understandable by the computer. • We use Compiler or interpreter to convert high-level language to low-level language. • Languages like FORTRAN,C, C++, JAVA, Python, etc., are examples of high-level languages. • All these programming languages use human-understandable language like English to write program instructions. • These instructions are converted to low-level language by the compiler or interperter so that it can be understood by the computer. • g++ main.cpp High-level language
  • 21. Assembly language • Middle-level language is a computer language in which the instructions are created using symbols such as letters, digits and special characters. • Assembly language is an example of middle-level language. In assembly language, we use predefined words called mnemonics. • Binary code instructions in low-level language are replaced with mnemonics and operands in middle-level language. • But the computer cannot understand mnemonics, so we use a translator called Assembler to translate mnemonics into machine language. • Assembler is a translator which takes assembly code as input and produces machine code as output. • That means, the computer cannot understand middle-level language, so it needs to be translated into a low-level language to make it understandable by the computer. • Assembler is used to translate middle-level language into low-level language. • g++ -S main.cpp -o main.s
  • 22. Low-level language • It requires an assembler that would translate instructions • It is not portable • It is difficult to understand. • Low-Level language is the only language which can be understood by the computer. • Low-level language is also known as Machine Language. • The machine language contains only two symbols 1 & 0. • All the instructions of machine language are written in the form of binary numbers 1's & 0's. • A computer can directly understand the machine language.
  • 23. ASSEMBLY LEVEL LANGUAGE HIGH-LEVEL LANGUAGE It needs an assembler for conversion It needs a compiler/interpreter for conversion In this, we convert an Assembly level language to machine level language In this, we convert a high-level language to Assembly level language to machine level language It is machine dependent It is machine-independent In this mnemonics, codes are used In this English statement is used It supports low-level operation It does not support low-level language In this, it is easy to access hardware component In this, it is difficult to access hardware component In this more compact code No compactness
  • 25. Pioneers of programming • Charles Babbage: Invented the Analytical Engine. His companion, Ada Augusta Lovelace, is considered the first programmer in history. • Konrad Zuse: Designed Plankalkül. This notation (never implemented) has features than can be found in many existing programming languages.
  • 26. Very low-level languages • Those are machine languages and assembly languages, machine-dependent coding systems. They were initially fully binary, and then symbolic. • There is one native machine language, and usually one assembly language per processor model. • Upward compatibility can be a nightmare. Was moving from 386 to 486 painless? From 486 to Pentium?
  • 27. Fortran • Fortran was originally developed by IBM in the 1950s for scientific and engineering applications, and subsequently came to dominate scientific computing. • It has been in use for over six decades in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, geophysics, computational physics, crystallography and computational chemistry. It is a popular language for high-performance computing and is used for programs that benchmark and rank the world's fastest supercomputers.
  • 28. Fortran • Fortran was the first effectively implemented high-level language that introduced variables as we know them now, loops, procedures, statement labels and much more. • The earliest versions of Fortran had many unique features, often awkward, later kept along for compatibility. It is still widely used in engineering applications that require much array manipulation. • The newest version, Fortran 90, has converged toward other popular programming languages.
  • 29. Algol 60 • It was the first to have block structure, recursion, and a formal definition. It is not used now, but it is the ancestor of most contemporary languages. • As far as design goes, Algol 60 was without doubt the most important innovation in the history of programming languages (so far ).
  • 30. CSI 3125, History, page 30 Cobol • Business-oriented computations • very strict program organization • poor control structures • elaborate data structures, record type introduced for the first time. Used to be very popular in business and government, much less at universities. • Revived for a while during the Y2K scare—why?
  • 31. PL/I • A combination of features believed (at the time) best in Fortran, Algol 60, Cobol. • the first language designed to be completely general, good for all possible applications • actively promoted by IBM • not used much today. • An interesting feature introduced in PL/I: event handling.
  • 32. Basic Beginners' All-purpose Symbolic Instruction Code • Is a family of general-purpose, high-level programming languages • The original version was designed by John G. Kemeny and Thomas E. Kurtz and released at Dartmouth College in 1964 • The first in history language of personal computing. • The first programming language for many programmers: designed to be easy to learn. • Very simple, limited, though still general-purpose. • Present-day versions of Basic are full-fledged languages—not "basic", and not easy to learn any more.
  • 33. CSI 3125, History, page 33 Simula 67 • Simula is the name of two simulation programming languages, Simula I and Simula 67, developed in the 1960s at the Norwegian Computing Center in Oslo, by Ole-Johan Dahl and Kristen Nygaard. ... Simula is considered the first object-oriented programming language. • An extension of Algol 60 designed for simulation of concurrent processes. • Introduced the central concepts of object orientation: classes and encapsulation. • Predecessor of Smalltalk and C++. • Now unused.
  • 34. Algol 68 • ALGOL 68 (short for Algorithmic Language 1968) is an imperative programming language that was conceived as a successor to the ALGOL 60 programming language, designed with the goal of a much wider scope of application and more rigorously defined syntax and semantics. • Imperative programming is a programming paradigm that uses statements that change a program's state • A very elegant design, unmatched till today. • Full orthogonality. • Extremely difficult to implement. • A very clever formal description, unfortunately hard to understand for most potential users. • Completely unused.
  • 35. Pascal • A conceptually simplified and cleaned-up successor of Algol 60. • A great language for teaching structured programming. • An excellent first language to learn: teaches good programming habits. • Its later extensions (for example, Delphi) are full-fledged systems programming packages, as powerful as any Java kit.
  • 36. Modula-2 • A better, conceptually uniform successor of Pascal. • Mechanisms to program concurrency (many processes running in parallel). • Not used as much as it deserves. • Its successors, Modula-3 and Oberon, are even more conceptually appealing, practically useful—and almost not used at all. (They lost the popularity contest with C++.)
  • 37. Ada • The result of an elaborate, multi-stage design process, and a more successful attempt at generality than PL/I. • Completely standard: there can be no dialects (like Java, except that Microsoft...). • There are, however, two standards: Ada 83 (the original), and Ada 95. • Ada has been designed to support concurrency in a very neat, systematic way.
  • 38. C-language • The implementation language of Unix. • A great tool for systems programming and a software development language on personal computers. • Once fashionable, still in use, but usually superseded by C++. • Dangerous if not used properly: not recommended to novice programmers. • Relatively low-level.
  • 39. Lisp • One of the earliest programming languages. • Based on the concept of computing by evaluating functions. Very good for symbolic computing. • For years, the only language for Artificial Intelligence work. (Prolog is 12 years younger.) • Many dialects, two standards (Scheme, Common Lisp). Nice programming environments. • Lisp's successors are very elegant (Miranda, ML, Haskell) but not nearly as widely used.
  • 40. Prolog • A very high-level programming language. • Declarative, based on a subset of logic, with proofs interpreted as computation. • Very powerful: • Non-deterministic (built-in backtracking). • Elaborate, flexible pattern matching. • Associative memory. • Pattern-directed procedure invocation. • In skilled hands, it is a very strong tool.
  • 41. Smalltalk • It is the purest object-oriented language ever designed (till now), cleaner than Java, much cleaner than C++. • Comes complete with a graphical interface and an integrated programming environment. • In skilled hands, a powerful tool.
  • 42. C++ • An object-oriented extension of the imperative language C. • This is a hybrid design, with object orientation added to a completely different base language. • Complicated syntax, difficult semantics. • Very fashionable, very much in demand. • Java did not (yet?) push it out.
  • 43. Java • A neat, cleaned up, sized-down reworking of C++. • Full object orientation (though not as consistent as Smalltalk) • Designed for Internet programming, but general-purpose. • It is said (not quite correctly) to be slow. • New fashion: maybe the next de-facto standard?
  • 44. Scripting languages • Text processing: • Perl • Python • Web programming • JavaScript • PHP
  • 46. Role of Programming Languages Just like natural languages, programming languages evolve and eventually pass out of use. Algol from 1960 is no longer used, replaced by Pascal, which in turn is being replaced by CH—I- and Java. COBOL use is dropping for business applications, also being replaced by C++. APL, PL/I, and SNOBOL4, all from the 1960s, and Pascal from the 1970s have all but disappeared. The older languages still in use have undergone periodic revisions to reflect changing influences from other areas of computing. Newer languages like C++, Java, and ML reflect a composite of experience gained in the design and use of these and the hundreds of other older languages. Some of these influences include the following:
  • 47. Influences 1. Computer capabilities. 2. Applications. 3. Programming methods. 4. Implementation methods. 5. Theoretical studies. 6. Standardization.
  • 48. Attributes of a Good Language 1. Clarity, simplicity, and unity. A programming language provides both a conceptual framework for thinking about algorithms and a means of expressing those algorithms. The language should be an aid to the programmer long before the actual coding stage. It should provide a clear, simple, and unified set of concepts that can be used as primitives in developing algorithms. 2. Orthogonality. • The term orthogonality refers to the attribute of being able to combine various features of a language in all possible combinations, with every combination being meaningful. • When the features of a language are orthogonal, the language is easier to learn and programs are easier to write because there are fewer exceptions and special cases to remember.
  • 49. Attributes of a Good Language 3. Naturalness for the application. A language needs a syntax that, when properly used, allows the program structure to reflect the underlying logical structure of the algorithm. Ideally, it should be possible to translate such a program design directly into appropriate program statements that reflect the structure of the algorithm. Sequential algorithms, concurrent algorithms, logic algorithms, and others all have differing natural structures that are represented by programs in those languages. 4. Support for abstraction. • Even with the most natural programming language for an application, there is always a substantial gap remaining between the abstract data structures and operations that characterize the solution to a problem and the particular primitive data structures and operations built into a language. • Ideally, the language should allow data structures, data types, and operations to be defined and maintained as self-contained abstractions. The programmer may use them in other parts of the program knowing only their abstract properties without concern for the details of their implementation.
  • 50. Attributes of a Good Language 5. Ease of program verification. • The reliability of programs written in a language is always a central concern. There are many techniques for verifying that a program correctly performs its required function. • A language that makes program verification difficult may be far more troublesome to use than one that supports and simplifies verification, even though the former may provide many more features that superficially appear to make programming easier. 6. Programming environment. • The availability of a reliable, efficient, and well-documented implementation of the language must head the list. • Special editors and testing packages tailored to the language may greatly speed the creation and testing of programs. • Facilities for maintaining and modifying multiple versions of a program may make working with large programs much simpler.
  • 51. Attributes of a Good Language 7. Portability of programs. • One important criterion for many programming projects is the transportability of the resulting programs from the computer on which they are developed to other computer systems • A language that is widely available and whose definition is independent of the features of a particular machine forms a useful base for the production of transportable programs. 8. Cost of use. Cost is certainly a major element in the evaluation of any programming language, but cost means many different things: (a) Cost of program execution. (b) Cost of program translation. (c) Cost of program creation, testing, and use. (d) Cost of program maintenance.
  • 53. Programming Environments • A programming environment is the collection of tools used in the development of software • This collection may consist of only a file system, a text editor, a linker, and a compiler. • Text editor is software that is used to write computer program. Ex Notepad, text editor. • The conversion of program text file into binary format you need software called compiler
  • 55. THE OPERATION OF A COMPUTER • A computer is an integrated set of algorithms and data structures capable of storing and executing programs. • A computer may be constructed as an actual physical device using wires, integrated circuits, circuit boards, and the like, in which case it is termed an actual computer or hardware computer. • It may also be constructed via software by programs running on another computer, in which case it is a software-simulated computer. • A programming language is implemented by construction of a translator, which translates programs in the language into machine language programs that can be directly executed by some computer. • The computer that executes the translated programs may either be a hardware computer or a partially of software.
  • 56. THE OPERATION OF A COMPUTER Organization of a conventional computer. • A main memory contains programs and data to be processed. • Processing is performed by an interpreter, which takes each machine language instruction in turn, decodes it, and calls the designated primitive operation with the designated operands as input. • The primitives manipulate the data in main memory and in high-speed registers and also may transmit programs or data between memory and the external operating environment.
  • 57. THE OPERATION OF A COMPUTER Organization of a conventional computer. A computer consists of six major components that correspond closely to the major aspects of a programming language:  Data  Primitive Operations  Sequence Control  Data Access  Storage Management  Operating Environment
  • 58. THE OPERATION OF A COMPUTER Organization of a conventional computer. 1. Data. Three major data storage components: main memory, high-speed registers, and external files. Main memory is usually organized as a linear sequence of bits subdivided into fixed-length words (typically 32 or 64 bits) or 8-bit bytes (typically 4 or 8 bytes per word). The high-speed registers consist of word-length bit sequences and may have special subfields that are directly accessible. The contents of a register may represent data or the address in main memory containing the data or next instruction. External files, stored on magnetic disk, magnetic tape, or CD-ROM,
  • 59. THE OPERATION OF A COMPUTER Organization of a conventional computer. 2. Operations. A computer must contain a set of built-in primitive operations, usually paired one to one with the operation codes that may appear in machine language instructions. Primitives for arithmetic e.g., real and integer addition, subtraction, multiplication, and division Primitives for testing various properties of data items e.g., test for zero, positive and negative numbers Primitives for accessing and modifying various parts of a data item e.g., retrieve or store a character in a word and retrieve or store an operand address in an instruction Primitives for controlling input-output (I/O) devices Primitives for sequence control e.g., unconditional and return jumps.
  • 60. THE OPERATION OF A COMPUTER Organization of a conventional computer. 3. Sequence control . • The control of execution of the operations, both primitive and user defined, is termed as sequence control. • The interpreter is central to the operation of a computer. Typically, the interpreter executes the simple cyclic algorithm • During each cycle, the interpreter gets the address of the next instruction from the program address register (and increments the register value to be the next instruction address)
  • 61. THE OPERATION OF A COMPUTER Organization of a conventional computer. 4. Data access. • Typically an operand might be in main memory or in a register. • the result of a primitive operation must be stored in some designated location. • We term these facilities the data access control of the computer. • The conventional scheme is to simply associate integer addresses with memory locations and provide operations for retrieving the contents of a location given its address.
  • 62. THE OPERATION OF A COMPUTER Organization of a conventional computer. 5. Storage management. To balance the internal speed of a microprocessor and the speed of a disk appropriately, various storage management facilities are employed. For speeding up the imbalance between main memory and the central processor, a cache memory is used. A cache memory is a small high-speed data storage that is between main memory and the central processor. A cache allows the computer to operate as if the main memory had essentially the same speed as the central processor.
  • 63. THE OPERATION OF A COMPUTER Organization of a conventional computer. 6. Operating environment. The operating environment of a computer ordinarily consists of a set of peripheral storage and I/O devices. These devices represent the outside world to the computer, and any communication with the computer must be by way of the operating environment. Often there are hardware distinctions between various classes of devices in the environment based on differences in use or speed of access e.g., high-speed storage [extended memories], medium- speed storage [magnetic disks, CD-ROM], low- speed storage [tapes], and I/O devices [readers, printers, displays, data communication lines].
  • 64. Alternative computer architectures von Neumann architecture. The von Neumann computer is named after the mathematician John von Neumann, who developed this initial design in the early 1940s as part of the design of ENIAC, which was one of the first electronic computers. A computer, in his design, consisted of a small controlling central processing unit (CPU) consisting of the primitive operations, sequence control and registers for storing the results of the primitive operations, a larger main memory, and a process for retrieving and storing words of data between the CPU and larger memory.
  • 65. Alternative computer architectures Multiprocessors. As we just discussed, one problem with the von Neumann design is the great imbalance in the slow speed of external data devices and the high speed of the CPU registers. An alternative approach toward this imbalance is the use of multiple CPUs in a given system. Such multiprocessing systems have been in use for over 30 years. By coupling several relatively inexpensive CPUs with single sets of memory, disks, tapes, and so on, an effective system can be designed. The operating system runs different programs on different CPUs in the system and overall performance is improved.
  • 67. Language Implementations 1. Translation (or compilation). A translator could be designed to translate programs in the high-level language into equivalent programs in the machine language of the actual computer. • An assembler is a translator whose object language is also some variety of machine language for an actual computer but whose source language, an assembly language, represents for the most part a symbolic representation of the object machine code. • A compiler is a translator whose source language is a high-level language and whose object language is close to the machine language of an actual computer, either being an assembly language or some variety of machine language. • A loader or link editor is a translator whose object language is actual machine code and whose source language is almost identical; it usually consists of machine language programs in relocatable form together with tables of data specifying points, where the relocatable code must be modified to become truly executable. • A preprocessor or a macroprocessor is a translator whose source language is an extended form of some high- level language such as C++ or Java and whose object language is the standard form of the same language.
  • 68. Language Implementations 2. Software simulation (software interpretation). • Rather than translating the high-level language programs into equivalent machine-language programs, we might instead simulate, through programs running on another host computer, a computer whose machine language is the high-level language. • To do this, we construct a set of programs in the machine language of the host computer that represent the algorithms (and data structures) necessary for the execution of programs in the high-level language. • The main simulator program performs an interpretation algorithm decoding and executing each statement of the input program in the appropriate sequence and producing the specified output from the program. • we say that the host computer creates a virtual machine simulating the high-level language. When the host computer is executing the high-level program, it is not possible to tell whether the program is being executed directly by the hardware or is first converted to the low-level machine language of the hardware computer.
  • 69. Virtual Computers Definition of virtual computer  Virtual machine is piece of software which simulates the actual machine environment. An implementation of programming language require program in language are analysed and then translated into a form that can be interpreter i.e. virtual machine first and then real machine.  For virtual machine environment the source program first translated into an intermediary abstract from which is then interpretively executed.  Example :- Java Virtual Machine (JVM)
  • 70. Virtual Computers  What is JVM?  Java Virtual Machine (JVM) is a engine that provides runtime environment to drive the Java Code or applications. It converts Java bytecode into machines language. JVM is a part of Java Run Environment (JRE). In other programming languages, the compiler produces machine code for a particular system. However, Java compiler produces code for a Virtual Machine known as Java Virtual Machine.  Here is how JVM works First, Java code is complied into bytecode. This bytecode gets interpreted on different machines Between host system and Java source, Bytecode is an intermediary language. JVM in Java is responsible for allocating memory space.
  • 71. Binding Time  Any program contain various entities such as variables, routines, control statements and so on.  These entities have special properties called as attributes.  Specifying the nature of attributes called as binding.  The time at which the choice for binding occurs is called binding times.  Although there is no simple categorization of the various types of bindings, a few main binding times may be distinguished if we recall our basic assumption that the processing of a program, regardless of the language, always involves a translation step followed by execution of the translated program
  • 73. 1. Execution time (run time). Many bindings are performed during program execution. These include bindings of variables to their values, as well as (in many languages) the binding of variables to particular storage locations. Two important subcategories may be distinguished:  On entry to a subprogram or block. In most languages, bindings are restricted to occur only at the time of entry to a subprogram or block during execution  At arbitrary points during execution. Some bindings may occur at any point during execution of a program. The most important example here is the basic binding of variables to values through assignment. Binding Time
  • 74. Binding Time 2. Translation time (compile time).  Bindings chosen by the programmer. In writing a program, the programmer consciously makes many decisions regarding choices of variable names, types for variables, program statement structures, and so on, that represent bindings during translation.  Bindings chosen by the translator. Some bindings are chosen by the language translator without direct programmer specification. How arrays are stored and how descriptors for the arrays are created are decisions made by the language ranslator.  Bindings chosen by the loader. A program usually consists of several subprograms that must be merged into a single executable program. The translator typically binds variables to addresses within the storage designated for each subprogram.
  • 75. Binding Time 3. Language implementation time.  Some aspects of a language definition may be the same for all programs that are run using a particular implementation of a language, but they may vary between implementations.  A program written in the language that uses a feature whose definition has been fixed at implementation time will not necessarily run on another implementation of the same language; even more troublesome, it may run and give different results. 4. Language definition time.  Most of the structure of a programming language is fixed at the time the language is defined, in the sense of specification of the alternatives available to a programmer when writing a program.  For example, the possible alternative statement forms, data structure types, program structures, and so on are all often fixed at language definition time.
  • 76. Binding Time To illustrate the variety of bindings and binding times, consider the simple assignment statement X = X + 10 written in a language L. We might inquire into the bindings and binding times of the following elements of this statement: 1. Set of types for Variable X. : The set of allowable types for X is often fixed at language definition time (e.g., only types real, integer, Boolean, set, and character might be allowed). 2. Type of variable X. : The particular data type associated with variable X is often fixed at translation time. 3. Set of possible values for variable X. : If X has data type real, then its value at any point during execution is one of a set of bit sequences representing real numbers. 4. Value of Variable X. : At any point during program execution, a particular value is bound to Variable X. This value is determined at execution time through assignment of a value to X. 5. Representation of the constant 10. : The integer 10 has both a representation as a constant in the text of the program, using the string 10, and a representation at execution time, commonly as a sequence of bits. 6. Properties of the operator +. :The choice of symbol + to represent the addition operation is made at language definition time.
  • 78.  Paradigm can also be termed as method to solve some problem or do some task.  Programming paradigm is an approach to solve problem using some programming language or also we can say it is a method to solve a problem using tools and techniques that are available to us following some approach.  There are lots for programming language that are known but all of them need to follow some strategy when they are implemented and this methodology/strategy is paradigms. Introduction of Programming Paradigms
  • 79. Introduction of Programming Paradigms What is Declarative Programming?  Declarative programming can be explained using a real-world scenario.  Assume that the user needs to check for new emails. One method is by enabling the inbox notifications. The user has to enable the notifications only once, and each time a new email arrives, he gets a notification automatically. Declarative programming is similar to that.  It provides simplicity.  Declarative programming expresses what required result is. It explains the logic of a computation without describing the control flow.
  • 80. What is Imperative Programming?  Imperative programming can be explained using a real-world scenario as before.  To check the new emails, the user can login to gmail and keep refreshing the page to check whether he got new emails or not.  This is similar to imperative programming.  It explains each and every step involved to achieve the result.  It uses statements to express the changes in the program state. Introduction of Programming Paradigms
  • 82. 1. Procedural Programming  Procedural programming can also be referred to as imperative programming.  It is a programming paradigm based upon the concept of procedure calls, in which statements are structured into procedures (also known as subroutines or functions).  They are a list of instructions to tell the computer what to do step by step, Procedural programming languages are known as top-down languages.  Most of the early programming languages are all procedural. Introduction of Programming Paradigms
  • 84. Introduction of Programming Paradigms Features of Procedural Code  Procedural Programming is excellent for general-purpose programming.  The coded simplicity along with ease of implementation of compilers and interpreters.  A large variety of books and online course material available on tested algorithms, making it easier to learn.  The source code is portable.  The code can be reused in different parts of the program, without the need to copy it.  The program flow can be tracked easily as it has a top-down approach.
  • 85. Introduction of Programming Paradigms 2. Object-Oriented Programming  In this framework, all real-world entities are represented by Classes.  Objects are instances of classes so each object encapsulates a state and behavior.  State implies the fields, attributes of the object and behavior is what you do with the state of the object and they are the methods.  Objects interact with each other by passing messages.
  • 87. Introduction of Programming Paradigms Features of OO  Encapsulation – This is a fundamental feature of Object-Oriented Programming. Here you hide unnecessary details in classes and deliver a simple and clear interface for working. It describes the idea of bundling data and methods that work on that data within one unit. This concept is also often used to hide the internal representation, or state, of an object from the outside  Inheritance - Inheritance is one of the core concepts of object-oriented programming (OOP) languages. It is a mechanism where you can derive a class from another class for a hierarchy of classes that share a set of attributes and methods. It explains how the class hierarchies develop code readability and support to the reuse of functionality.  Data Abstraction - to Data abstraction is the reduction of a particular body of data to a simplified representation of the whole. Data abstraction is usually the first step in database design.  Polymorphism - Polymorphism is an object-oriented programming concept that refers to the ability of a variable, function or object to take on multiple forms.
  • 88. Introduction of Programming Paradigms 3. Functional Programming  The functional programming paradigms has its roots in mathematics and it is language independent.  The key principal of this paradigms is the execution of series of mathematical functions.  The central model for the abstraction is the function which are meant for some specific computation and not the data structure. Data are loosely coupled to functions.  The function hide their implementation. Function can be replaced with their values without changing the meaning of the program. Some of the languages like perl, javascript mostly uses this paradigm.
  • 90. Introduction of Programming Paradigms •Pure functions – As seen above, if the input is an array, the output will be a new array and the input array will not be modified. So in case of pure functions, the output depends only on the input. •Recursion-A recursive function is a function that calls itself during its execution. This enables the function to repeat itself several times, the result being outputted at the end of each iteration. •Referential transparency-An expression is said to be referentially transparent if it can be replaced with its corresponding value without changing the program's behavior. As a result, evaluating a referentially transparent function gives the same value for fixed arguments. In functional programming, only referentially transparent functions are considered. They are a lot easier to read and understand. •Variables are Immutable-In functional programming you cannot modify a variable after it has been initialized. You can create new variables and this helps to maintain state throughout the runtime of a program. •Functions are First-Class and can be Higher-Order-A programming language is said to have First-class functions when functions in that language are treated like any other variable. For example, in such a language, a function can be passed as an argument to other functions, can be returned by another function and can be assigned as a value to a variable. Higher-order functions are functions that take at least one first-class function as a parameter. Features of Functional Programming
  • 91. Introduction of Programming Paradigms  It can be termed as abstract model of computation.  It would solve logical problems like puzzles, series etc.  In logic programming we have a knowledge base which we know before and along with the question and knowledge base which is given to machine, it produces result.  In normal programming languages, such concept of knowledge base is not available but while using the concept of artificial intelligence, machine learning we have some models like Perception model which is using the same mechanism.  In logical programming the main emphasize is on knowledge base and the problem. The execution of the program is very much like proof of mathematical statement, e.g., Prolog 4. Logic programming paradigms
  • 92. Introduction of Programming Paradigms Features of Logical Programming  Logical programming can be used to express knowledge in a way that does not depend on the implementation, making programs more flexible, compressed and understandable.  It enables knowledge to be separated from use, i.e. the machine architecture can be changed without changing programs or their underlying code.  It can be altered and extended in natural ways to support special forms of knowledge, such as meta-level of higher-order knowledge.  It can be used in non-computational disciplines relying on reasoning and precise means of expression.