You are on page 1of 35

Lecture 1

An Introduction to Programming
Languages

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 1


This lesson includes:

o Software and Classification


o Programming Languages and Classification
o Language Translators
o Sample C programs

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 2


At a glance
 Hardware refers to physical devices of a computer
system.

 Software is a collection of programs – consists of


organized sets of electronic instructions that tell
computer how to do certain tasks and control the
computer as well.

 Program is a organized sequence of instructions


written in a language that can be understood by a
computer.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 3


Types of Software

Software

System Application
Software Software

Programming
Operating Communication
Language Utility Programs Horizontal Vertical
System Software
Translator

General OS Network OS

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 4


Types of Software
 The two most common types of programs are:
 System software and
 Application software.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 5


System Software
 System software is a set of programs designed to control
the operation and extend the processing capability of a
computer system.
 Basic types of system software are:
 Operating System
 General Purpose Operating System - DOS, Windows, Mac OS,
OS/2, Linux etc.
 Network Operating System - Windows NT, Novell NetWare, Linux,
Unix etc.
 Programming Language Translator - Compiler, Interpreter,
Assembler etc.
 Communication Software – Putty, FTP (File Transfer
Protocol), Terminal Emulator
 Utility Software - Backup utilities, Disk formatting,
4-May-19
Antivirus, Firewall, Intrusion detection, Screen savers etc.
Abu Ahmed Ferdaus, CSE, DU. 6
Application Software
 Application software is a set of one or more programs
designed to solve a specific problem, or do a specific task.
 Application software tells the computer how to accomplish
tasks the user requires. Examples:
 Payroll processing
 Examination result processing
 Inventory management
 Preparation of Income Tax return
 Creating a personal document
 Editing a graphic image

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 7


Application Software
 Some common application software are:
 Word processing programs (Microsoft Word)
 Spreadsheet software (Microsoft Excel)
 Database management Software (Oracle, DB2,
Microsoft SQL Server, MySQL)
 Presentation programs (Microsoft Power Point)
 Graphics programs (Adobe Photoshop, Adobe
Illustrator)
 Web design tools and browsers (IE, Opera, Mozilla
Firefox)
 Internet applications (E-mail: gmail, yahoo etc.)
 Communications programs (Skype, Instant Messaging,
Viber)
 Entertainment and education (Windows Media Player)
 Multimedia authoring (Digital movie with sound, video
and animation)
4-May-19 Abu Ahmed Ferdaus, CSE, DU. 8
What is a Programming Language?
 A language is a means of communication.
 A computer language is used by a programmer to
instruct a computer what he/she wants to do.
 A programming language is an artificial language
designed to communicate instructions to a
machine, particularly a computer.
 Programming languages can be used to create
programs that control the behavior of a machine
and/or to express algorithms precisely.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 9


Types of Programming Languages

Programming
Language

Machine Assembly Higher Level


Language Language Language

Third Fourth Fifth


Generation Generation Generation

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 10


The Evolution of Programming Languages
 To build programs, people use languages that are
similar to human language. The results are
translated into machine code, which computers
understand.
 Programming languages fall into three broad
categories:
 Machine languages
 Assembly languages

 High level languages

.
4-May-19 Abu Ahmed Ferdaus, CSE, DU. 11
Machine Languages
 Machine languages (first-generation languages) are
the most basic type of computer languages,
consisting strings of numbers the computer's
hardware can use.
 Written as combination of binary 1s and binary 0s.
 Only language of a computer understood by it
without using a translation program.
 Different types of hardware use different machine
code. For example, IBM computers use different
machine language than Apple computers.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 12


Machine Languages
 Advantage:
 Programs can be executed very fast by the computer

 Disadvantages:
 Machine dependent
 Difficult to program
 Error prone
 Difficult to modify

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 13


Assembly Languages
 Assembly languages (second-generation languages) are
only somewhat easier to work with than machine
languages.
 To create programs in assembly language, developers
use cryptic English-like phrases (MOV,CMP, SUB, J, JL,
RET) to represent strings of numbers.
 A language which allows instructions and storage
locations to be represented by letters and symbols
instead of just numbers.
 The code is then translated into object code, using a
translator called an assembler.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 14


Assembly Languages

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 15


Assembly
code

Assembler

Object code
Assembly Languages
 Advantages over machine language:
 Easier to understand and use
 Easier to locate and correct errors
 Easier to modify
 No worry about addresses
 Easily re-locatable
 Efficiency of machine language
 Disadvantages:
 Machine dependent
 Knowledge of hardware required
 Machine level coding

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 17


High Level Languages
 A computer programming language that resembles
natural Language.
 High level languages are more powerful than
assembly language and allow the programmer to
work in a more English-like environment.
 Higher-level programming languages are divided
into three "generations," each more powerful than
the last:
 Third-generation languages
 Fourth-generation languages
 Fifth-generation languages

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 18


High Level Languages
 Advantages:
 Machine independent
 Easier to learn, write and use
 Fewer errors during program development
 Requires less time
 Enabling programmers to write instructions using
English words and familiar mathematical symbols and
expressions
 Better documentation and easier to maintain
 Complex programs can be written easily
 Disadvantages:
 Lower execution efficiency
 Less flexibility to control the computer’s CPU,
4-May-19 memory and registers
Abu Ahmed Ferdaus, CSE, DU. 19
Third-Generation Languages
 Third-generation languages (3GLs) are the first to use
true English-like phrasing, making them easier to use
than previous languages.

 3GLs are portable, meaning the object code created for


one type of system can be translated for use on a
different type of system.
 The following languages are 3GLs:
 FORTAN C

 COBOL C++

 BASIC Java

 Pascal LISP
4-May-19 Abu Ahmed Ferdaus, CSE, DU. 20
Abbreviation of some Languages
 FORTRAN – FORmula TRANslation
 COBOL – COmmon Business Oriented Language
 BASIC – Beginner’s All-purpose Symbolic Instruction
Code
 LISP – LISt Processing
 RPG – Report Program Generator
 SNOBOL – StriNg Oriented SymBOlic Language

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 21


Fourth-Generation Languages
 Fourth-generation languages (4GLs) are even easier
to use than 3GLs.
 4GLs may use a text-based environment (like a 3GL)
or may allow the programmer to work in a visual
environment, using graphical tools.
 The following languages are 4GLs:
 Visual Basic (VB)
 SQL, PL/SQL (Procedural Language/SQL)
 MATLAB
 SPSS (Statistical Product and Service Solutions)

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 22


Fifth-Generation Languages
 Fifth-generation languages (5GLs) are an issue of
debate in the programming community – some
programmers do not agree that they even exist.
 These high-level languages would use artificial
intelligence to create software, making 5GLs
extremely difficult to develop.
 Fifth generation languages are currently being used
for neural networks. A neural network is a form of
artificial intelligence that attempts to imitate how the
human mind works.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 23


Language Translator
 Translator performs the action of interpretation of the
meaning of a text, and subsequent production of an
equivalent text, also called a translation, that
communicates the same message in another language.
 A computer can directly execute only machine language
program. To execute a program written in other
languages need to be translated into machine language.
Language translator is a program which performs this
task.
 So, translator translates a program written in a
programming language (Source Code) into a machine
understandable form (Object code).
 Example: Assembler, Compiler, Interpreter

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 24


Language Translator

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 25


Assembler

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 26


Compiler
 Normally high level programming languages (C, BASIC,
Java) are used to write computer programs because they
are easy to use.
 Compiler is a program that translates programs written
in high level language (source program) into machine
language (object program).
 It generates several machine language instructions for
each source statement i.e. one to many correspondence.
 It translates the whole program and then executes.
 A compiler can be written for different computers.
 Object programs are loaded into memory before
execution.
 C, Java use compiler.
4-May-19 Abu Ahmed Ferdaus, CSE, DU. 27
Compiler

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 28


Interpreter
 Also a high-level language translator program but
different from compilers.
 Does not generate object program.
 It translates and immediately executes each source
statement. Then the next one.
 It’s a kind of a debugging tool.
 Programmers can check the outcome of a source
statement immediately.
 Takes much longer to execute than compiler.
 Example: Visual Basic uses interpreter.

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 29


Interpreter

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 30


Comparison of Compiler and Interpreter
Compiler Interpreter

It prepares an object It translates and immediately


program from source executes each instruction of
program. the source program.

Debugging is complex and It is a debugging tool and is


time consuming. useful during program
development stage.

Lower execution time. Higher execution time.


Requires higher program Requires less program
development effort and development effort and time.
time.
4-May-19 Abu Ahmed Ferdaus, CSE, DU. 31
Sample 1: Printing a Text
#include <stdio.h>
int main()
{
/*Program to Display The Content*/
printf(“Good Morning..! Have a Nice Day”);
return 0;
}

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 32


Sample 2-V1: Adding Two Numbers
#include <stdio.h>
int main()
{
int a, b, c;
a = 5;
b = 7;
c = a + b;
printf("%d + %d = %d\n", a, b, c);
return 0;
}

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 33


Sample 2-V2: Adding Two Numbers
#include <stdio.h>
int main()
{
int a, b, c;
printf("Enter the first value:");
scanf("%d", &a);
printf("Enter the second value:");
scanf("%d", &b);
c = a + b;
printf("%d + %d = %d\n", a, b, c);
return 0;
}
4-May-19 Abu Ahmed Ferdaus, CSE, DU. 34
Thank You

4-May-19 Abu Ahmed Ferdaus, CSE, DU. 35

You might also like