Application of ICT WEEK 10

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 28

WEEK -10

2
3
What is programming?

 Series of instructions to a computer to accomplish a task

 Instructions must be written in a way the computer can understand

 Programming languages are used to write programs

 Once the code (language) of a program has been written, it must be executed
(run, started).

 You may need to type the name of the program to start it, or use a word like
RUN and the name of the program (in the old days, anyway).

Zafar Iqbal Khan 4 Application of ICT


Programming Language
• Set of commands that a computer has been
“taught” to understand
• Languages that look like “machine code” (e.g.,
82A8: jsr r5,@#82AE 82AC: sob r0,8296) are used for…
– Writing games
– Writing application programs (like Excel)
• Other languages look like English (“high level,”
e.g., PRINT “HELLO”)
– Logo
– JavaScript
– And many more
Zafar Iqbal Khan 5 Application of ICT
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.

 It provides a linguistic framework for describing computations.

 English is a natural language. It has words, symbols and grammatical rules.

 A programming language also has words, symbols and rules of grammar.

Zafar Iqbal Khan 6 Application of ICT


Programming Language
 The grammatical rules are called syntax.

 Each programming language has a different set of syntax rules.

 Programming languages have evolved over time as better ways have been

developed to design them.

o First programming languages were developed in the 1950s

o Since then thousands of languages have been developed

 Different programming languages are designed for different types of

programs.
Zafar Iqbal Khan 7 Application of ICT
What does Programming look like?
 Here are some examples of an instruction to print the
word HI
– Logo PR [HI]
– JavaScript alert(“HI”);
– FORTRAN PRINT “HI”
– BASIC PRINT “HI”
– COBOL DISPLAY ‘HI’.
– C++ printf(“HI”);
– Pascal WRITELN(‘HI’);
– Assembly XPRNT MESSAGE1
Language MESSAGE1 DC ‘HI’

Zafar Iqbal Khan 8 Application of ICT


Programming Language Generations

• In the beginning… To use a computer, you needed to know how to


program it.
• Today… People no longer need to know how to program in order to
use the computer.
• To see how this was accomplished, lets investigate how programming
languages evolved.
– First Generation - Machine Language (code)
– Second Generation - Assembly Language
– Third Generation - People-Oriented Programming Languages
– Fourth Generation - Non-Procedural Languages
– Fifth Generation - Natural Languages

Zafar Iqbal Khan 9 Application of ICT


Programming Language Generations
 First Generation
(late 1940s):

Machine-level programming
languages
– Fast and efficient, executed
directly on the CPU
– Consists only of 0s and 1s
– Difficult for humans to read,
write, and debug

Zafar Iqbal Khan 10 Application of ICT


Programming Language Generations

 First Generation - Machine Language (code)


– Machine language programs were made up of instructions
written in binary code.
• This is the “native” language of the computer.
• Each instruction had two parts: Operation code, Operand
– Operation code (Opcode): The command part of a computer
instruction.
– Operand: The address of a specific location in the computer’s
memory.
• Hardware dependent: Could be performed by only one
type of computer with a particular CPU.

Zafar Iqbal Khan 11 Application of ICT


Programming Language Generations

 Second Generation
(early 1950s):
– Symbolic assemblers
– Interpreting routines
– Very early compilers

Assembly languages
– Simple mnemonic instructions <opcode> <operands>
– Assembler translates into machine code
– Handcoding in assembly only for low-level needs

Zafar Iqbal Khan 12 Application of ICT


Programming Language Generations

 Second Generation - Assembly Language


– Assembly language programs are made up of instructions
written in mnemonics.
– Mnemonics: Uses convenient alphabetic abbreviations to
represent operation codes, and abstract symbols to represent
operands.
– Each instruction had two parts: Operation code, Operand
– Hardware dependent.
– Because programs are not written in 1s and 0s, the computer
must first translate the program before it can be executed.

Zafar Iqbal Khan 13 Application of ICT


Programming Language Generations

 Third Generation
(mid 1950s - present):

High level, general-purpose

– FORTRAN, LISP, COBOL, ALGOL


(Ada, Basic, C, C++, Java, Pascal, Smalltalk, …)

– Easier for humans to read, write, debug


– Compiler translates into machine code before running
– Interpreter translates into machine code at runtime

Zafar Iqbal Khan 14 Application of ICT


Programming Language Generations

 Third Generation - People-Oriented Programs


– Instructions in these languages are called statements.
• High-level languages: Use statements that resemble
English phrases combined with mathematical terms needed
to express the problem or task being programmed.
• Transportable: NOT-Hardware dependent.
• Because programs are not written in 1s and 0s, the computer
must first translate the program before it can be executed.

Zafar Iqbal Khan 15 Application of ICT


Programming Language Generations

 Fourth Generation (1970s - ): Non-Procedural Languages

 Programming-like systems aimed at simplifying the programmers task of


imparting instructions to a computer.
 Maple, Mathematica, Postscript, SPSS, SQL

 Many are associated with specific application packages.


 Query Languages
 Specification Languages
 Systems Engineering
 Report Writers /Generators,
 Application Generators

Zafar Iqbal Khan 16 Application of ICT


Programming Language Generations

– Query Languages:
• Enables a person to specify exactly what information they require
from the database.
• Usually embedded within database management programs.
– Report Writers:
• Takes information retrieved from databases and formats into
attractive, usable output.
– Application Generators:
• A person can specify a problem, and describe the desired results.
• Included with many micro-computer programs (macros).

Zafar Iqbal Khan 17 Application of ICT


Programming Language Generations

 Object-Oriented Languages: A language that expresses a computer problem as a


series of objects a system contains, the behaviors of those objects, and how the
objects interact with each other.

Object: Any entity contained within a system.

Examples:
 A window on your screen.
 A list of names you wish to organize.
 An entity that is made up of individual parts.

Some popular examples: C++, Java, Smalltalk, Eiffel.

Zafar Iqbal Khan 18 Application of ICT


Programming Language Generations

 Fifth Generation (1980s - ): Natural Languages


Solve problems using constraints rather than algorithms, used in Artificial
Intelligence
– Prolog
 Natural-Language: Languages that use ordinary conversation in one’s own
language.
– Research and experimentation toward this goal is being done.
• Intelligent compilers are now being developed to translate natural language
(spoken) programs into structured machine-coded instructions that can be
executed by computers.
• Effortless, error-free natural language programs are still some distance into the
future.

Zafar Iqbal Khan 19 Application of ICT


A Family Tree of Languages

Fortran LISP
Cobol

BASIC Algol 60 PL/1


Simula ML
C Algol 68
Pascal Scheme
Smalltalk
Ada Dylan
C+ PerlModula 3 Prolog
+ Java
C# Python Ruby
Zafar Iqbal Khan 20 Application of ICT
 Assembled languages:
– Assembler: a program used to translate Assembly language
programs.
– Produces one line of binary code per original program statement.
• The entire program is assembled before the program is sent to
the computer for execution.

Zafar Iqbal Khan 21 Application of ICT


 Compiled languages:
– Compiler: a program used to translate high-level programs.

– Translates the entire program into binary code before anything


is sent to the CPU for execution.

• The translation process for a compiled program:


– First, the Compiler checks the entire program for syntax errors in
the original source code.

– Next, it translates all of the instructions into binary code.


» Two versions of the same program exist: the original source
code version, and the binary code version (object code).

– Last, the CPU attempts execution only after the programmer


requests that the program be executed.
Zafar Iqbal Khan 22 Application of ICT
 Interpreted Languages:
– Interpreter: A program used to translate high-
level programs.
– Translates one line of the program into binary
code at a time:
 An instruction is fetched from the original source code.
 The Interpreter checks the single instruction for errors. (If
an error is found, translation and execution ceases.
Otherwise…)
 The instruction is translated into binary code.
 The binary coded instruction is executed.
 The fetch and execute process repeats for the entire
program.

Zafar Iqbal Khan 23 Application of ICT


Zafar Iqbal Khan 24 Application of ICT
Language Processors
 A program is a set of instructions for performing a particular task.

 These instructions are just like English words.

 The computer interprets the instructions as 1's and 0's.

 A program can be written in assembly language as well as in high-level


language.

 This written program is called the source program.

 The source program is to be converted to the machine language, which is


called an object program.

 A translator is required for such a translation.

Zafar Iqbal Khan 25 Application of ICT


Language Processors
 Program translator translates source code of programming language into
machine language-instruction code.

 Generally, computer programs are written in languages like


COBOL, C, BASIC and ASSEMBLY LANGUAGE,
which should be translated into machine language before execution.

 A language processor is a hardware device designed or used to perform tasks, such


as processing program code to machine code.

 Language processors are found in languages such as Fortran and COBOL.

Zafar Iqbal Khan 26 Application of ICT


Language Processors

 A compiler takes a text file written in a programming language, and converts it into
binary code that a processor can understand: it makes an ".exe" file. You compile
only
once, then always run the "exe" file.

Borland Turbo C is a compiler: you write in C in a text file,


then you compile to get and exe file.

 An interpreter does the same, BUT in real time: each time you run the code, it is
"compiled", line by line: Basic is an interpreter.

 An assembler is similar, in the way that, instead of taking a plain text file, ie in C, it
takes a code written in Assembler Mnemonics, and convert it into binaries.

All "executable" files are in binaries (just 1's and 0's) - maybe viewed in hex (0x12de...)

Zafar Iqbal Khan 27 Application of ICT


[1]. Graham Brown and David Watson, " Information and Communication Technology ” 2013.

[2]. Peter Norton, “Introduction to Computers” 6th International Edition (McGraw Hill)

[3]. Charles S. Parker, " Understanding Computer Today & Tomorrow”, 2000.

You might also like