1 / 35

Lesson 1 Computers and Programming Languages

Lesson 1 Computers and Programming Languages. Characteristics of computers Mechanization of arithmetic Programmable ***. History of computing machines 1642, Pascaline (Pascal adder) Blaise Pascal, a French mathematician Mechanical + and – Shoe-box size. 1670, Leibniz’s calculator

asolley
Download Presentation

Lesson 1 Computers and Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lesson 1Computers and Programming Languages Characteristics of computers • Mechanization of arithmetic • Programmable *** History of computing machines • 1642, Pascaline (Pascal adder) • Blaise Pascal, a French mathematician • Mechanical • + and – • Shoe-box size

  2. 1670, Leibniz’s calculator • von Leibniz, a German mathematician • Mechanical • +, –, *, /

  3. 1800s, Babbage Analytical Engine • C. Babbage, English mathematician • supports arithmetic operations with storage for data • Mechanical • Programmable, controlled by punch cards • Ada Augusta, assistant, 1st programmer

  4. 1946, ENIAC • Eckert & Mauchly, Univ. Pennsylvania, USA • Electronic, 19,000 vacuum tubes • 1,500 relays • 60,000 pounds, 16,200 ft3 • program via re-wiring • 5000 arithmetic operations / sec.

  5. Late 1940s • von Neumann, Princeton, USA • programs stored as data during execution • 1958, IBM 7090, transistors • 1964 IBM System/360, integrated circuits

  6. 1980s, most computers, VLSI (Very Large Scale Integrated circuits) • 1999, PC • Pentium II processor • 333 MHz; 7.5M transistors • Main memory: 64 Mbyte; • Hard disk: 4Gbyte; • Price: HK$10,000 • 2004, PC • Pentium 4 processor • 3 GHz; 125M transistors • Main memory: 512 Mbyte • Hard disk: 80Gbyte; • Price: HK$5,000

  7. Moore’s Law The number of transistors in a chip is doubled every couple of years (Exponential growth)

  8. Basic components of a computer Secondary Storage Main Memory Input Unit Output Unit Control Unit Arithmetic & Logic Unit Central Processing Unit (CPU) Network Interface Internet

  9. A Pentium 4 chip • Central Processing Unit (CPU) • Arithmetic and logic unit • +, –, *, /, … • comparison: >, <, ==, >=, ... • logical AND, OR, … • Control unit • Instruction execution cycle 1. fetch next instruction in RAM, 2. decode the instruction, 3. fetch the data from RAM, if needed, 4. carry out the operation, 5. store the result in RAM, if needed, 6. repeat the entire cycle from Step 1.

  10. 00000 00001 00010 00011 00100 • Main Memory (Primary Memory) • individually accessible storage cells with addresses • Each cell stores 1 byte (8 bits) • random access memory (RAM) • Read & write • Electronic, silicon chips • fast • volatile (Data are lost when power is off.)

  11. Tracks Sectors Gaps • Secondary storage, e.g., hard disk A disk surface contains magnetic tracks organized in concentric circles. A track is divided into sectors. A block of data (smallest unit, e.g., 512 bytes) is stored in a sector.

  12. Direct access The arm first moves to the targeted track. Then the read/write head accesses the data when the targeted segment revolves underneath it. • Storage: magnetic • Movement: mechanical • Higher capacity than RAM • Slower than RAM • Cheaper than RAM • Non-volatile (Data are retained even when power is off.) • Two other common access mechanisms are: • Sequential access (tapes) • Random access (RAM)

  13. Input Units • Keyboards • Mouse • Joy sticks • Output Units • Monitors • Printers • Speakers A touch monitor supports both input and output

  14. Terminology • Data: the physical form of information (singular: datum) • A character (represented by 8 binary bits, ‘A’ is 01000001) • A name (represented as a sequence of characters (a string) ) • The age of a person (represented as a 32-bit integer) • File: Data stored on a disk, eg, • A text file (containing only characters) • A file that stores a sequences of student records. A record contains Name: Chan Tai Man UID: 20020323888 Tel: 29592193 . . . • A PowerPoint file

  15. A bit is a binary digit. Its value is either 0 or 1. • A byte consists of 8 bits • An algorithm is a sequence of precise instructions that leads to a solution (Similar to a recipe.) • A computer program is a set of precise instructions for a computer to execute. • A recipe is a set of instructions for a person to carry out, eg, A recipe for preparing a fish dish: • Clean a 1-pound fish. • Cut the fish into two halves. • Fry the fillets in boiling oil for 6 minutes. • Add soy sauce and green onions right before serving.

  16. //A C++ program that converts temperature #include <iostream> using namespace std; int main() { int f, c; //Declarations cout << "Enter the temperature in Fahrenheit: "; cin >> f; c = (f - 32) * 5 / 9; cout << "The temperature in Centigrade is: " << c << "\n"; system("PAUSE"); return 0; } Run the program

  17. Hardware: physical machinery of a computer system • a Notebook PC • a network card • a monitor • a printer Software: a collection of programs • MS Word, a software package for preparing documents • Window 2000, an operating system on PC • A Java compiler for translation • Netscape for surfing the Internet

  18. Software Life Cycle • Analysis and specification of the task • Design of the software • Implementation • Testing • Maintenance • Obsolescence

  19. Problem-solving phase Implementation phase Start Problem definition Algorithm design Translating to C++ Desktop testing Testing We will focus on the impl. phase in this course. Working program

  20. Programming Languages • Machine Languages • Data are represented as a sequence of bits, eg, 00000101 is 5. • Instructions are represented as a sequence of bits too, e.g., 000101 0001 00001100 Operation Data sources/destination Add the numbers in Register 1 and the memory cell at location 00001100; store the sum in Register 1. • A register is a high-speed memory cell in cpu. A cpu may contains many registers. • A program on a disk must be first loaded in RAM before the execution starts • Machine dependent (Different computers have different machine languages.)

  21. Add the no. in Register 1 to the no. in the location called count; Store the sum in the Register. • Assembly Languages • Instructions are represented by symbolic names that make sense to human beings, e.g., ADD R1, count STORE R1, SUM [assembly lang. Program] [mach. Lang. Program] Assembler (software) • One assembly instruction is translated into one machine instruction • Assembly language is machine dependent

  22. Put 3 in the memory location called n. • High-level Languages • Instructions appeared in a form similar to natural languages or mathematical formulas. E.g., n = 3; sum = a + b + c; if (n != 0) average = sum / n; • A compiler translates source code into object code [Source program] [object program] inhigh-level lang. in machine lang. Executed by a computer • One statement may be translated into hundreds of machine instructions • Examples: Fortran, Pascal, C, C++ Compiler

  23. Linking An object program may be put together with other build-in programs in libraries before the execution. A linker is a program that carries out the linking operation. • Loading An object/pseudocode program must be first loaded in RAM before the execution. • Portable (Machine independent) A program written in a high level language can be compiled and executed in various computers.

  24. Syntax • The grammar that specifies the correct form of a language. • A syntax rule for <assignment statement> <assign stat> <id> = <expression> ; E.g.,A = B + C ; • A syntax diagram for <compound statement> { <statement> } E.g., { A = B + 1 ; If (C > 0) D = -1; }

  25. Syntax rules that specify balanced parentheses 1. E () 2. E (E) 3. E EE • All balanced paren. can be generated using the rules , eg, E EE (Rule 3) (E)E (Rule 2) (())E (Rule 1) (())(E) (Rule ?) (())(EE) (())(()E) (())(()()) • There is no way to derive an unbalanced parentheses from the rules , eg, (()(()

  26. Semantics Rules which give the meanings of statements. E.g., <id> = <expression> ; means: evaluate the <expression>; store the result in the memory location represented by <id>. E.g., apply the rule to evaluate A = B + C ; • Examples of high-level languages • FORmula TRANslation (FORTRAN) • John Backus • Numerical Analysis • The Oldest • COmmon Business-Oriented Language (COBOL) • For commercial applications • Once promoted by US government

  27. ALGOrithmic Language (ALGOL) • For coding algorithms • Well designed • Predecessor of PASCAL • Beginner’s All-Purpose Symbolic Instruction Code (BASIC) • Poorly designed • APL (A Programming Language) • PL/I (Programming Language I), once promoted by IBM • LISP, PROLOG, ADA (promoted by US Defense Dept) • B, C • C++

  28. B was developed by Ken Thompson, the originator of UNIX • C was developed by Dennis Ritchie of AT&T Bell Lab in 1972 • A high-level language with low-level features • Easy-to-write, but hard-to-read • Not safe (No automatic checks) • Not Object-oriented • C++ was developed by Bjarne Stroustrup of Bell Lab in early 1980s • Object-oriented • Intricate, in addition to other shortcomings of C

  29. Turing Award • Offered by America Computing Machinery (ACM) • In memory of Alan Turing • UK Applied Mathematician • Theorist on computer models • Study the power of computer Can we have a program that determines whether the execution of a program will halt or not? • http://www.turing.org.uk/turing/ • Highest honor in computer science • Offered annually

  30. Turing Award Laureates 1966 A.J. Perlis 1967 Maurice V. Wilkes 1968 Richard Hamming 1969 Marvin Minsky 1970 J.H. Wilkinson 1971 John McCarthy 1972 E.W. Dijkstra 1973 Charles W. Bachman 1974 Donald E. Knuth 1975 Allen Newell 1975 Herbert A. Simon 1976 Michael O. Rabin 1976 Dana S. Scott 1977 John Backus 1978 Robert W. Floyd 1979 Kenneth E. Iverson 1980 C. Antony R. Hoare 1981 Edgar F. Codd 1982 Stephen A. Cook 1983 Ken Thompson 1983 Dennis M. Ritchie 1984 Niklaus Wirth 1985 Richard M. Karp 1986 John Hopcroft FORTRAN APL Prog. Lang. ALGOL UNIX, C C PASCAL

  31. 1997 Douglas Engelbart 1998 James Gray 1999 Frederick P. Brooks, Jr. 2000 Andrew Chi-Chih Yao 姚期智教授 2001 Johan Dahl and Kristen Nygaard 2002 R. L. Rivest, A. Shamir & L.M. Adleman 2003 Alan Kay 1986 Robert Tarjan 1987 John Cocke 1988 Ivan Sutherland 1989 William (Velvel) Kahan 1990 Fernando J. Corbato' 1991 Robin Milner 1992 Butler W. Lampson 1993 Juris Hartmanis 1993 Richard E. Stearns 1994 Edward Feigenbaum 1994 Raj Reddy 1995 Manuel Blum 1996 Amir Pnueli Theory of Computation OOP OOP

  32. Truths that might hurt (18th June 1975) Edsger W.Dijkstra 1930-2002 • It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. • FORTRAN --"the infantile disorder"--, by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use.

  33. Truths that might hurt • The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence. • Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer. • Simplicity is prerequisite for reliability.

  34. Reading Assignment • Chapter 1 of the Text, P. 1-39

More Related