0% found this document useful (0 votes)
16 views

Unit-1 Lecture - 1

The document provides an overview of programming languages, detailing their definitions, evolution, and classifications from first to fifth generation languages. It discusses the software development process, including the software development life cycle (SDLC), and highlights key programming concepts such as syntax, semantics, and various paradigms. Additionally, it covers essential programming language qualities, error handling, memory management, and the components of computer architecture based on the Von-Neumann model.

Uploaded by

kbtug23531
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Unit-1 Lecture - 1

The document provides an overview of programming languages, detailing their definitions, evolution, and classifications from first to fifth generation languages. It discusses the software development process, including the software development life cycle (SDLC), and highlights key programming concepts such as syntax, semantics, and various paradigms. Additionally, it covers essential programming language qualities, error handling, memory management, and the components of computer architecture based on the Von-Neumann model.

Uploaded by

kbtug23531
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 87

Prof. M. V.

Malode
Department Computer

Maratha Vidya Prasarak Samaj’s


Karmaveer Adv. Baburao Ganpatrao
Thakare College of Engineering
Nashik Maharashtra, India
Unit – 1: Fundamentals of Programming

Discuss the principles underlying the programming


languages

CO 1
What is a programming language
What is a programming language
• A programming language is a set of rules that provides a
way of telling a computer what operations to perform.
• A programming language is a set of rules for
communicating an algorithm.
• A programming language is a notational system for
describing computation in a machine-readable and
human-readable form.
• A programming language is a tool for developing
executable models for a class of problem domains
Contd.
• English is a natural language. It has words, symbols and
grammatical rules.
• A programming language also has words, symbols and rules of
grammar.
• The grammatical rules are called syntax.
• Each programming language has a different set of syntax rules.
Why there are so Much Languages?
Why there are so Much Languages?
• Programming languages have evolved over time as better ways
have been developed to design them.
• First programming languages were developed in the 1950s.
• Since then thousands of languages have been developed

• Different programming languages are designed for different types


of programs.
Levels of Programming Languages.
Types of Programming Languages
• First Generation Languages
• Second Generation Languages
• Third Generation Languages
• Fourth Generation Languages
• Fifth Generation Languages
First Generation Language.

Machine language
• Machine language is a low-level language made up of
binary numbers or bits that a computer can understand.
• Machine language is machine dependent as it is the
only language the computer can understand.
• Very efficient code but very difficult to write.
Second Generations Languages
Assembly languages
• A low-level language that helps to communicate directly
with computer hardware.
• It uses mnemonics to represent the operations that a
processor has to do.
• Very efficient code and easier to write.
Working of Assembly Code
1. Assembly languages contain mnemonic codes that
specify what the processor should do.
2. The mnemonic code that was written by the programmer
was converted into machine language (binary language)
for execution.
3. An assembler is used to convert assembly code into
machine language.
4. That machine code is stored in an executable file for the
sake of execution.
Third Generations Languages
•Closer to English but included simple mathematical notation.
•Programs written in source code which must be translated
into machine language programs called object code.
•The translation of source code to object code is
accomplished by a machine language system program
called a compiler.
•Common third generation languages
◦ FORTRAN
◦ COBOL
◦ C and C++
◦ Visual Basic
Fourth Generations Languages
• A high level language (4GL) that requires fewer instructions to
accomplish a task than a third generation language.
• Fourth generation languages are commonly used in database
programming and scripts examples
include Perl, PHP, Python, Ruby, and SQL.
• Used with databases
◦ Query languages
◦ Report generators
◦ Forms designers
◦ Application generators
Fifth Generations Languages

•These are the programming languages that have visual


tools to develop a program.
•Examples of fifth generation language include Mercury,
OPS5, and Prolog(Based on mathematical logic, Rule-
or Constraint-based).
•fifth-generation languages are designed to make the
computer solve a given problem without the
programmer.
Beyond Fifth Generations Languages
• Though no clear definition at present, natural language programs
generally can be interpreted and executed by the computer with
no other action by the user than stating their question.
• Limited capabilities at present.
Identify the generation ?
Identify the generation ?
Identify the generation ?
Identify the generation ?
Identify the generation ?
Software development process
• From inception of an idea for a software system until it is
implemented and delivered to a customer, and even after that,
the software undergoes different gradual development and
evolution. The software is said to have life cycle composed of
different phases.
SDLC Model
• "The Waterfall" approach, the whole process of software
development is divided into separate phases. In this Waterfall
model, typically, the outcome of one phase acts as the input for
the next phase sequentially.
Roles of Programming languages
Defining Syntax and Semantics
Syntax refers to the rules that define the structure or
form of statements in a programming language,
including how keywords, operators, and symbols.
Semantics refers to the meaning behind the
syntax—what happens when a program is executed.
Language Paradigms
Programming languages embody various programming paradigms, which are ways of
thinking about and organizing software development. Some of the most common paradigms
include:
● Imperative Programming:
● Functional Programming:
● Object-Oriented Programming (OOP):
● Logic Programming:
Abstraction Mechanism

Programming languages serve as tools for abstraction by offering


higher-level constructs (e.g., functions, classes, modules) that allow
developers to manage complexity in large systems.
4, Data Types and Data Structures
Programming languages provide a variety of data types (e.g., integers, strings, booleans) and
structures (e.g., arrays, lists, trees) that allow developers to store and manipulate data.
Role: A programming language defines and supports various data types and structures, making it
possible to design and implement algorithms and manage data effectively.

5. Control Flow
Control flow mechanisms (e.g., loops, conditionals, function calls) are core to defining how a
program executes. The structure of control flow allows a program to make decisions, repeat tasks,
and manage the execution path.

6. Error Handling and Exceptions


Error handling mechanisms are essential to ensuring programs can manage runtime issues (e.g.,
invalid input, memory overflows). Different languages provide varying approaches to error
detection and recovery, such as exception handling in languages like Java or Python.
7. Modularity and Reusability
Modularity is the principle of breaking down a program into smaller, manageable parts (modules or
functions). A language’s support for modularity enables better organization of code and fosters reusability.

8. Memory Management
Memory management is an essential aspect of programming language design. Some languages require
manual memory management (e.g., C), while others provide automatic memory management (e.g., garbage
collection in Java, Python).

9. Concurrency and Parallelism


With the rise of multi-core processors, many programming languages now provide support for concurrency
and parallelism, allowing multiple tasks to run simultaneously. Languages like Go, Java, and Python provide
constructs for handling concurrent operations.

10. TypeCasting System


Type casting is the process of converting one data type into another. There are two main types of type
casting: widening (automatic) and narrowing (manual).
Criteria in good language design
•Writability
•Readability
•Orthogonality
•Reliability
•Maintainability
•Extensibility
•Standardability
•Implementability
Writability

❖ Writability refers to the ease with which code can be written in a particular
language. A language with good writability has a concise syntax,
easy-to-remember keywords and constructs, and powerful abstractions that
make it easy to express complex ideas.
Readability

• Coding should be simple and clear to understand.


• Readability refers to how easy it is to read and understand code
written in a particular language. A language with good readability
has a syntax that is easy to comprehend, uses meaningful naming
conventions, and has well-structured code.
Orthogonality
• This means relatively small set of primitive constructs can be
combine.
For ex., int *count; Here pointer and integer is combined.
Reliability
● Reliability refers to the ability of a language to produce
consistent and predictable results, even in the presence of
errors and unforeseen circumstances.
● Program will not behave in unexpected way during
execution.
○ Type Checking
○ Exception Handling
○ Aliasing: It is same memory location (variable) having more
than one name. Which is causes confusion.
Maintainability

• The ease with which code can be modified and updated over
time. A language that is easy to maintain allows developers to
make changes and fix issues more quickly and efficiently.
Security

The ability of a language to protect against potential


security threats, such as hacking or data breaches. A
secure language reduces the risk of sensitive data being
compromised or stolen.
Extensibility
A language that allows the user to add features to it.
• Example: the ability to define new data types and new operations
(functions or procedures)
• Example: new releases that extend the built-in features of the
language
Standardability
The quality of Language that allows programs written to be
transported from one place(System) to another without significant
change in language structure.
Efficiency
Performance: The language should provide mechanisms to
write efficient code in terms of both time (execution speed) and
space (memory usage).

Portability
Cross-Platform Support: The language should ideally be able to
run on multiple platforms without requiring significant changes to
the code.
Environment Independence: A good language should not be tied
to a particular operating system or hardware platform.
Programming Languages qualities

• Programming language is a tool for development of software.


• Quality of language is related to quality of software.
• Software must be reliable.
• Software must be maintainable.
• Software must execute efficiently
Languages and reliability
• Writibility
Easier it is to concentrate on problem solving activity, the less error prone is program
writing.
• Readabilty
Provision of specific constructs to define new operations, which keeps the definition
of such concepts separate from rest of the program that may use them, enhances
readability greatly.
• Simplicity
can be achieved by minimizing feature of a language, but it reduces power of the
languages( eg; pascal is simple but less powerful than C++).
• Safety
Avoid goto statements an pointers variables, but it reduces the power
• Robustness
Ability to deal with undesired events(invalid input,arithmetic overflow).
Languages and maintainability

• Readability and simplicity.


• Factoring/Grouping.
• Use of recursion.
• Constant to be given symbolic names.(pi instead of 3.14)
Languages and efficiency.
• Not only measure by execution speed and space.
• Effort required to produce a program and efforts in maintenance
can also be viewed as components of the efficiency.
• Should be reusable.
• Should be portable.
History of Programming language
History of Programming language
History of Programming language
Programming - Environment
It simply indicates a base on top of which we can do our
programming.
We need to have the required software setup, i.e., installation on our
PC which will be used to write computer programs, compile, and
execute them.(Eg: Internet Browsing)
The following setup is required to start with programming using any
programming language.
A text editor to create computer programs.
A compiler to compile the programs into binary format.
An interpreter to execute the programs directly.
Text Editor
• A text editor is a software that is used to write computer programs.
• Your Windows machine must have a Notepad, which can be used to
type programs.
• other good editors are Notepad++, which is freely available.
• If Mac user, then you will have TextEdit
• For Linux, there is texteditor
Compiler
The computer cannot understand your program
directly given in the text format(programming
language), so we need to convert this program in
a binary format(machine language), which can
be understood by the computer.
The conversion from text program to binary file is
done by another software called Compiler and
this process of conversion from text formatted
program to binary format file is called program
compilation.
Interpreter

There are programming languages such as


Python, PHP, and Perl, which do not need
any compilation into binary format, rather
an interpreter can be used to read such
programs line by line and execute them
directly without any further conversion.
Von-Neumann Model
• Von-Neumann proposed his computer architecture design in 1945 which
was later known as Von-Neumann Architecture.
• It consisted of a Control Unit, Arithmetic, and Logical Memory Unit (ALU),
Registers and Inputs/Outputs.
• A Von Neumann-based computer:
Uses a single processor
Uses one memory for both instructions and data.
Executes programs following the fetch-decode-execute cycle
Components of Von-Neumann Model

• Central Processing Unit


• Buses
• Memory Unit
Central Processing Unit

• The part of the Computer that performs the bulk of data


processing operations is called the Central Processing Unit and is
referred to as the CPU.
• The CPU performs a variety of functions dictated by the type of
instructions that are incorporated in the computer.
• The major components of CPU are Arithmetic and Logic Unit
(ALU), Control Unit (CU) and a variety of registers.
Arithmetic and Logic Unit (ALU)
The Arithmetic and Logic Unit (ALU) performs the required
micro-operations for executing the instructions. In simple words, ALU
allows arithmetic (add, subtract, etc.) and logic (AND, OR, NOT, etc.)
operations to be carried out.
Control Unit
The Control Unit of a computer system controls the operations of
components like ALU, memory and input/output devices.
The Control Unit consists of a program counter that contains the
address of the instructions to be fetched and an instruction register
into which instructions are fetched from memory for execution.
Registers
Registers refer to high-speed storage areas in the CPU. The data
processed by the CPU are fetched from the registers.
Program Counter (PC)
● Function: The Program Counter (PC) holds the address of the next instruction to be fetched from memory.

2. Current Instruction Register (CIR)


● Function: The Current Instruction Register (CIR) holds the instruction that is currently being executed. Once the
instruction is fetched from memory, it is placed in the CIR for decoding and execution.

3. Accumulator (AC)
● Function: The Accumulator (AC) is a special-purpose register that temporarily holds the results of computations
performed by the Arithmetic Logic Unit (ALU).

4. Memory Address Register (MAR)


● Function: The Memory Address Register (MAR) holds the address in memory where data is to be read from or
written to.

5. Memory Data Register (MDR)


● Function: The Memory Data Register (MDR) holds the data that is either read from memory or is about to be written
to memory.
Buses
• Buses are the means by which information is shared between
the registers in a multiple-register configuration system.
• A bus structure consists of a set of common lines, one for
each bit of a register, through which binary information is
transferred one at a time. Control signals determine which
register is selected by the bus during each particular register
transfer.
• There are three major bus systems for data transfer.
Memory Unit
• A memory unit is a collection of storage cells together with
associated circuits needed to transfer information in and out of
the storage. The memory stores binary information in groups of
bits called words. The internal structure of a memory unit is
specified by the number of words it contains and the number of
bits in each word.
• Two major types of memories are used in computer systems:
RAM (Random Access Memory)
ROM (Read-Only Memory)
Introduction to Computers Basic Operations

There are five basic types of computer operations: Inputting, processing, outputting, storing, and
controlling.
Input
Input is whatever goes into the computer. Input can take a variety of forms,
from commands you enter by keyboard to data from another computer (via a
network connection) or device (via direct or network connection). A device that
feeds data into a computer, such as a keyboard or mouse, is called an input
device.
Output

Output is any information (data) that comes out of a computer. Output


devices can be other computers, display screens, speakers, and printers.
Storage
• Computer data storage is referred to as storage or memory, which can save
digital data. Examples are RAM, hard disks, CDs, DVDs and removable flash
memory sticks.
• Permanent, or non-volatile, storage devices do not require power to
remember the data stored. Mass storage devices, like your hard disk, are
non-volatile; a loss of power does not affect their ability to retain data. This
category also include ROM (Read Only Memory).
• Temporary or volatile storage is more often called "memory". A loss of power
means that any data stored will be lost irretrievably. When you are using an
application, such as a word processor, the data (the document you are
working on) is stored in RAM (Random Access Memory). If you lose power
without explicitly saving your work, you will likely lose data.
Processing
• The processor is the brain of a computer. It's also called the CPU (Central
processing unit) and it is a microchip. For a non-programmer, this is where all
the real action is. Programs just set the stage and direct the play. (In this off
hand analogy, the play itself, in written form, would be most like a program.)
• The processor actually performs very simple operations like basic arithmetic
and comparing two values (but that may be like saying a stage actor just
speaks, moves and emotes).
• Despite it's apparent simplicity, the CPU does in fact run the show, controlling
all of the peripherals while executing the current software commands.
Virtual Computers

the Virtual Computer is "a software emulation of a physical computing


environment". Virtual Computers are also knows as virtual machines. Task of
the virtual computer is to provide one or more simultaneous execution
environments in which operating systems or other programs may execute.
Introduction of Programming Paradigms

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.
Imperative programming paradigm
1. It is one of the oldest programming paradigm.
2. The program describes steps that change the state of the computer.
3. Imperative programming explicitly tells the computer "how" to accomplish a
program.
4. To make programs simpler for a human to read and write, imperative statements
can be grouped into sections known as code blocks.
5. Program's code into blocks was first implemented in the ALGOL programming
language.
Disadvantage:
Complex problem cannot be solved
Less efficient and less productive

Advantage:
Very simple to implement
It contains loops, variables etc.

Examples of Imperative programming paradigm:


C : developed by Dennis Ritchie and Ken Thompson
Fortan : developed by John Backus for IBM
Basic : developed by John G Kemeny and Thomas E Kurtz

Imperative programming is divided into three broad categories: Procedural, OOP and
parallel processing.
Procedural programming paradigm
This paradigm emphasizes on procedure in terms of under lying machine model.
There is no difference in between procedural and imperative approach. It has the
ability to reuse the code and it was boon at that time when it was in use because of
its reusability.
Examples of Procedural programming paradigm:
C : developed by Dennis Ritchie and Ken Thompson
C++ : developed by Bjarne Stroustrup
Java : developed by James Gosling at Sun Microsystems
ColdFusion : developed by J J Allaire
Pascal : developed by Niklaus Wirth
#include <iostream>
#include <stdio.h> using namespace std;
int main() {
int number1, number2, sum; int main()
printf("Enter two integers: "); {
scanf("%d %d", &number1, int firstNumber, secondNumber,
sumOfTwoNumbers;
&number2);
cout << "Enter two integers: ";
// calculating sum cin >> firstNumber >> secondNumber;
sum = number1 + number2; sumOfTwoNumbers
printf("%d + %d = %d", sumOfTwoNumbers = firstNumber +
number1, number2, sum); secondNumber;
return 0; cout << firstNumber << " + " << secondNumber
} << " = " << sumOfTwoNumbers;
return 0;
}

C Program C++ Program


Object oriented programming

The program is written as a collection of classes and object which are meant for
communication. The smallest and basic entity is object and all kind of computation is
performed on the objects only. More emphasis is on data rather procedure. It can handle
almost all kind of real life problems which are today in scenario.
Advantages:
• Data security
• Inheritance
• Code reusability
• Flexible and abstraction is also present
Examples of Object Oriented programming
paradigm
Simula : first OOP language
Java : developed by James Gosling at Sun Microsystems
C++ : developed by Bjarne Stroustrup
Objective-C : designed by Brad Cox
Visual Basic .NET : developed by Microsoft
Python : developed by Guido van Rossum
Ruby : developed by Yukihiro Matsumoto
Smalltalk : developed by Alan Kay, Dan Ingalls, Adele Goldberg
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]){


@autoreleasepool {
public class SumNatural {
int a, b;
public static void main(String[] args) {
int num = 100, sum = 0;
NSLog(@"Enter value for a:\n");
for(int i = 1; i <= num; ++i)
Printf(“Enter the value of a:”);
{
scanf("%i", &a);
// sum = sum + i;
sum += i;
NSLog(@"Enter value of b:\n");
}
scanf("%i", &b);
System.out.println("Sum = " + sum);
}
int sum = a + b;
}
NSLog(@"Sum of two numbers:\t%i\n", sum);
JAVA Program }
return 0;
}

Objective- C Program
Parallel processing approach

Parallel processing is the processing of program instructions by dividing them among multiple
processors. A parallel processing system posses many numbers of processor with the objective
of running a program in less time by dividing them. This approach seems to be like divide and
conquer. Examples are NESL (one of the oldest one) and C/C++ also supports because of some
library function(multithreading).

NESL is a parallel language developed at Carnegie Mellon by the SCandAL project. It integrates various
ideas from the theory community (parallel algorithms), the languages community (functional languages)
and the system's community (many of the implementation techniques).
2. Declarative programming paradigm

The programmer defines what needs to be accomplished by the program without


defining how it needs to be implemented.
Declarative programming describes a particular class of problems with language
implementation taking care of finding the solution.
This is the only difference between imperative (how to do) and declarative (what to do)
programming paradigms.
It is divided as Logic, Functional, Database.
Logic 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.
Languages that emphasize this paradigm: Prolog, GHC, Parlog, Vulcan, Polka, Mercury,
Fnil.
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
go:- write('Enter first number : '),read(X),nl,
write('Enter second number : '),read(Y),nl,
add(X,Y).
mul(X,Y):-
S is X+Y,
M is X*Y,
write('Addition is : '),write(S),nl,
write('Multiplication is : '),write(M).
% End of code
Functional programming paradigms

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 function hide their implementation.
Function can be replaced with their values without changing the meaning of the
program.
Some of the languages like javascript mostly uses this paradigm.
Function for computing the average of two numbers:

(defun avg(X Y) (/ (+ X Y) 2.0))

Function is called by:

> (avg 10.0 20.0)

Function returns:

15.0
Examples of Functional programming
paradigm:
JavaScript : developed by Brendan Eich
Haskwell : developed by Lennart Augustsson, Dave Barton
Scala : developed by Martin Odersky
Erlang : developed by Joe Armstrong, Robert Virding
Lisp : developed by John Mccarthy
ML(Meta language) : developed by Robin Milner
Clojure : developed by Rich Hickey
const num1 = parseInt(prompt('Enter the first number '));
main = do const num2 = parseInt(prompt('Enter the second number '));

let a = 10 //add two numbers


let b = 20 const sum = num1 + num2;

putStrLn "Sum of two // display the sum


console.log(`The sum of ${num1} and ${num2} is ${sum}`);
numbers is:"
print (a + b)

Javascript
Haskell
Database/Data driven programming
approach
This programming methodology is based on data and its movement. Program
statements are defined by data rather than hard-coding a series of steps. A database
program is the heart of a business information system and provides file creation, data
entry, update, query and reporting functions.
CREATE DATABASE databaseAddress;
CREATE TABLE Addr (
PersonID int,
LastName varchar(200),
FirstName varchar(200),
Address varchar(200),
City varchar(200),
State varchar(200)
);
Select * from Addr where City=“Nashik”;
THANK YOU

Maratha Vidya Prasarak Samaj’s Phone Number: 0253-2571439/ 0253-2582891 Email id: [email protected]
KBT College of Engineering Nashik Fax number: 0253-2317016 College website: http://kbtcoe.org
Udoji Maratha Boarding Campus, Gangapur Road,
Nashik-422013. Maharashtra India

You might also like