BU-CPE 101 NOTE 2
Introduction to programming languages
A programming language is a formal system of notation used to instruct computers to perform
specific tasks. It consists set of instructions which popularly called code or lines of code. It is
structured according to defined syntax and semantics.
Programmers are enabled to communicate with machines and develop software applications,
websites and models.
Instruction Set Architecture (ISA)
An ISA defines the set of instructions that a computer processor can execute. It serves as the
interface between software and hardware.
Types of ISAs
1. CISC (Complex Instruction Set Computing) - x86, x86-64, IA-64
Many complex instructions
Variable-length instructions
Microcode translates instructions into simpler operations
2. RISC (Reduced Instruction Set Computing) - ARM, PowerPC, SPARC, MIPS, RISC-V
Simple, fixed-length instructions
Fewer instructions
Compiler optimizes instruction sequence
3. EPIC (Explicitly Parallel Instruction Computing) - IA-64, Transmeta Crusoe
Explicit parallelism
Compiler schedules instructions
4. VLIW (Very Long Instruction Word): Intel IA-64, Transmeta Crusoe
Multiple instructions per clock cycle
Compiler packs instructions
Key Components of ISA
1. Instruction Format - Binary representation of instructions
2. Instruction Set - Set of available instructions
3. Addressing Modes - Ways to access memory
4. Register Architecture - Number and type of registers
5. Memory Organization - Memory hierarchy and management
ISAs and Operating Systems
1. Linux - supports multiple ISAs (x86, ARM, MIPS)
2. Windows - primarily supports x86 and x86-64
3. macOS - supports x86-64 and ARM
4. iOS - supports ARM
5. Android - supports ARM
Real-World Applications of ISAs
i. Embedded Systems - RISC, ARM, and MIPS in IoT devices
ii. High-Performance Computing - x86-64, PowerPC, and SPARC in supercomputers
iii. Mobile Devices - ARM in smartphones and tablets
iv. Gaming Consoles - Custom ISAs (e.g., PlayStation, Xbox)
Set of Instructions in Programming Language
The set of instructions in a programming language involves different commands and constructs
that dictate how a program runs. These instructions are in different categories. These were
discussed below:
1. Control structures - they dictate the flow of execution within a program. This enhances
decision making (such as `if`, `else`, `switch`) and repetition (`for`, `while` loops).
2. Data manipulation instructions - they handle data operations. These include creating,
reading, updating and deleting data (it can be called CRUD operations).
3. Function Definitions – they are commands that allow programmers to define reusable
blocks of code (functions or methods) that can be invoked throughout the program.
4. Input/Output Operations – they are instructions that manage data exchange between the
program and the user or other systems. They are read from a keyboard or writing to a file.
These instructions are essential for executing tasks ranging from simple calculations to
complex algorithms.
Types of Input in programming language
A programming language has unique type of inputs which are essential for its functionality.
These include;
1. User Input - these are data provided by users through interfaces. They are command line
and graphical user interface. Any of the input can be processed by the program language
involves to perform actions based on user preferences.
2. File Input – these are data read from files stored in a computer or network. These are
needed in programing language to process data from files to perform tasks which
involves data analysis or configuration settings.
3. Sensor Input - data collected from sensors (temperature readings) can be processed in
programming language to make real-time decisions. This is when system programming or
embedded systems are involved.
Importance of programming languages in Software applications, Websites and Systems
Programming languages are fundamental tools that empower developers to create functional
software solutions that meet user needs and solve real-world problems. They are essential for the
development of software applications, websites and systems because of the following reasons
1. Automate tasks – programming languages provided understandable and detailed
instructions for computers to follow. Thus, enhance automation of repetitive tasks and
improve efficiency in various domains.
2. Facilitate user interaction - programming languages enhance developers to create
interactive applications and websites that accepted input data and receive output from the
users.
3. Implement complex logic - programming languages enable the implementation of
algorithms that solve complex problems in different sectors. These include finance,
healthcare, agriculture, bank and engineering.
4. Support system Integration - programming languages enable communication between
different software components and systems through APIs (Application Programming
Interfaces). This enhances interoperability in modern computing environments.
Concepts of Low-level languages and high-level languages in computer programming
Each of the language has distinct purposes and operations at different levels of abstraction. Low-
level languages refer to programming languages that provide little or no abstraction from a
computer instruction set architecture. The low-level language are machine language and
assembly language. They are closer to hardware when compared to high-level languages.
High-level languages provide significant abstraction. Thus, they are more user-friendly and
versatile for application development. When a programmer or a developer acknowledges these
distinctions. It becomes easy to choose the appropriate language for their specific needs.
Machine Language
Machine language is called machine code. It is the lowest level of programming language. It has
binary code (0s and 1s). It is the only language directly understood by the computer central
processing unit (CPU).
Characteristics
i. It is in the binary format. All its instructions are represented in binary format. Thus, it is
difficult for human beings to read or write.
ii. Machine language instructions can be executed directly by the CPU without any
translation.
iii. CPU are made in different types. Then, each of them has its own machine language. It
means that machine code is not portable across different hardware architectures. Hence, it
is hardware specific. Example of simple addition operation in machine - `00000001
00000010`, where specific binary patterns correspond to particular operations.
Assembly language
Assembly language is a low-level programming language that uses mnemonic codes and
symbols to represent machine-level instructions. It serves as an abstraction over machine
language. Thus, slightly readable by human beings.
Characteristics
Assembly language uses Instead of binary code, human-readable symbols unlike machine code
used machine language. Assembly language can be written as (ADD` for addition, `MOV` for
moving data) to represent instructions.
It needs an assembler to translate assembly code into machine code before it can be executed.
It is hardware specific.
Performing addition operation in assembly:
MOV AX, 7 ; Move the value 7 into register AX
MOV BX, 3 ; Move the value 3 into register BX
ADD AX, BX ; Add the values in AX and BX
C and C++ programming languages
C and C++ programming languages are regarded as low-level languages due to their
characteristics. These provide direct access to hardware resources and require manual memory
management.
C programming language
It provides a thin layer of abstraction over machine language. This allows developers to directly
interact with hardware components. It requires manual memory management through pointers,
etc. It does not have a runtime environment. So, it manages resources and handle errors. It
compiles directly to machine code which eliminates the need for interpretation. It is portable and
efficient across various platforms and architectures. It is used for systems programming
C++ programming language
It is built on the foundation of C programming language but object-oriented programming
features were added. Its template system enables compile-time evaluation and generic
programming. It retains C manual memory management via pointers, new and delete. It supports
multiple programming paradigms, these include procedural, object-oriented and functional.
Common Characteristics of C and C++
Direct Memory Access - both languages allow direct memory access through pointers.
Compilation - both languages compile to machine code.
3. Lack of Garbage Collection – both require manual memory management.
4. Error Handling – both of them require manual error handling.
High-Level Languages
High-level languages are programming languages that have providence for strong abstraction
from the details of the computer hardware. They are developed for human beings to read and
write. Thus, they are more user-friendly compare with low-level languages. Some of the high-
level languages are Python, Java, HTML/CS, JavaScript, C# and Ruby.
Characteristics
1. Garbage Collection - automatic memory management.
2. Runtime Environments- interpreted or virtual machine-based execution.
3. Higher Abstraction - focus on software design rather than hardware details.
Characteristics of High-Level Languages
i. Easier to learn and use
ii. Abstracted from hardware details
iii. Focus on software design
iv. Automatic memory management (garbage collection)
v. Runtime environments or virtual machines
vi. Support for object-oriented, functional, or procedural programming
vii. Large standard libraries and frameworks
viii. Platform independence
Advantages of High-Level Languages
i. Faster development
ii. Improved productivity
iii. Better maintainability
iv. Easier debugging
v. Cross-platform compatibility
vi. Large community support
Disadvantages of High-Level Languages
i. Performance overhead
ii. Limited control over hardware
iii. Dependence on runtime environments
iv. Potential security risks
v. Limited support for low-level operations.
Class assignment
1. Mention and discuss 3 set of instructions in programming language.
2. What are the components of ISA?
3. Mention 2 ISAs and their operating systems
4. Discuss 3 types of input in programming language.
5. Mention the importance of programming languages in software application, website
development and system development.
6. Write short notes on Machine language and assembly language
7. State the differences between C and C++ and discuss why both are regarded as low-level
language.
8. State 5 advantages and disadvantages of high - level language