Understanding Computer Software and Programming Languages, Lecture notes of Information Technology

An overview of computer software, including system software, programming software, and application software. It discusses programming paradigms, such as procedural and object-oriented programming, and different levels of programming languages, from machine language to high-level languages. The document also covers the advantages and disadvantages of low-level and high-level languages, factors to consider when choosing a programming language, and the differences between compilers and interpreters. It is a useful resource for understanding the fundamentals of computer programming and software development. (417 characters)

Typology: Lecture notes

2023/2024

Available from 06/06/2025

wilson-rich
wilson-rich 🇰🇪

282 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C-introduction notes - PROGRAMMING
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Understanding Computer Software and Programming Languages and more Lecture notes Information Technology in PDF only on Docsity!

C-introduction notes - PROGRAMMING

CHAPTER 1

INTRODUCTION TO COMPUTER PROGRAMMING

What is a computer? A computer is an electronic device that manipulates or processes raw data into information. It has the ability to store , retrieve , and process data. Computers have two main components: hardware and software Hardware is any part of your computer that has a physical structure , such as the Monitor, keyboard or mouse. It also includes all of the computer's internal parts like the CPU, Motherboard and the RAM

Software is a collection of computer programs and related data that provides the instructions for telling a computer what to do and how to do it.

Depending on its use and area of implementation, Software can be divided/ classified into 3 major types:

System software - System software is computer software designed to operate the computer hardware to provide basic functionality and to provide a platform for running application software.

Examples: Operating system (e.g. Microsoft Windows, Linux, Mac OS etc

System utilities includes: BIOS Program, Disk Defragmenter, Disk Clean up, Disk Partition Tool, System Restore

Programming software - Programming software includes tools in the form of programs or applications that software developers use to create, debug, maintain, or otherwise support other programs and applications.

Example: C , C++ , C# , BASIC, JAVA , Visual Basic , Phyton , HTML , PHP

Application software – is a program or group of programs designed for end users. They allow end users to accomplish one or more specific (non-computer related) tasks

Examples: Word processor, Spreadsheet , Presentation Software , DBMS, DTP , Graphic Editor

Programming technique : related to an algorithmic idea for solving a particular class of problems. For example, “divide and conquer” or “program development by stepwise refinement”

Programming style : is a set of rules or guidelines used when writing the source code for a computer program. Following a particular programming style will help programmers read and understand source code conforming to the style, and help to avoid introducing errors

Source program/ source code refers to program statements that the programmer enters in the program editor window, and which have not yet been translated into machine-readable form. Source code is what is understood by the programmer, and is usually written in high- level language or Assembly language.

The term Object code/ object program refers to the program code that is in machine- readable (binary) form and is produced by a Compiler or Assembler after translating the Source program into a form that is machine readable

Language Translators - A computer uses & stores information in binary form, and therefore, it cannot understand programs written in either high-level or low-level languages. This means that, any program code written in Assembly language or high-level language must be translated into Machine language, before the computer can recognize & run these programs. A Translator is special system software used to convert the Source codes (program statements written in any of the computer programming languages) to their Object codes (computer language equivalents). The Translators reside in the main memory of the computer, and use the program code of the high-level or Assembly language as input data, changes the codes, and gives the output program in machine-readable code.

In addition, translators check for & identify some types of errors (e.g., Syntax/grammatical errors) that may be present in the program being translated. They will produce error messages if there is a mistake in the code.

Each language needs its own translator. Generally, there are 3 types of language translators:  Assembler.

 Interpreter.

 Compiler.

Note. Interpreters & Compilers translate source programs written in high-level languages to their machine language equivalents.

a. Assembler - An assembler translates programs written in Assembly language into machine language that the computer can understand and execute.

Functions of an Assembler.

  1. It checks whether the instructions written are valid, and identifies any errors in the program.

The Assembler will display these errors as well as the complete source and object programs. If the program has no errors, the job control will let it run immediately, or save the object program so that it may run it later without translating it again.

  1. It assigns memory locations to the names the programmer uses. E.g., the Assembler keeps a table of these names so that if an instruction refers to it, the Assembler can easily tell the location to which it was assigned.
  2. It generates the machine code equivalent of the Assembly instructions. Usually, the Assembler generates a machine code only when no errors are detected. Some of the errors include;
    • Typing mistakes.
    • Using the wrong format for an instruction.
  • Specifying a memory location outside the range 0 – 2047. Note. The Assembler cannot detect Logic errors. The programmer knows of these errors only when the program is run & the results produced are incorrect (not what the programmer expected). The programmer must therefore, go through the program & try to discover why an incorrect result was being produced.

b. Interpreter - An interpreter translates a source program word by word or line by line. This allows the CPU to execute one line at a time.

The Interpreter takes one line of the source program, translates it into a machine instruction, and then it is immediately executed by the CPU. It then takes the next instruction, translates it into a machine instruction, and then the CPU executes it, and so on. The translated line is not stored in the computer memory. Therefore, every time the program is needed for execution, it has to be translated.

c. Compiler - A compiler translates the entire/whole source program into object code at once, and then executes it in machine language code. These machine code instructions can then be run on the computer to perform the particular task as specified in the high-level program.

The process of translating a program written in a high-level source language into machine language using a compiler is called Compilation. For a given machine, each language requires its own Compiler. E.g., for a computer to be able translate a program written in FORTRAN into machine language; the program must pass

(Translation & execution go together).

2. Translates the program each time it is needed for execution; hence, it is slower than compiling. 3. Interpreted object codes take less memory compared to compiled programs. 4. For an Interpreter, the syntax (grammatical) errors are reported & corrected before the execution can continue. 5. An Interpreter can relate error messages to the source program, which is always available to the Interpreter. This makes debugging of a program easier when using an Interpreter than a Compiler.

the code is executed by the CPU. (Translation & execution are separate phases)

2. Compiled programs (object codes) can be saved on a storage media and run when required; hence executes faster than interpreted programs. 3. Compiled programs require more memory as their object files are larger. 4. For a Compiler, the syntax errors are reported & corrected after the source code has been translated to its object code equivalent. 5. Once the source program has been translated, it is no longer available to the Compiler, so the error messages are usually less meaningful.

Linkers & Loaders

Computer programs are usually developed in Modules or Subroutines (i.e., program segments meant to carry out the specific relevant tasks). During program translation, these modules are translated separately into their object (machine) code equivalents.

The Linker is a utility software that accepts the separately translated program modules as its input, and logically combines them into one logical module, known as the Load Module that has got all the required bits and pieces for the translated program to be obeyed by the computer hardware.

The Loader is a utility program that transfers the load module (i.e. the linker output) into the computer memory, ready for it to be executed by the computer hardware.

Syntax

Each programming language has a special sequence or order of writing characters.

The term Syntax refers to the grammatical rules, which govern how words, symbols, expressions and statements may be formed & combined.

Semantics

These are rules, which govern the meaning of syntax. They dictate what happens (takes place) when a program is run or executed.

Review Questions.

  1. Define the following terms: (i). Computer program. (ii). Programming. (iii). Programming language.
  2. With reference to programming, distinguish between Source program and Object code.
  3. What is the function(s) of: Assemblers, Interpreters and Compilers in a computer system?
  4. (a). What are the main functions of a Compiler?

(b). Differentiate between a Compiler and an Interpreter

LEVELS OF PROGRAMMING LANGUAGES / GENERATIONS OF

ROGRAMMING LANGUAGES

There are many programming languages. The languages are classified into 2 major categories: 1). Low-level programming languages. 2). High-level programming languages.

Each programming language has its own grammatical (syntax) rules, which must be obeyed in order to write valid programs, just as a natural language has its own rules for forming sentences.

LOW-LEVEL LANGUAGES These are the basic programming languages, which can easily be understood by the computer directly, or which require little effort to be translated into computer understandable form. They include:

  1. Machine languages.
ASSEMBLY LANGUAGES (SECOND GENERATION PROGRAMMING LANGUAGES)

The second-generation programming language are also low-level assembly languages. Assembly language is the human-readable notation for the machine language used to control specific computer operations. Assembly languages were developed in order to speed up programming (i.e., to overcome the difficulties of understanding and using machine languages). The vocabulary of Assembly languages is close to that of machine language, and their instructions are symbolic representations of the machine language instructions. Assembly language programs are easier to understand, use & modify compared to Machine language programs. Assembly language programs have less error chances. To write program statements in Assembly language, the programmer uses a set of symbolic operation codes called Mnemonic codes. The code could be a 2 or 3 shortened letter word that will cause the computer to perform specific operation. E.g., MOV – move, ADD - addition, SUB – subtraction, RD - read.

Example RD PAT, 15 (read the value 15 stored in the processor register named PAT)

SUB PAT, 10 (subtract 10 from the value in register PAT)

A program written in an Assembly language cannot be executed/obeyed by the computer hardware directly. To enable the CPU understand Assembly language instructions, an Assembler (which is stored in a ROM) is used to convert them into Machine language. The Assembler accepts the source codes written in an Assembly language as its input, and translates them into their corresponding computer language (machine code/ object code) equivalent. Comments are incorporated into the program statements to make them easier to be understood by the human programmers. Assembly languages are machine-dependent. Therefore, a program written in the Assembly language for a particular computer cannot run on another make of computer

Advantages of Low-level languages

1. The CPU can easily understand machine language without translation. 2. The program instructions can be executed by the hardware (processor) much faster. This is because; complex instructions are already broken down into smaller simpler ones. 3. Low-level languages have a closer control over the hardware, are highly efficient & allow direct control of each operation. They are therefore suitable for writing Operating system software & Game programs , which require fast & efficient use of the CPU time 4. They require less memory space. 5. Low-level languages are stable, i.e., they do not crash once written.

Disadvantages of Low-level languages

Very few computer programs are actually written in machine or Assembly language because of the following reasons;

1. Low-level languages are difficult to learn, understand, and write programs in them. 2. Low-level language programs are difficult to debug (remove errors). 3. Low-level languages have a collection of very detailed & complex instructions that control the internal circuiting of the computer. Therefore, it requires one to understand how the computer codes internally works. 4. Relating the program & the problem structures is difficult, and therefore cumbersome to work with. 5. The programs are very long; hence, writing a program in a low-level language is usually tedious & time consuming. 6. The programs are difficult to develop, maintain, and are also prone to errors (i.e., it requires highly trained experts to develop and maintain the programs). 7. Low level languages are machine-dependent (specific), hence non-portable. This implies that, they are designed for a specific machine & specific processor, and therefore, cannot be transferred between machines with different hardware or software specifications. 8. It is not easy to revise the program, because this will mean re-writing the program again.

HIGH- LEVEL LANGUAGES

High-level languages were developed to solve (overcome) the problems encountered in low- level programming languages.

The grammar of High-level languages is very close to the vocabulary of the natural languages used by human beings - can be read and understood easily even by people who are not experts in programming.

Most high-level languages are general-purpose & problem-oriented. They allow the programmer to concentrate on the functional details of a program rather than the details of the hardware on which the program will run.

High-level language programs are machine-independent, (i.e., they do not depend on a particular machine, and are able to run in any family of computers provided the relevant translator software is installed).

Programs written in a high-level language cannot be obeyed by the computer hardware directly. Therefore, the source codes must be translated into their corresponding machine language equivalent. The translation process is carried out by a high-level language software translator such as a Compiler or an Interpreter.

Features of high-level programming languages.

8. High-level language programs are self-documenting, i.e., the program statements displays the transparency of purpose making the verification of the program easy. 9. High level languages are more flexible; hence, they enhance the creativity of the programmer and increase his/her productivity in the workplace.

Disadvantages of using High-level languages

1. High-level languages are not machine-oriented; hence, they do not use of the CPU and hardware facilities efficiently. 2. The languages are machine-independent, and cannot be used in programming the hardware directly. 3. Each high-level language statement converts into several machine code instructions. This means that, they use more storage space, and it also takes more time to run the program. 4. Their program statements are too general; hence, they execute slowly than their machine code program equivalents. 5. They have to be interpreted or compiled to machine-readable form before the computer can execute them. 6. The languages cannot be used on Computers with low memory. The source program written in a high-level language needs a Compiler, which is loaded into the main memory of the computer, and thus occupies much of memory space. This greatly reduces the memory available for a source program.

TYPES OF HIGH-LEVEL LANGUAGES.

High-level languages are classified into five different groups:

  1. Third generation languages (Structured / Procedural languages).
  2. Fourth generation languages (4GLs).
  3. Fifth generation languages (5GLs)
  4. Object-oriented programming languages (OOPs).
  5. Web scripting languages.

The various types of high-level languages differ in: The data structures they handle. The control structures they support. The assignment instructions they use. Application areas, e.g., educational, business, scientific, etc.

THIRD GENERATION LANGUAGES (STRUCTURED LANGUAGES)

A structured (procedural) language allows a large program to be broken into smaller

subprograms called modules, each performing a particular (single) task. This technique of program design is referred to as structured programming. Structured programming also makes use of a few simple control structures in problem solving. The 3 basic control structures are: Sequence Selection. Iteration (looping). Example of c program

#include<stdio.h> Int main() { Printf(“Hello World”); Return 0; }

Advantages of structured programming.

  1. It is flexible.
  2. Structured programs are easier to read.
  3. Programs are easy to modify because; a programmer can change the details of a section without affecting the rest of the program.
  4. It is easier to document specific tasks.
  5. Use of modules that contain standard procedures throughout the program saves development time.
  6. Modules can be named in such a way that, they are consistent and easy to find in documentation.
  7. Debugging is easier because; each module can be designed, coded & tested independently.

Examples of Third generation programming languages include :

1). BASIC (Beginners All-purpose Symbolic Instructional Code). BASIC is a simple general-purpose high-level language used in most computer processing tasks such as developing business and educational applications. It is easy to learn & use; hence, suitable for students who wish to easily learn programming. Translation in most versions of BASIC is carried out by an Interpreter.

Disadvantages of BASIC. BASIC is available in so many versions with different dialects/languages & therefore, it has no standard. Some dialects are limited to data & control structures they support. Some versions of BASIC offer limited facilities in terms of structured programming & meaningful variable names.

2). PASCAL

It was developed for mathematicians, scientists and engineers. It provides an easier way of writing scientific & engineering applications. FORTRAN statements are mostly in form of mathematical expressions; hence, it is useful in writing of programs that can process numeric data. FORTRAN programs are compiled.

Advantages of FORTRAN. It is portable, i.e. it can be used on different types of computers. Disadvantage of FORTRAN. It is not suited for business applications. 5). Ada This language was named after the first lady programmer Ada Lovelace. It is suitable for developing military, industrial and real-time systems.

6). C C is mainly used for developing system software such as the operating system as well as developing the application packages. It has powerful commands that permit the rapid development of programs, and allows direct control over the hardware.

Disadvantage of C It is difficult to read & learn because of its strict dialect rules.

7). LOGO LOGO was designed for educational use in which children can explore & develop concepts through programming the movement of a pen.

8). COROL COROL is used in Real-time processing. COROL programs are compiled.

9). RPG (Report Program Generator) RPG is used in report generating applications, (i.e. it is designed to facilitate the output of reports of business data). A Report generator is a software tool that extracts stored data to create customized reports that are not normally/usually produced by existing applications. 10). SNOBOL (String Oriented Symbolic Language). It is a high-level language designed to manipulate strings of characters. It is therefore used for non-numeric applications. FOURTH GENERATION LANGUAGES (4GL’S).

4GLs make programming even easier than the 3GLs because; they present the programmer with more programming tools, such as command buttons, forms, textboxes etc. The programmer simply selects graphical objects called controls on the screen, and then uses

them to create designs on a form by dragging a mouse pointer. The languages also use application generators (which in the background) to generate the necessary program codes; hence, the programmer is freed from the tedious work of writing the code. 4GLs are used to enquire & access the data stored in database systems; hence, they are described as the Query languages.

Purpose of fourth generation languages. The 4GL‟s were designed to meet the following objectives: -

  1. To speed up the application-building process, thereby increasing the productivity of a programmer.
  2. To enable quick & easy amendments and alteration of programs.
  3. To reduce development & maintenance costs.
  4. To make languages user-friendly. This is because, the 4GL‟s are designed to be user- oriented, unlike the 3rd generation languages which are problem & programmer oriented.
  5. To allow non-professional end-users to develop their own solutions.
  6. To generate bug-free codes from high-level expressions of requirements.

Css example 1

body.top { color : red; font-style : italic }

Example: Structured Query Language (SQL) to select criminal details from a database

SELECT name, height, DoB FROM criminals WHERE numScars = 7;

Examples of 4GLs are: Visual Basic Delphi Pascal Visual COBOL (Object COBOL) Access Basic Advantages of fourth generation languages.

  1. They are user-based, and therefore, easy to learn & understand.
  2. The grammar of 4GL‟s is very close to the natural English language. It uses menus & prompts to guide a non-specialist to retrieve data with ease.
  3. Very little training is required in order to develop & use 4GL programs.
  4. They provide features for formatting of input, processing, & instant reporting.

OOPs use objects. An Object is a representation of a software entity such as a user-defined window or variable. Each object has specific data values that are unique to it (called state) and a set of the things it can accomplish called (functions or behaviour). Several objects can be linked together to form a complete program. Programs send messages to an object to perform a procedure that is already embedded in it. This process of having data and functions that operate on the data within an object is called encapsulation. The data structure & behaviour of an object is specified/described by a template (called a class). Classes are hierarchical, and it is possible to pass the data & behaviour of an object in one class down the hierarchy. Object-Oriented programming enables rapid program development. Every object has properties such as colour, size, data source, etc, which can be set easily without much effort. In addition, every object has events associated with it that can be used to trigger certain actions, e.g. remove the window from the screen on clicking the „Close‟ button. OOP has contributed greatly to the development of graphical user interface operating systems and application programs.

Examples of Object-oriented programming languages are: - Simula C++ SmallTalk Java Java is sometimes associated with development of websites, but it can be used to create whole application programs that do not need a web browser to run.

JAVA Java is an OOP language that resembles Object C (a simplified form of C++). The code of Java displays graphics, accesses the network, and interfaces with users via a set of capabilities known as classes. Classes define similar states & common methods for the behavior of an object. JAVA programs are not compiled into machine code; instead, they are converted into a collection of bytes that represent the code for an abstract Java Virtual machine (VM). A Java interpreter running on a physical machine is then used to translate those bytes into local actions, such as printing a string or drawing a button.

WEB SCRIPTING LANGUAGES.

Web scripting languages are mostly used to create or add functionalities on web pages. Web pages are used for creating Web sites on the Internet where all sorts of advertising can be done. Web pages are hypertext (plain-text) documents written using a language called HyperText Markup Language (HTML). HTML documents have a file extension of .Html or .Htm. Note. HTML doesn‟t have the declaration part and control structures, and has many limitations. Therefore, to develop functional websites, it must be used together with other

web scripting languages like JavaScript, VBScript and Hypertext Preprocessor.

Comparison of Programming languages. Machine language Assembly language High-level languages

  1. Instruction set is made up of binary digits (0‟s & 1‟s).
  2. Instruction is made of 2 parts: operation code & operand.
  3. No translation is needed. (This is the computer language; hence, the computer understands it directly).
  4. Executed by the hardware directly & is faster.
  5. Difficult to learn, develop & maintain.
  6. Programs are lengthy & tedious.
  7. It is time-consuming to develop machine code programs.
  8. Used in applications where efficient use of the CPU time is necessary, e.g., developing Operating systems & other
    1. Instruction set is made up of Mnemonics & labels.
    2. Instruction is made up of 2 parts: operation code & operand, but comments can be added.
    3. Uses an Assembler to convert the assembly language source codes to their object code equivalent
    4. Executed faster than Highlevel, but slower than the machine code programs.
    5. It‟s easier to learn, develop & maintain as compared to machine code programs.
      1. Like machine code language, the programs are lengthy & tedious.
      2. They take a shorter time to develop as compared to machine code programs, but take longer than High-level language programs.
      3. Like machine language, Assembly language programs are used in applications where efficient use of the CPU time is necessary.

1.instruction set is similar to English language statements & mathematical operators.

  1. The instruction varies depending on the particular language.
  2. Uses compiler or interpreter Compiler translates all the source code at once into object code; Interpreter translates line by line
  3. Translation & execution is very slow.
  4. Easy to learn, develop, maintain and use.
  5. Programs are shorter & simpler than Machine & assembly lang. programs.
    1. Developing High-level language programs takes very short time.
  6. Most High-level languages are general-purpose, & can be used to do almost all computer-processing tasks.