Sinhgad College of Engineering
Vadgaon Bk. Pune
Approved by AICTE New Delhi Recognized by Govt. of Maharashtra
Affiliated to Savitribai Phule Pune University
Accredited by NAAC with A+ Grade
Subject:- 210255: Principles of Programming Languages
Unit-1 Fundamentals of Programming.
1
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 2
Contents:
1 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: The operation of a computer, Virtual
Computers and Binding Times.
• Programming paradigms- Introduction to programming paradigms,
Introduction to four main Programming paradigms- procedural,
object oriented, functional, and logic and rule based.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 3
UNIT-1
FUNDAMENTALS OF PROGRAMMING
1.1 Importance of Studying Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 4
• Following are the reasons for studying the programming language concepts.
1) Increased capacity to express ideas
2) Improved background for choosing appropriate language:
3) Increased ability to learn a new language.
4) Better Understanding of significance of implementation.
5) Better use of languages that are already known.
1.1 Importance of Studying Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 5
• Following are the reasons for studying the programming language concepts.
1) Increased capacity to express ideas
• The study of different programming languages makes the programmer with variety of
programming constructs.
• In this study, programmer can understand various data structures, control structures abstractions
and their ability.
2) Improved background for choosing appropriate language:
• By the knowledge of various programming languages , one can be aware of its variety of
features.
• Hence while developing a software application programmer can make appropriate selection of the
languages whose feature are most applicable.
1.1 Importance of Studying Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 6
3) Increased ability to learn a new language.
• Due to knowledge of programming constructs and implementations techniques programmer can
learn new language easily.
4) Better understanding of significance of implementation:
• By learning and understanding different languages , programmer can know the reasons behind
the language design .
5) Better use of languages that are already known:
• By studying the concepts of programming languages programmer can learn about previously
unknown and unused parts of the languages they already use and begin to use those features.
1.2 History of Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 7
1) Scientific applications:
• The scientific application require large number of floating point computations.
• It typically makes use of arrays.
• The programming Language used is- Fortran.
2) Business Applications:
• It requires use of decimal number and character data. It also need s an ability to specify decimal
arithmetic operations.
• The programming language preferred for building the business applications is COBOL.
1.2 History of Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 8
3) Systems Programming:
• System programs communicate and coordinate the activities and functions of hardware and
software of a system and also controls the operations of the hardware.
• The general programming languages such as C, C++ are usually preferred for system
programming.
4) Web Software:
• The world wide web software is used to represent some dynamic web contents
representation of text audio or video data, contents containing some computations and so
on.
• A web application (web app) is an application program that is stored on a remote
server and delivered over the internet through a browser interface.
1.3 Attribute of Good Languages
UNIT-III Polymorphism
Department Of Computer Engineering
06-10-2021 9
1) Simplicity & Clarity:
• Few languages such as Basic, Algol, and Pascal in the past were purposely created to
simplify clarify of expression. Basic, for example, had a very small instruction set.
• Algol 60 had a publication language that supports a standard structure for typesetting
programs that occurred in published journal articles. Pascal was specially created as a
teaching language, with features that simplified the teaching and learning of structured
programming principles.
2) Readability:
• An essential principle for determining a programming language is the ease with which
the programs can be read and learn. Therefore, a good programming language must
consider readability in the context of the problem domain.
1.3 Attribute of Good Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 10
3) Writability:
• Writability is a part of how easily a language can be used to generate a program for the
chosen issue domain.
• Some language features that influence readability also influence writability.
4) Abstraction:
• Abstraction is an important element of the program design process. Programmers give
Multiple time-building abstractions, both data abstractions, and procedural abstractions,
to apply the reuse of code and prevent recreating it.
• A good programming language provides data and procedural abstraction so that it is a
preferred design tool in the programming phase.
1.3 Attribute of Good Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 11
5) Cost of use − Cost is exactly a major component in the computation of any programming
language,
• but the cost defines some different things such as cost of program execution, cost of
program translation, cost of program creation, testing, use, and cost of program
maintenance.
6) Programming Environment:
• The technical architecture of a programming language is only one method of moving its
service.
• The presence of a suitable programming environment can create a technically unsteady
language simpler to work with than a powerful language that has little external support.
1.4 Role of Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 12
1.4.1 Evolution of Major Programming Languages:
FORTRAN-I:
• It is designed for new IBM 704 ,which had index registers and floating point hardware.
FORTRAN-II:
• It was distributed in 1958.
• Independent Compilation was supported for FORTRAN-II
Functional Programming: LISP :
• It is list Processing Language.
• This language is used in the research of AI.
COBOL:
• The first macro facility in a high level language.
• It has support for hierarchical data structure.
• It contain nested selection statements.
1.4 Role of Programming Languages
UNIT-III Polymorphism
Department Of Computer Engineering
06-10-2021 13
BASIC
• It is easy to use and learn.
PASCAL:
• It is designed initially for teaching structured programming.
• It was small simple and easy to learn.
Python
• Python is one of the most widely used user-friendly programming languages.
• It is an open-source and easy to learn programming language developed in the 1990s. It is mostly
used in Machine learning, Artificial intelligence, Big Data, GUI based desktop applications, and
Robotics.
1.4 Role of Programming Languages
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 14
C:
• C is a powerful general-purpose programming language.
• It can be used to develop software like operating systems, databases, compilers, and so on.
• C programming is an excellent language to learn to program for beginners.
C++:
• C++ is a powerful general-purpose programming language.
• It can be used to develop operating systems, browsers, games, and so on.
• C++ supports different ways of programming like procedural, object-oriented, functional, and so on.
Java:
• Java is a simple, secure, platform-independent, reliable, architecture-neutral high-level programming
language developed by Sun Microsystems in 1995.
• Now, Java is owned by Oracle. It is mainly used to develop bank, retail, information technology,
android, big data, research community, web, and desktop applications.
1.5 Programming Environments
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 15
• Programming environments is an environment in which the programs can be created and
tested.
• Programming environment consists of a collection of support tools that are used in software
Development.
• These Tools are editors, debuggers, verifiers, data generator and so on.
1.5 Programming Environments
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 16
1.5.1 Effect on Language Design.
• The programming Environment influences on language design in two major areas namely
separate compilation and testing debugging.
• Separate Compilation.
• Testing Debugging.
1.5 Programming Environments
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 17
• Separate Compilation:
In the structure of any huge program it is regularly desirable to have multiple programmers
or programming group design, code, and test elements of the program before the last
assembly of all the elements into a complete program.
• Testing and debugging −
Testing is the process using which we find errors and bugs. Debugging is the process using
which we correct the bugs that we found during the testing process.
Execution trace features −
Prolog, LISP, and some other interactive languages support features that enable specific
statements and variables to be identified for detection during execution.
Breakpoints − In an interactive programming environment, languages provide a feature
where the programmer can determine points in the program as breakpoints.
1.5 Programming Environments
1.5.2 Environment Framework.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 18
• A framework in programming is a tool that provides ready-made components or solutions
that are customized in order to speed up development.
• A framework can include support programs, compilers, code libraries, toolsets, and APIs to
develop software and create systems. Open-source frameworks are always being updated
and improved.
1.5 Programming Environments
1.5.2 Environment Framework.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 19
• Environment framework is nothing but the collection of infrastructure services that can be
used for program development purpose.
• These services are data repository , Graphical user interface, security, communication
services.
• Borland JBuilder is a programming environment that provides integrated compiler ,
editor, and debugger for java development.
• The modern programming environment makes use of Visual Studio .Net for developing the
applications using C# Visual Basic .Net , Jscript, J# and so on.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 20
1.6.1 Operation of computer.
• Working of any computer is based on the software present it. The software contains
collection of programs.
• These programs are created using suitable programming languages.
• A computer consists of six major components that are associated with the programming
languages.
Data
Primitive operations
Sequence Control
Data Access
Storage management
Operating Environment.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 21
Data:
• In any programming Language there are variety of data items and data structure.
• The built in Data types can be directly manipulated by hardware primitive operations. Such
built in data types integer, floating point number, double, and strings.
Primitive operations :
• A computer contains a set of built in primitive operations such as addition, substraction ,
multiplication and division.
Sequence Control:
• Computer must provide the mechanism for controlling the flow of execution of
programming instruction . This mechanism is called as sequence control.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 22
Data Access:
• Computer provide a controlling mechanism for supplying data for execution of
programming instruction. This mechanism is called data access.
Storage management:
• Computer provides the mechanism for controlling the storage for programs and data
resources.
Operating Environment.:
• The operating environment consists of peripheral storage and I/O devices.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 23
1.6.3 Interpreter & Compiler.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 24
1.6.4 Early Binding & Late Binding.
• Early Binding.
It happens at compile time.
It is more efficient
Compiler knows at the time of compiling what type object it is.
Compile time polymorphism is known as early binding.
Early Binding makes application is faster.
• Late Binding.
It happens at run time.
It is more flexible
Compiler doesn’t knows at the time of compiling what type object it is.
Runtime polymorphism is known as late binding.
Late Binding makes application is slower.
1.6 Impact of Machine Architecture.
1.6.2 Virtual computer.
• Definition of Virtual Computer: Virtual Machine is a piece of software which simulates the
actual environment.
• For virtual machine environment the source program is translated into an intermediary
abstract form which is then interpretively executed.
Source
Program
Lexical analyzer Syntax analyzer Type checker
06-10-2021
Input
Abstract
Syntax
Lexical analyzer
output
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
Computer
25
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 26
• In this case , the source program first goes through stages such as lexical analyzer, syntax
analyzer, and type checker.
• Then the abstract syntax obtained from these three phases is interpreted to get translated
output.
For example – java virtual machine is kind of virtual machine which plays an
important role in achieving the platform independence.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 27
• 1.6.3 Binding and Binding Times
• Association of method call to the method body is known as binding. There are two types of
binding: Static Binding that happens at compile time and Dynamic Binding that happens at
runtime.
• Any program contain various entities such as variable , routines , control statement and so
on . These entities have special properties. These properties are called attributes.
• For example The programming entity parameter routine or function has number of
parameter , type of parameter , parameter passing method and so on.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 28
Language Definition Time
Language Implementation
Time
Translation Time Execution Time
Classes of Binding Times
• Classes of Binding Times
on entry
of subprogram
At arbitrary
points
by
programmer
by
Translator
by
Loader
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 29
• Types of and Binding Times
• There are two types of binding times which are as follows −
Execution Time (Run-Time) − Some bindings are implemented during program execution.
These contain bindings of variables to their values, and the binding of variables to specific
storage areas. The property of runtime bindings are as follows −
• On entry to a subprogram or block − In some languages, bindings are limited to
appear only at the time of entry to a subprogram or block during execution.
• At arbitrary points during execution − Some bindings can appear at any point during
the execution of a program.
1.6 Impact of Machine Architecture.
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 30
• Translation time (compile-time) − There are three different types of translation time
bindings are as follows −
• Bindings have been chosen by the programmer − In writing a program, the programmer
consciously produces some decisions concerning choices of variable names, types for
variables, program statement structures, etc. that describe bindings during translation. The
language translator creates the use of these bindings to decide the final structure of the
object code.
• Bindings chosen by the translator − Some bindings are selected by the language
translator without a direct programmer requirement.
• Bindings chosen by the loader − A program generally includes multiple subprograms that
should be combined into a single executable program.
1.7 Programming Paradigms
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 31
• Definition: Paradigm can also be termed as method to solve some problem or do some
task.
Various types of Programming paradigm are-
1. Imperative or procedural programming.
2. Object Oriented programming.
3. Functional Programming.
4. Logic Programming.
1.7 Programming Paradigms
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 32
• Examples of various programming languages based on the above mentioned paradigm is as
shown by following table.
1.7 Programming Paradigms
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 33
• Imperative : Machine-model based.
• It is based on commands that update variables in storage.
The Latin word imperare means “to command”.
• The imperative programming is also called as procedural
Programming language.
• The central features of this language are variables,
assignment statements, and iterations.
Example of imperative programming are- C, Pascal, Ada,
Fortran and so on.
1.7 Programming Paradigms
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 34
• OOP : Programming with Data Types
• In this language everything is modeled as object.
Hence is the name.
• This language has a modular programming approach in
Which data and function are bound in entity called class.
• This programming approach paradigm has gained a
great popularity in recent years because of its characteristic
features such as data abstraction, encapsulation, inheritance,
Polymorphism and so on.
Examples of Object Oriented Programming languages are-
C++, Java.
1.7 Programming Paradigms
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 35
• Functional Programming: Equations; Expression Evaluation..
• In this paradigm we express computations as the evaluation of mathematical functions.
• Functional programming paradigms treat values
as single entities. Unlike variables, values are
never modified. Instead, values are transformed into
new values.
• Computations of functional languages are performed
largely through applying functions to values,
i.e., (+ 4 5).
Examples of function programming are LISP, ML, Haskell,
1.7 Programming Paradigms
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 36
• Logic Programming: First-order Logic Deduction..
• In this paradigm we express computations in the term of mathematical Logic only. It is also
called as ruled based programming approach.
• Rules are specified in no special order.
• It supports for declarative programming approach.
Examples of Logic programming is prolog,
UNIT-I Fundamentals of Programming
Department Of Computer Engineering
06-10-2021 37
1. Explain the importance of studying programming language.
2. Explain the evolution of Major Programming Languages.
3. What are the attributes of Good Language?
4. What is programming environment? Explain the effect of programming environment on language
design.
5. What is programming paradigms? Explain the primitive programming paradigms along with its
merits and demerits.
6. Explain various classes of binding times.
7. Explain the effect of programming environment on language design in brief.
8. Explain the concept of environment framework in programming environment.
9. What is the difference between compiler and interpreter?
10. Explain the concept of virtual computer.
11. Explain various classes of binding times.
12. What is the difference between early binding and late binding?
13. Explain the programming paradigm in detail?
14. List the programming paradigm. For any three state which programming languages are based on
them and law?
Frequently Asked Questions.