Docsity

PROGRAMMING LANGUAGES INTRODUCTION, Lecture notes of Programming Languages

Toggle sidebar
bg1
Session One: History of programming languages
1.1 Session Objectives
By the end of this session, you should be able to:
• Explain the concept of programming
• Identify the levels of programming languages
• Explain the translators: Compiler, interpreter
Def: Computer
• electronic device
• that accepts data and instructions,
• stores them in the memory,
• then process
• to generate information.
Data & Execution &
Instructions storage
Data :What is fed into a computer
(raw facts).
Information: is already processed data.
INPUT
PROCESSSSS
OUTPUT
Information
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download PROGRAMMING LANGUAGES INTRODUCTION and more Lecture notes Programming Languages in PDF only on Docsity!

Session One: History of programming languages

1.1 Session Objectives

By the end of this session, you should be able to:

  • Explain the concept of programming
  • Identify the levels of programming languages
  • Explain the translators: Compiler, interpreter

Def: Computer

  • electronic device
  • that accepts data and instructions,
  • stores them in the memory,
  • then process
  • to generate information.

Data & Execution & Instructions storage

Data :What is fed into a computer (raw facts).

Information: is already processed data.

INPUT PROCESSSSS OUTPUT

Information

Smartwatch Features You Need to Consider

  • Locate Your Smartphone, Car & Key
  • Make & Receive Calls
  • Smart Compass
  • Gesture Control
  • Accept Verbal Commands
  • Play Music
  • Access Notifications
  • Emergency Call & Fall Detection
  • Tell time
  • Keep track of your health, communication with loved ones
    • Speed and size (Super computers are the fastest, most-powerful and most expensive computers).
    • Power consumption
    • Data storage capacity
    • Memory size

N/b: For the above computer to work, it has to be programmed.

Computer program Def 1: - is a set of instructions written in the computer language specifying processing operations on data.

Def 2: -It is a coded list of instructions performing a set of calculations.

Example: A program to add three numbers, calculate average and display results. 1.Begin

  1. Input: a, b, c,
  1. Process:(i) sum=a +b + c (ii) average =sum/ 4.Output: sum, average 5.End

N/B A program has input, process and output.

Computer Programming : process of producing a computer program. Programming involves:-

  • writing a program
  • debugging the program
  • compiling the program
  • Running/Execute the program.

Programming Language : Language that is understood by the hardware.

1.2 What is Computer Programming Methodology

A Methodology is a system of methods with its orderly and integrated collection of

various methods, tools and notations.

A computer program is a series of instructions written in the language of the

computer which specifies processing operations that the computer is to carry out

on data.

It is a coded list of instructions that tell" a computer how to perform a set of

calculations or operations.

1.3. Types of Programming Languages There are three levels of programming languages;

  • Machine language (low level language)
  • Assembly (or symbolic) language
  • Procedure-oriented language (high level language)

1.3.1 Machine language The lowest-level programming language (except for computers that utilize programmable microcode) Machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. It is a programming language in which the instructions are in a form that allows the computer to perform them immediately, without any further translation being required. Instructions are in the form of a Binary code also called machine code and are called machine instructions. Commonly referred to as the First Generation language

1.3.2 Assembly Language Introduced in 1950s, reduced programming complexity and provided some standardization to build and applications. Also referred to second generation language. The 1 and 0 in machine language are replaced by with abbreviations or mnemonic code. It consists of a series of instructions and mnemonics that correspond to a stream of executable instructions. It is converted into machine code with the help of an assembler. Common features includes;

  • Mnemonic code; used in place of the operation code part of the instruction eg SUB for substract, which are fairly easy to remember
  • Symbolic Addresses which are used in place of actual machine addresses. A programmer can choose a symbol and use it consistently to refer to one particular item of data. Example FNO to represent First No.
  • The symbolically written program has to be translated into machine language before being used operationally. A 1 to 1 translation to machine language, ie one symbolic instruction produces one machine instruction/code.

Advantages of Assembly language over machine language

  • It is easy to locate and identify syntax errors, thus it is easy to debug it.
  • It is easier to develop a computer application using assembly language in comparison with machine language
  • Assembly language operates very efficiently.

1.3.3 High level language A Machine independent and a Problem oriented (POL) programming language. High level language is portable across different machine types (architectures); The machine independence of the high level languages means that in principle it should be possible to make the same high- level language run on different machines. It reflects the type of problem solved rather than the features of the machine.

High level languages are more abstract, easier to use and more portable across platforms as compared to low-level programming languages. A programmer uses variables, arrays or Boolean expressions to develop the logic to solve a problem. Source programs are written in statements akin to English. A high level language code is executed by translating it into the corresponding machine language code with the help of a compiler or interpreter. High level languages can be classified into the following categories;

  • Procedure-oriented languages (third generation)
  • Problem-oriented languages (fourth generation)
  • Natural languages (fifth generation).

Procedure languages. High-level languages designed to solve general-purpose problems, example BASIC, COBOL, FORTRAN, C, C++ and JAVA. They are designed to express the logic and procedure of a problem. Though the syntax of the languages may be different, they use English-like commands that are easy to follow. They are portable.

Problem-oriented languages(4 th^ GL) Used to solve specific problems.

  • Portable across different machine types (architectures)
  • Libraries of macros and sub-routines can be incorporated
  • As they are problem oriented, the programmer is able to work at least to some extent independently of the machine.
  • Have a set of rules that must be obeyed.  Syntax: the structure of the statements and the grammatical rules governing them. Grammatical rules that govern the way in which words, symbols, expressions and statements may be formed and combined.  Semantics: the meaning of the statements written in the language. The rules that governs its meaning. – what happens when the program is executed/run most are standardized by ISO/ANSI to provide an official description of the language

1.4.1 High Level language Translation High level languages need to be translated into machine language which is the computer language. The translation is done by a Compiler or Interpreter

1.4.2 Compiler A compiler is a manufacturer specifically written computer program which translates (or compiles) a source code computer program that translates the source code written in a high level language into the corresponding object code of the low level language. The translation process is called compilation. The entire high level source code / program is converted into the executable machine code file prior to the object program being loaded into main memory and executed. Translation done only ones and the object program can be loaded into the main storage and executed. A program that translates a low-level language into a high level language is called a Decompiler. Compiled languages includes C, C++, COBOL, FORTRAN etc.

Compilers are classified into single-Pass compilers and Multi-pass compilers. Single-pass compilers are generally faster than multi-pas compilers, but multi-pass compilers are required to generate high quality code

A Compiler:

  • Translates the source program code into machine code
  • Includes linkages for closed sub-routine
  • Allocates areas of main storage
  • Produces the object program.
  • Produces a printed copy (listing) of the source code and object code
  • Produces a list of errors found during compilation.

1.4.3 Interpreter: The interpreter is a translation program that converts each high-level language statement into the corresponding machine code. The translation process is carried out just before the program statement is executed. Instead of the entire program, one program statement at a time is translated and executed immediately. When using an interpreter, the source code translated every time the program is executed

The commonly interpreted languages include BASIC and PERL. Though interpreters are easier to create as compared to compilers, the compiled languages can be executed more efficiently and are faster. Interpreters are appropriate in;

  • Handling user commands in an interactive system
  • Debugging programs as they run (removing program faults).
  • Handling software produced for or by a different computer.

1.5.0 Session Summary

We use computer programs almost in all our day to day activities. Computers consisted

of hardware and software components. Programs consist of a group of instructions

designed to accomplish a certain computer task. In order to create computer programs,

we use other software called software development tools which include assemblers,

compilers, and interpreters.

1.5.1 Student Activity

a) What is a program?