1
Programming Fundamentals
Lecture 1
Khalid H. Ahmed
https://spu.edu.iq
2
Objectives
To understand what:
computers are
Hardware & Software is
a programming language is
Compilers & Interpreters are
Simple java application looks like
https://spu.edu.iq
3
Computers
Is a programmable machine.
A programmable machine must respond the same way to same instructions.
Modern computers are electronic and digital.
https://spu.edu.iq
4
Computer Hardware
https://spu.edu.iq
5
Computer Hardware
General Purpose Computer require:
Input devices: Keyboard, Mouse
Output devices: Screen, Speaker
Storage Devices: Hard disk, SSD.
Memory
CPU
https://spu.edu.iq
6
Computer Hardware
Computer Sizes and Powers
PC
Workstation
Minicomputer (10 – 100s of users)
Mainframe (100s – 1000s users)
Supercomputers (1000,000s Inst/sec)
https://spu.edu.iq
7
Computer Software
By computer software we mean
things we cannot touch.
Design, Logic, Architecture, etc.
https://spu.edu.iq
8
What is a Program?
It is an organized set of instructions executed by a computer.
A program is like the soul of a computer and the hardware is the body.
Programs are written in a language known as programming language.
https://spu.edu.iq
9
Program VS Software
A program contains only instructions
However
Software can contain a lot of programs and other resources.
https://spu.edu.iq
10
Programming Language
is a special language used to develop applications.
is composed of a pre-defined set of instructions that can be combined to
form a program.
https://spu.edu.iq
11
What is instruction ?
Instruction is the result of converting high level language code (Source Code)
to machine level (Binary) using a compiler.
https://spu.edu.iq
12
What is Code ?
A code is little piece of information that is readable by human and contains a
logic.
Codes are of different levels:
Highest level (e.g.: C++) [Source Code]
Low level (Assembly Language) [Source Code]
Machine level (Binary)
https://spu.edu.iq
13
A sample Java Application / Program
1 public class HelloWorld {
2 public static void main(String[] args) {
3 System.out.println("Hello, World");
4 }
5 }
A text editor is usually used to write the source code.
https://spu.edu.iq
14
What is a Compiler?
A compiler by itself is a program. However, it can translate source code to
program.
This converts human readable text to machine instructions.
https://spu.edu.iq
15
Compilers & Interpreters
A compiler and Interpreter both do the same thing. However, they do it
differently.
Compilers translate the whole code before execution.
Interpreters translate chunks at a time and if an error occurs the rest of the
file does not get translated.
https://spu.edu.iq
16
How to create a program?
Write the source code in a code editor.
Compile it using a compiler.
1 # Compile the program
2 javac MyApp.java
3
4 # Execute it
5 java MyApp
https://spu.edu.iq
17
Simple java App
Contents of “MyApp” file.
1 public class MyApp {
2 public static void main(String[] args) {
3 System.out.println("Hello, World");
4 }
5 }
https://spu.edu.iq
18
Questions ?
https://spu.edu.iq
19
Homework
Read more about:
Computer architecture
Java Programming language
https://spu.edu.iq