6fd9cdfed4cf8cd89b1b36667db9458a.ppt
- Количество слайдов: 17
Introduction to Computers and Programming n Hardware n Software n Computer languages n Compiling and running 1
Computer Basics n A computer system consists of both hardware and software. n Hardware - the physical components. n Software - the instructions, or rather, computer programs, that tell the hardware what to do. 2
Common Hardware Components Memory Input Devices (such as mouse and keyboard) Output Devices Processor (CPU) n Processor: (such as video display or printer) n Input devices: Ø keyboard, mouse, touch-screen Ø game controllers Ø sensors Ø Central Processing Unit (CPU) Ø interprets and executes program instructions n Memory: n Output device(s) Ø volatile and non-volatile Ø holds data and instructions Ø video display, printer Ø robotic devices 3
Common Hardware Components Memory Input Devices (such as mouse and keyboard) Output Devices Processor (CPU) n Processor: (such as video display or printer) n Input devices: Ø keyboard, mouse, touch-screen Ø game controllers Ø sensors Ø Central Processing Unit (CPU) Ø interprets and executes program instructions n Memory: n Output device(s) Ø volatile and non-volatile Ø holds data and instructions Ø video display, printer Ø robotic devices 4
Classification of Memory At a high-level there are two types of memory: n 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 n 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 5
Memory Organization n Bit = one binary digit, either 0 or 1 n Byte = 8 bits n Word = 4 bytes n Larger groupings: (number of bytes) name Kilobyte (KB) Megabyte (MB) Gigabyte (GB) Terabytes (TB) Petabyte (PB) Exabyte (EB) Zetabyte (ZB) Yottabyte (YB) approximation 2^10 2^20 2^30 2^40 2^50 2^60 2^70 2^80 6 exact 10^3 10^6 10^9 10^12 10^15 10^18 10^21 10^24
Binary Encodings n Everything in memory is “encoded” in binary, i. e. , as a sequence of bits. “A” 45 “DOG” => => => 01000001 00101101 01001111 01000111 n Generally, the encoding of an object is unique among all similar objects, e. g. , the encoding of “A” is different from the encoding of “B. ” Why? 7
Binary Encodings n How many binary sequences are there on n bits? n How many bits are needed to uniquely encode k items? • • k=8 k=12 k=5 k=1000 8
Main Memory Organization n 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). n 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 9
Computer Programs! n A program is a set of instructions for a computer to execute or run. n System Software - Part of the computers “infrastructure, ” and necessary for the system to operate: Ø Ø Ø Operating Systems – DOS, Microsoft Windows, Mac. OS, Linux, UNIX, etc. Database Systems – Oracle, IBM DB 2, SQL Server, Access Networking Software Web Servers Application Servers n User Applications - Not required for the system to operate: Ø Ø Ø Games Apps Office Applications – Word, Powerpoint, Excel Web Browsers Text Editors – textedit, vi, emacs, notepad 10
Various Types of Software Interfaces n Graphical User Interface (GUI) Ø Windows, menus, buttons, sliders, etc. Ø Windows, Word, Power. Point, most games Ø Sometimes also called “event-driven” interfaces Ø First developed by Xerox Corporation n Command-Line: Ø User types in commands one line at a time Ø DOS (Start -> run -> cmd) Ø Unix xterm n Application Program Interface (API) Ø Allows one program to communication, interact or “interface” with another, or with some external, physical device. Ø ODBC, JDBC, Swing, AWT 11
Programming Language Hierarchy n Programs are written, or coded, in a programming language. n There are many different types of programming languages. 12
High-Level Languages n 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) n A program in a HLL is frequently referred to as: Ø Ø a source program source code source file source 13
High-Level Language Example (Java) public class Simple. Program { 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); } } 14
Machine Languages n Machine Language: Ø Ø Ø very difficult for humans to read just 0 s and 1 s primitive single-line commands directly understood by hardware not portable (hardware dependent) n A program in machine language is frequently referred to as: Ø Ø Ø an object program object code executable program executable code executable 15
Machine Language Example 0000001 000010 000110 000000 100011 001000 00000100 : : 16
Getting from Source to Machine Code n Back in the dark ages, people programmed in machine code…this was a pain! n Then a really smart person invented HLL’s…this was much better. Ø John Backus => FORTRAN (mid 1950’s) n HLL programs must be translated to machine code in order to be executed. n Translating a program in a high-level language to machine code is called compiling. n A program that compiles programs is called a compiler. 17