Introduction to Computers and Programming Hardware Software - - PowerPoint PPT Presentation

introduction to computers and programming
SMART_READER_LITE
LIVE PREVIEW

Introduction to Computers and Programming Hardware Software - - PowerPoint PPT Presentation

Introduction to Computers and Programming Hardware Software Computer languages Compiling and running 1 Computer Basics A computer system consists of both hardware and software . Hardware - the physical components.


slide-1
SLIDE 1

1

Introduction to Computers and Programming

 Hardware  Software  Computer languages  Compiling and running

slide-2
SLIDE 2

2

Computer Basics

 A computer system consists of both hardware and software.  Hardware - the physical components.  Software - the instructions, or rather, computer programs, that

tell the hardware what to do.

slide-3
SLIDE 3

3

Common Hardware Components

Input devices:

  • keyboard, mouse, touch-screen
  • game controllers
  • sensors

Output device(s)

  • video display, printer
  • robotic devices

Memory Processor

(CPU)

Input Devices

(such as mouse and keyboard)

Output Devices

(such as video display or printer)

Processor:

  • Central Processing Unit (CPU)
  • interprets and executes

program instructions 

Memory:

  • volatile and non-volatile
  • holds data and instructions
slide-4
SLIDE 4

4

Common Hardware Components

Input devices:

  • keyboard, mouse, touch-screen
  • game controllers
  • sensors

Output device(s)

  • video display, printer
  • robotic devices

Memory Processor

(CPU)

Input Devices

(such as mouse and keyboard)

Output Devices

(such as video display or printer)

Processor:

  • Central Processing Unit (CPU)
  • interprets and executes

program instructions 

Memory:

  • volatile and non-volatile
  • holds data and instructions
slide-5
SLIDE 5

5

Classification of Memory

At a high-level there are two types of memory:

Volatile – contents are lost when power is turned off:

  • Main memory (stores programs and data during execution)
  • Cache memory
  • Fastest and most expensive form of memory, per byte

Non-Volatile – contents are maintained when power is turned off:

  • Hard drive, hard disk or Solid State Drive (SSD); internal or external
  • CD, DVD
  • Flash drive
  • Tape (still used extensively)
  • Slowest and cheapest form of memory, per byte
slide-6
SLIDE 6

6

Memory Organization

 Bit = one binary digit, either 0 or 1  Byte = 8 bits  Word = 4 bytes  Larger groupings: (number of bytes)

name approximation exact Kilobyte (KB) 2^10 10^3 Megabyte (MB) 2^20 10^6 Gigabyte (GB) 2^30 10^9 Terabytes (TB) 2^40 10^12 Petabyte (PB) 2^50 10^15 Exabyte (EB) 2^60 10^18 Zetabyte (ZB) 2^70 10^21 Yottabyte (YB) 2^80 10^24

slide-7
SLIDE 7

7

Binary Encodings

 Everything in memory is “encoded” in binary, i.e., as a sequence

  • f bits.

“A” => 01000001 45 => 00101101 “DOG” => 01000100 01001111 01000111

Generally, the encoding of an object is unique among all similar

  • bjects, e.g., the encoding of “A” is different from the encoding of “B.”

Why?

slide-8
SLIDE 8

8

Binary Encodings

How many binary sequences are there on n bits?

How many bits are needed to uniquely encode k items?

  • k=8
  • k=12
  • k=5
  • k=1000
slide-9
SLIDE 9

9

Main Memory Organization

Main memory:

  • A list of locations, each

containing one byte of data.

  • Each location has an associated

“number,” which is commonly referred to as its’ address.

  • Is said to be byte addressable.
  • Also called Random Access

Memory (RAM). 

The number of bytes per data item may vary from one item to another, and from one computer system to another.

  • Integer => 4 or 8 bytes (1 word)
  • Character => 1 or 2 bytes

Address Contents

3021 11110000 Item 1 (2 bytes) 3022 11001100 3023 10101010 Item 2 (1 byte) 3024 11001110 Item 3 (3 bytes) 3025 00110001 3026 11100001 3027 01100011 Item 4 (2 bytes) 3028 10100010 3029 … Next Item, etc.

slide-10
SLIDE 10

10

Computer Programs!

A program is a set of instructions for a computer to execute or run.

System Software - Part of the computers “infrastructure,” and necessary for the system to operate:

  • Operating Systems – DOS, Microsoft Windows, MacOS, Linux, UNIX, etc.
  • Database Systems – Oracle, IBM DB2, SQL Server, Access
  • Networking Software
  • Web Servers
  • Application Servers

User Applications - Not required for the system to operate:

  • Games
  • Apps
  • Office Applications – Word, Powerpoint, Excel
  • Web Browsers
  • Text Editors – textedit, vi, emacs, notepad
slide-11
SLIDE 11

11

Various Types of Software Interfaces

Graphical User Interface (GUI)

  • Windows, menus, buttons, sliders, etc.
  • Windows, Word, PowerPoint, most games
  • Sometimes also called “event-driven” interfaces
  • First developed by Xerox Corporation

Command-Line:

  • User types in commands one line at a time
  • DOS (Start -> run -> cmd)
  • Unix xterm

Application Program Interface (API)

  • Allows one program to communication, interact or “interface” with another,
  • r with some external, physical device.
  • ODBC, JDBC, Swing, AWT
slide-12
SLIDE 12

12

Programming Language Hierarchy

Programs are written, or coded, in a programming language.

There are many different types of programming languages.

slide-13
SLIDE 13

13

High-Level Languages

High-Level Language (HLL):

  • Java, C, C++, C#, COBOL, FORTRAN, BASIC, Lisp, Ada, etc.
  • closest to natural language - words, numbers, and math symbols
  • relatively easy for people to read (intended for people)
  • sophisticated, multi-line statements/commands
  • not directly understood by hardware
  • “portable” (hardware independent)

A program in a HLL is frequently referred to as:

  • a source program
  • source code
  • source file
  • source
slide-14
SLIDE 14

14

High-Level Language Example (Java)

public class SimpleProgram { public static void main(String[] args) { System.out.println(“Hello out there.”); System.out.println(“I will add two numbers for you.”); int x; double d; x = 3752; d = 3.14156; System.out.println(“The sum of ” + x + “ and ” + d + “ is:”); System.out.println(x + d); } }

slide-15
SLIDE 15

15

Machine Languages

Machine Language:

  • very difficult for humans to read
  • just 0s and 1s
  • primitive single-line commands
  • directly understood by hardware
  • not portable (hardware dependent)

A program in machine language is frequently referred to as:

  • an object program
  • object code
  • executable program
  • executable code
  • executable
slide-16
SLIDE 16

16

Machine Language Example

000000 000001 000010 000110 000000 100000 100011 000011 001000 000000 000001 000100 : :

slide-17
SLIDE 17

17

Getting from Source to Machine Code

Back in the dark ages, people programmed in machine code…this was a pain!

Then a really smart person invented HLL’s…this was much better.

  • John Backus => FORTRAN (mid 1950’s)

HLL programs must be translated to machine code in order to be executed.

Translating a program in a high-level language to machine code is called compiling.

A program that compiles programs is called a compiler.