Topic 1 - Introduction To Computer and Programming Languages
Topic 1 - Introduction To Computer and Programming Languages
Topic 1
COMPUTER AND
PROGRAMMING
LANGUAGE
1) To learn about the hardware
and software components of
computers
2) To learn about level of
programming languages
3) To learn about the roles of
compilers & interpreters in
OBJECTIVE the translation process
S 4) To understand the activity of
programming
5) To compile and run your first
Java program
6) To recognize 3 types of errors
2
WHAT IS A
COMPUTER?
An electronic device that stores and
processes data
Consists of hardware and software.
Hardware
the physical, tangible parts of a
computer.
keyboard, monitor, disks, wires, etc.
Software
programs (e.g. Ms Word) and data.
Intangible parts of the computer.
Hardware Software
•Central Processing Unit (CPU) •System Software
•Main Memory: Random •Application Software
Access Memory (RAM) •c
•Secondary Storage •B
•Input / Output Devices
4
HARDWAR
E
COMPONE
NTS OF A
COMPUTE
R
5
HARDWARE COMPONENTS
OF A COMPUTER
CPU
RAM
• Temporary memory.
• Volatile (information stored in it will be lost
when electric power supply is turned off).
• Directly connected to the CPU, using memory
cells unit.
7
HARDWARE COMPONENTS
OF A COMPUTER
Motherboard
adapter cards
processor chip
memory chips
memory slots
Expansion
slots for
8
adapter cards
HARDWARE COMPONENTS
OF A COMPUTER
Secondary Storage
Provides permanent storage for information.
• Examples of secondary storage:
• Hard disks
• Floppy disks
• CD-ROMs
• USB Flash Drives
9
RAM VS. SECONDARY
STORAGE
RAM / Main Secondary Storage
Memory / Primary / Secondary
Memory Memory
• Volatile • Nonvolatile
• Fast • Slow
• Expensive • Cheap
• Low capacity • Large capacity
• Works directly with • Not connected
the processor directly to the
processor
10
HARDWARE COMPONENTS
OF A COMPUTER
11
CPU AND MAIN MEMORY
Chip that
executes
program
CPU
commands
E.g.
Interact to execute instructions Intel Core i-7-
4960X
Primary storage
area for Main
programs and Memory
data that are in
active use
12
SECONDARY MEMORY
DEVICES
CPU
Secondary memory
devices provide
long-term storage
Information is moved
Main between main memory
Hard Disk Memory and secondary memory
as needed
Mouse
Monitor screen
Keyboard
Joystick Hard Disk
Bar code scanner
Main
Touch screen
Memory
USB Flash Drive
14
THINK
Imagine that you
are using a computer
to write a letter.
Where is the Microsoft
Word program that you
are running located?
15
SOFTWARE
In contrast to hardware, software is an
abstract, intangible entity.
Software can be categorized as system or
application software (refer next slide).
It consists of program and data to be used to
perform certain tasks.
A program is a sequence of simple steps and
operations, stated in a precise language that
the hardware can interpret.
The process of programming involve
algorithm design & coding. 16
System Software
System programs keep all the
hardware and software running
together smoothly.
The most important system
software is the operating
SOFTWA
system (OS).
Controls all machine activities.
RE
Provides the user interface to
the computer.
Manages resources such as the
CATEGOR
CPU, memory & I/O.
E.g: Windows 10, Unix, Linux,
IES Mac OS.
Application Software
Generic term for any other kind
of software
E.g: Ms Word processor, Excel
Spreadsheets, Web browsers,
games
17
Computers store all information
digitally:
numbers
text
DIGITAL
graphics and images
video
INFORMA
audio
program instructions
TION In some way, all information is
digitized - broken down into
pieces and represented as
numbers
18
REPRESENTING TEXT
DIGITALLY
For example, every character is stored as a
number, including spaces, digits, and
punctuation.
Corresponding upper and lower case letters are
considered as different characters.
Hi, Heather.
20
p. 4.15 Fig. 4-16 Next
Once information is
digitized, it is represented
and stored in memory
using the binary number
BINARY system.
21
MAIN MEMORY
Addresses 9278
9279 Main memory is
9280 divided into many
9281 memory locations
9282 (or cells)
9283
9284 Each memory cell
9285 has a numeric
9286
address, which
uniquely identifies
it
22
STORING INFORMATION
Each memory cell
stores a set number
of bits (usually 8
bits, or one byte)
9278 01001010 Represents
9279 ‘J’
Represents
01100001
9280 ‘a’
01110110 Represents
9281
9282 01100001 ‘v’
Represents
9283 ‘a’
9284
9285
9286 Large values are
stored in consecutive
memory locations
23
MAIN MEMORY
24
STORAGE CAPACITY
Every memory device has a storage capacity,
indicating the number of bytes it can hold.
Capacities are expressed in various units:
Computer program
a sequence of instructions
written in a programming
language to achieve a
task/to solve a problem.
26
Levels of programming
language levels:
machine language
(computer directly
understands)
assembly language
LANGUA (symbolic form, need minor
GE translation)
high-level language (entire
LEVELS language need to be
translated )
28
Each type of CPU executes
instructions only in a
particular machine
PROGRAM language.
MING A program must be translated
29
Languages Descriptions Examples Translators
Machine Instruction in 0 01110000110000 None
and 1 bits 01
PROGRAMMING
LANGUAGES 30
THE JAVA PROGRAMMING
LANGUAGE
Created by Sun
Microsystems, Inc.
Introduced in 1995
and it's popularity has
grown quickly.
Rich library
Platform-
independent("write
once, run anywhere")
or architecture-
neutral
31
The Java compiler translates
Java source code into a special
representation called
bytecode.
32
JAVA TRANSLATION
Java source
code (program)
Java Java
compiler bytecode
Bytecode
interpreter
Machine
(Code is executed)
code 33
After compiling a Java
program into bytecode,
that bytecode can be used
on any computer with a
bytecode interpreter and
without a need to
PORTABILI recompile.
TY Bytecode can be sent over
the Internet and used
anywhere in the world.
This makes Java suitable
for Internet applications.
34
Understand files and
folders/directories
SETTING Install JDK
ER TO
Documentation
Tutorial
35
IDE (Integrated
Development
SETTING Environment)
UP YOUR
a software application that
can facilitate programmers
to develop program
COMPUT Write, save, compile &
run program in a single
ER TO environment
USE JAVA
E.g. jGrasp, Netbeans,
Eclipse, BlueJay
36
JGRASP IDE
37
FILE HELLO.JAVA
public class Hello
{
public static void main(String[] args)
{
// display a greeting in the console window
System.out.println("Hello World!");
}
}
38
A Java program is made up of class
definitions.
A class definition must contain a
JAVA
header and a body.
A class contains zero or more
PROGRA
methods
A method is a named section of code
M that also has a header & body
ELEMENT
A method contains program
statements
39
JAVA PROGRAM STRUCTURE
// comments about the class
public class Hello
{
class header
class body
40
}
JAVA PROGRAM STRUCTURE
// comments about the class
public class MyProgram
{
// comments about the method
public static void main (String[] args)
{
41
COMPILING AND RUNNING
Type program into text editor
43
PROCESSING A JAVA
PROGRAM
Hello.java
Hello.class
Class Loader
44
It is common for
programmer to make
mistake in a program.
45
SYNTAX ERRORS
" 46
SYNTAX
ERROR
47
RUNTIME ERRORS
total = 90/0;
48
RUNTIME ERRORS
No error
49
LOGIC ERRORS
50
LOGIC ERROR
51
Creating a Java
Program…
52
Source code
Byte code
53
TODAY’S TAKE
AWAY
Understand what is programming
Learn about the architecture of
computers
Learn about level of programming
languages
Learn about computing
environment and your compiler
Learn how to compile and run
your first Java program
Recognize 3 types of errors
54