You are on page 1of 18

Programming Languages

• A programming language is a set of rules that create a pathway to let a


computer know what the operator or programmer wants to do with it.
• Every electronic devices [starting from a LED to Core i-n (n=1,2...)
processor] works only on two basic operation: On (1) and Off (0).
• That means, combination of only two digits (0 and 1) is sufficient enough
to interact with any electronic devices.
• Among the various types of programming language, C is one of the most
popular, powerful language and has made a revolution in programming
history.
• C language was developed by Dennis Ritchie in BELL Laboratory in 1970.
Programming Languages
Low Level Language High Level Language
1.Machine Language Python, Java, C, C++
2.Assembly Language
Programming Languages
Programming Languages
High Level Language

Compiler

Assembly Language

Assembler

Machine Language
Programming Languages
Programming Problem: D is assigned the sum of A times B plus 10

High Level Language: D = A*B + 10

Assembly Language:
mov eax, A
mul B
add eax, 10
mov D, eax

Machine Language:
A1 00404000
F7 25 00404004
83 C0 0A
A3 00404008
Computer Languages
Machine Language
• Uses binary code (0,1)
• Machine-dependent
• Not portable
Assembly Language
• Uses mnemonics (a system such as a pattern of letters, ideas)
• Machine-dependent
• Not usually portable
• Efficient but difficult to understand
• Used for mainly operating system development
High-Level Language (HLL)
• Uses English-like language
• Machine independent
• Portable (but must be compiled for different platforms)
• Easy to write and understand
• Used for complex scientific and engineering tasks. Exemples: Pascal, C, C++,
Java, Fortran, Python etc.
Machine Language
• The representation of a computer program which is actually read and
understood by the computer.
• A program in machine code consists of a sequence of machine instructions.
Instructions:
• Machine instructions are in binary code
• The symbol 0 stands for absence of electric pulse
• The symbol 1 stands for presence of an electric pulse
• Instructions specify operations and memory cells involved in the operation

Operation Address
0010 0000 0000 0100
0100 0000 0000 0101
0011 0000 0000 0110
Assembly Language
• A symbolic representation of the machine language of a specific processor.
• It will be converted to machine code by an assembler.
• Usually, each line of assembly code produces one machine instruction (One-
to-one correspondence).
• Programming in assembly language is slow and error-prone but is more
efficient in terms of hardware performance.
• These alphanumeric symbols are known as mnemonic codes and can
combine in a maximum of five-letter combinations e.g. ADD for addition,
SUB for subtraction, START, LABEL etc. Because of this feature, assembly
language is also known as ‘Symbolic Programming Language.'
Example:
• Load Price
• Add Tax
• Store Cost
Assembly Language
Assembler
• Software tools are needed for editing, assembling, linking, and debugging
assembly language programs
• An assembler is a program that converts source-code programs written in
assembly language into object files in machine language
Popular assemblers have emerged over the years for the Intel family of
processors.
These include-
• TASM (Turbo Assembler from Borland)
• NASM (Netwide Assembler for both Windows and Linux), and
• GNU assembler distributed by the free software foundation
Assembly Language
• Each command of a program is called an instruction (it instructs the
computer what to do).
• Computers only deal with binary data, hence the instructions must be in
binary format (0s and 1s) .
• The set of all instructions (in binary form) makes up the computer's machine
language. This is also referred to as the instruction set.
• Machine language instructions usually are made up of several fields. Each
field specifies different information for the computer. The major two fields
are:
• Opcode field which stands for operation code and it specifies the particular
operation that is to be performed.
• Each operation has its unique opcode.
• Operands fields which specify where to get the source and destination
operands for the operation specified by the opcode.
• The source/destination of operands can be a constant, the memory or one of
the general-purpose registers.
Assembly Language
• Built from two pieces
Add R1, R3, 3

Opcode Operands
What to do with the data Where to get data and
(ALU operation) put the Results
Types: Each operand taken from a
Arithmetic, logical particular addressing mode:
◦ add, sub, mult Examples:
◦ and, or Register add r1, r2, r3
◦ Cmp Immediate add r1, r2, 10
Memory load/store Indirect mov r1, (r2)
◦ ld, st Offset mov r1, 10(r3)
Control transfer PC Relative beq 100
◦ jmp
◦ bne
Complex *ALU- Arithmetic Logic Unit.
◦ movs
Assembly Language
High-Level Language
• A programming language which use statements consisting of English-like
keywords such as "FOR", "PRINT" or “IF“, ... etc.
• Each statement corresponds to several machine language instructions (one-
to-many correspondence).
• Much easier to program than in assembly language.
• Data are referenced using descriptive names.
• Operations can be described using familiar symbols.
• A machine language system program, called a compiler, is needed to compile
or transform the code into machine readable form.
Example:
Cost = Price + Tax
Computer 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
0001001001000101001001
001110110010101101001...
Programming
Language Family Tree

Two broad groups

Traditional programming
languages
•Sequences of
instructions

Object-oriented
languages
•Objects are created
rather than sequences of
instructions
Typical Programming Languages
BASIC
• Beginner’s All-purpose Symbolic Instruction Code.
• Developed at Dartmouth College in mid 1960s.
• Developed as a simple language for students to write programs with which
they could interact through terminals.
• Example: LET X = 4
LET Y = 5
LET Z = X + Y Output: 4 + 5 = 9
PRINT X, “+”, Y, “=“, Z
END
C
• Developed by Bell Laboratories in the early 1970s.
• Provides control and efficiency of assembly language while having third
generation language features.
• Often used for system programs.
• UNIX (operating system) is written in C.
Typical Programming Languages
C++
• An object-oriented programming language.
• It is C language with additional features.
• Widely used for developing system and application software.
• Graphical user interfaces can be developed easily with visual programming
tools.

JAVA
• An object-oriented programming language similar to C++ that eliminates lots
of C++’s problematic features .
• Allows a web page developer to create programs for applications, called
applets that can be used through a browser.
• Objective of JAVA developers is that it be machine, platform and operating
system independent.
Special Programming Languages
Scripting Languages
• JavaScript and VBScript
• PhP and ASP
• Perl and Python

Command Languages
• sh, csh, bash

Text processing Languages


• LaTex, PostScript

HTML
• Hyper Text Markup Language.
• Used on the Internet and the World Wide Web (WWW).
• Web page developer puts brief codes called tags in the page to indicate how
the page should be formatted.
Compare between C, C++ & Python
// C program showing // C++ program showing # Python program
// how to take input // how to take input showing
// from user // from user # how to take input
#include <iostream> # from user
#include <stdio.h> using namespace std;
int main() int main() a = input("first
{ int a, b, c; { int a, b, c; number: ")
printf("first number"); cout << "first number: "; b = input("second
number: ")
scanf("%d", &a); cin >> a;
c=a+b
printf("second number: cout << endl;
"); print("Hello World")
cout << "second number: ";
scanf("%d", &b); print(a, "+", b, "=", c)
cin >> b;
c = a + b; cout << endl;
printf("Hello World\n c = a + b;
%d + %d = %d", a, b, c); ** Python has no
cout << "Hello World" <<endl; declaration.
return 0; cout << a << "+" << b << "=" << c;
} return 0; }

You might also like