[go: up one dir, main page]

0% found this document useful (0 votes)
8 views15 pages

Lecture 5 PL ICT

The document provides an overview of computer programming, detailing the types of programming languages including machine language, assembly language, and high-level languages. It explains the role of compilers, interpreters, and linkers in program execution, as well as common types of program errors such as syntax, runtime, and logical errors. Additionally, it highlights various high-level programming languages like Python, Java, and C++, along with their uses and strengths.

Uploaded by

dev.faisee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views15 pages

Lecture 5 PL ICT

The document provides an overview of computer programming, detailing the types of programming languages including machine language, assembly language, and high-level languages. It explains the role of compilers, interpreters, and linkers in program execution, as well as common types of program errors such as syntax, runtime, and logical errors. Additionally, it highlights various high-level programming languages like Python, Java, and C++, along with their uses and strengths.

Uploaded by

dev.faisee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Introduction to Computer

Programming
Programs
• Programs are written in programming languages

-Programs are the set of instructions that tell computer what to do.

• A Programming Language is
– A special purpose and limited language
– A set of rules and symbols used to construct a
computer program
– A language used to interact with the computer
Program(example):
Computer Languages
– Machine Language
• Uses binary code
• Machine-dependent
• Not portable
• Assembly Language
– Uses mnemonics
– Machine-dependent
– Not usually portable
• High-Level Language (HLL)
– Uses English-like language
– Machine independent
– Portable (but must be compiled for different platforms)
– Examples: Pascal, C, C++, Java, Fortran, . . .
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
– Instructions specify operations and memory cells involved in the
operation
Example: Operation Address

0010 0000 0000 0100


0100 0000 0000 0101

0011 0000 0000 0110


Assembly Language
• Assembly language is a low-level programming language that is
closely related to machine code, the binary code that computers
understand directly. It uses human-readable mnemonics and
symbols to represent the raw instructions of a computer's
architecture.

• Is converted to machine code by an assembler.


• Programming in assembly language is slow and
error-prone.
• Mnemonic representation of the instructions and data
• Example:
Load Price
AddTax
Store Cost
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
• Example:
Cost := Price + Tax
high-level programming languages

There are many high-level programming languages, each designed with different goals and
strengths.
Python
Use: Web development, data science, automation, machine learning.
Strengths: Easy to learn, large libraries, cross-platform.

JavaScript
Use: Web development (front-end and back-end), mobile app development.
Strengths: Runs on all browsers, large ecosystem, asynchronous programming.

Java
Use: Enterprise applications, Android development, web development.
Strengths: Platform-independent, strong OOP features, large community.

C++
Use: System software, game development.
high-level programming
languages
C#
Use: Windows apps, game development (Unity), web development.
Strengths: Strong Windows integration, modern syntax, great for game development.

PHP
Use: Web development, content management systems (WordPress, Joomla).
Strengths: Easy to learn, widely supported, large community.

R
Use: Data science, statistics, machine learning.
Strengths: Strong statistical libraries, excellent for data analysis.
Compilers & Programs
• Compiler
– A program that converts another program from
some source language (or high-level
programming language / HLL) to machine
language (object code).
– Some compilers output assembly language
which is then converted to machine language by
a separate assembler.
2. Interpretation (For Interpreted Languages)

• Some high-level languages, like Python, JavaScript, or Ruby, are


interpreted. This means the source code is not directly compiled into
machine code. Instead, it is read and executed line-by-line by an
interpreter at runtime.The interpreter translates the high-level code
into machine code on the fly, which is then executed
immediately.Example: In Python, when you run a Python script, the
Python interpreter reads the code and executes the corresponding
machine-level instructions.
What is a Linker?
• A program that pulls other programs together so
that they can run.
• Most programs are very large and consist of
several modules.
• Even small programs use existing code provided
by the programming environment called libraries.
• The linker pulls everything together, makes sure
that references to other parts of the program
(code) are resolved.
Program Errors
• Syntax Errors:
– Errors in grammar of the language

Explanation: The closing parenthesis ) is missing, which causes the interpreter to raise a syntax error.
Cont..
• Runtime error:
– When there are no syntax errors, but the program
can’t complete execution
• Divide by zero
• Invalid input data

Explanation: Dividing a number by zero is mathematically undefined, causing a


ZeroDivisionError.
Cont..
Logical Error:
A logical error occurs when the code runs without throwing an error, but the
output is not as expected. This type of error often occurs because of incorrect
logic in the code.

You might also like