Download presentation
Presentation is loading. Please wait.
Published byBlaise Bishop Modified over 7 years ago
1
Dr. Introduction to Computing pierre@vigneras.name Dr. Pierre Vignéras This work is licensed under a Creative Commons Attribution-Share Alike 2.0 France. See http://creativecommons.org/licenses/by-sa/2.0/fr/ for details
2
Dr. Text Books Reference Book: New Perspectives On Computer Concepts Parsons and Oja National Book Foundation The Web: http://wikipedia.org Books C- How to program (Third Edition) Introduction C++ and Java Deitel & Deitel Prentice Hall
3
Dr. ● No entry after the first 10 minutes ● No exit before the end of the class ● Unannounced Quiz – Weekly, at the beginning of a class – Fixed timing (you may suffer if you arrive late) – Spread Out (do it quickly to save your time) – Papers that are not strictly in front of you will be considered as done – Cheaters will get '-1' mark – Your head should be in front of your paper! Class, Quiz & Exam Rules Rules
4
Dr. Grading Policy ● Quiz: 20 % ● Mid: 30 % ● Final: 50 % ● A final average below 50/100 will be assigned a failed mark: F. Grading Policy
5
Dr. Outline (Important points) ● Basics – Numeral basis – Bits & Bytes – computer components ● Hardware History – Von Neumann Architecture – Moore's Law
6
Dr. ● Theory History – Godel Theorem – Turing Machine, Lambda Calculus & Boolean Algebra – Algorithms (pseudo-code, flowcharts) – Computability and Complexity Theory ● Language History – Compilation vs Interpretation – Type System – Type checking (static vs dynamic, weak vs strong) Outline (Important points)
7
Dr. ● Operating System History – Definitions & Compositions – Eras (Unix, Apple, IBM PC, Mac, Windows) – Open Source (GNU, Linux) ● Network History – Internet, Web, Search Engine – Network Layers (OSI, TCP/IP) – Network Topology Outline (Important points)
8
Dr. 8 Outline Basics
9
Dr. Computer: definition (http://en.wikipedia.org/wiki/Computer) ● Origin – Person who performed numerical calculations, often with the aid of a mechanical calculating device ● Today – Machine for manipulating data according to a list of instructions known as a program. ● Various sort ● Supercomputer, Mainframe, Servers ● Personal Computers, Laptop ● PDA, Cellular Phones, Smart cards I. Basics
10
Dr. Vocabulary (http://en.wikipedia.org/wiki/Digital http://en.wikipedia.org/wiki/Bit) ● Digital = discrete – Comes from digits (Latin origin = fingers) ● Analogue = continuous (real life) ● Bit = 1 binary digit – Can have either the value 1 or 0 – Used to represent (almost) everything – Physical representation: ● 1 == electricity is present ● 0 == no electricity ● A byte is a collection of 8 bits – Unit for storage capacity I. Basics
11
Dr. Numeral Bases Base 10: Decimal Base 2: Binary Base 8: Octal Base 16: Hexadecimal Base 10: Decimal Base 2: Binary Base 8: Octal Base 16: Hexadecimal Common values: 2 8 =256 2 16 =65,536 2 10 =1,024 (kilo) 2 20 =1,048,576 (Mega) 2 30 : 1 mega kilo (Giga) 2 40 : 1 giga kilo (Tera) Common values: 2 8 =256 2 16 =65,536 2 10 =1,024 (kilo) 2 20 =1,048,576 (Mega) 2 30 : 1 mega kilo (Giga) 2 40 : 1 giga kilo (Tera) 1 kb = 1024 bits 1 kB = 1024 bytes 1 CD = 650 MB 1 DVD = 4.5 GB 1 photo ~ 2 MB 1 character = 1 B 1 text email ~ 5 kB 1 kb = 1024 bits 1 kB = 1024 bytes 1 CD = 650 MB 1 DVD = 4.5 GB 1 photo ~ 2 MB 1 character = 1 B 1 text email ~ 5 kB I. Basics
12
Dr. Personal Computer Architecture (1)Screen (2)Motherboard (3)Processor (CPU) (4)Memory (RAM) (5)Extension Cards (6)Power Supply (7)Optical disk drive (CD/DVD) (8)Hard Disk Drive (HDD) (9)Keyboard (10)Mouse I. Basics
13
Dr. Memory (http://en.wikipedia.org/wiki/Random_Access_Memory) ● Random Access Memory (Main memory) – Erased when computer is shut down – A list of cells ● Each cell is assigned an address (a number) and can store a fixed amount of informations (8, 16, 32 or 64 bits) – Memory can contains instructions or data ● The cell addressed #1234 contains “0101” ● “0101” may means: – the number 5 in decimal, – the character 'F', – the instruction: “increase the value of the next cell by one” – The first and third “property” are TRUE, others are FALSE, – Anything else... I. Basics
14
Dr. Central Processing Unit (Processor) (http://en.wikipedia.org/wiki/CPU) ● Reads instructions from the memory, executes them and writes the result in the memory – Operations possible ● addition, subtraction, multiplication, division ● comparisons, string manipulations,... ● Driven by a timer ● Frequency = Number of ticks (cycle) per second ● Performance = Instructions Per Cycle * Frequency – AMD Athlon XP ~ 2.5 IPC – Intel PIV ~ 2 IPC – At same clock speed, AMD Athlon performs better than Intel PIV ● Connected with other devices by several bus I. Basics
15
Dr. Input/Output Devices ● Hard drives – Store permanently data ● Programs and data (documents) ● Network cards (Ethernet card) – Used to connect several computers ● CD/DVD drives – Read-only storage devices (music, video, data) ● Video Card (3D specialized hardware) – Driven by the CPU to transmit data on screen(s) – Contains a Graphic processor (GPU) – Needs its own memory I. Basics
16
Dr. The 2006 market ● CPUs (future trends is multi-core) – Intel: PIV (~ 3.8 GHz), Core Duo (~ 2 GHz) – AMD: Athlon 64, Opteron (~ 2 Ghz) ● Memory: [512 – 1512] MB ● Hard Drives: [60 – 800 ] GB ● Network Cards: – Ethernet: 1 Gb/s – Wireless (Wi-Fi): ~ 54 Mb/s ● Video Cards: ~ 256 MB, 400 MHz ● Screens: CRT 17' & 19'; TFT 15' & 17' (trend) I. Basics
17
Dr. Internet (http://en.wikipedia.org/wiki/Internet) – Worldwide, publicly accessible network of interconnected computer networks that transmit data using the IP protocol (language) – World Wide Web (WWW): ● collection of interconnected documents, linked by Hyperlinks and URLs ● accessible via the Internet, as are many other services ● www != Internet ● You need a client application (called a web browser) – URL: protocol://address[:port]/ressource ● http://images.google.com/preferences (www) http://images.google.com/preferences ● fish://192.168.1.1/documents (SSH) I. Basics
18
Dr. Searching on the web ● Search Engines – Google: http://www.google.pkwww.google.pk – Yahoo: http://www.yahoo.comhttp://www.yahoo.com ● How does it work? – During the night, a robot scans the web and indexes web pages making pairs [word, {URLs}] – When you enter a keyword, the search engine look in its table for a matching [word, {URLs}] – It then present the set of {URLs} ● Internet does not provide true informations – Anyone can write what he wants! I. Basics
19
Dr. E-Mail ● Works over the Internet like the normal (slow) mail system (also called snail) ● You need a client application – Can be a web browser (webmail) – Can be a dedicated mail reader ● You should follow the netiquette (Internet Etiquette) – Catch-all term for the conventions of politeness – See: http://tools.ietf.org/html/rfc1855 - RFC1855 (standard) http://www.penmachine.com/techie/emailtrouble_2003-07.html (short)http://tools.ietf.org/html/rfc1855 http://www.penmachine.com/techie/emailtrouble_2003-07.html I. Basics
20
Dr. 20 Outline History
21
Dr. 21 Parallel Worlds ● Theory – Models – Languages – Complexity – Computability – Cryptography ● Engineering – Hardware ● Processors, Hard drives, Memory,... – Software ● Design, Operating Systems, Project Management,... Edsger Dijkstra: "Computer science is no more about computers than astronomy is about telescopes.” Using a computer does not make one a computer scientist! II. History
22
Dr. 22 Hardware http://www.eingang.org/Lecture/ II. History
23
Dr. 23 Counting ● From the very beginning, men started off by counting on their digits for various reasons – Sharing food items fairly – Religion & ceremonies according to time – etc. ● Many possibilities (base): 10, 16, 12, 6,... ● Some attempts to create counting machines – Help counting up to big numbers – Abacus (China), Pascaline (Blaise Pascal, 1642), The Difference Engine (Charles Babbage, 1812) II. History/Hardware
24
Dr. 24 Cards ● 1890: Herman Hollerith presents – Punched Cards & Tabulating Machine – For U.S. Census Bureau – Used until the highly controversial United States presidential election of 2000 – Tabulating Machine is a great success: creation of IBM by Herman Hollerith ● Limited to tabulation II. History/Hardware
25
Dr. 25 Cards (http://en.wikipedia.org/wiki/Punch_card) II. History/Hardware
26
Dr. 26 Cards (http://en.wikipedia.org/wiki/Punch_card) II. History/Hardware
27
Dr. 27 Binary Representation ● In 1941, Konrad Zuse creates the Z3 ● Uses binary system II. History/Hardware
28
Dr. 28 Engineering Improvements ● Mark I (IBM, 1930-1959) – Fully automatic machine – Four operations on 23 decimals numbers – Subroutines (logarithm & trigonometric functions) – 3 to 5 seconds per multiplication – In use at Harvard until 1959 ● ENIAC (Mauchly and Eckert, 1946-1955) – 10 decimal-digits words – “Wire your own“ instruction technique II. History/Hardware
29
Dr. 29 John Von Neumann (http://en.wikipedia.org/wiki/Von_Neumann_Architecture) ● Data and Program can be stored in the same space – The machine itself can alter either its program or its internal data ● Conditional goto's to other point in the code ● Often used subroutines can be stored in memory ● First machine appears in 1947 (EDVAC & UNIVAC) – Still the overall architecture of computers today! II. History/Hardware
30
Dr. 30 Von Neumann Architecture II. History/Hardware
31
Dr. 31 Major engineering advances ● Transistors (Shockley, Bardeen, Walter; 1947) – Freedom from vacuum tubes, which were extremely bulky ● Integrated Circuits (Kilby, 1959) – Aka “chip” – collection of tiny transistors which are connected together – only connections were needed to other electronic components ● Machines becomes smaller and more economical to build and maintain. II. History/Hardware
32
Dr. 32 Moore's Law (http://en.wikipedia.org/wiki/Moore's_law) ● 1965: Moore, a co-founder of Intel. – The complexity of integrated circuits doubles every 24 months – Quoted as “[...] doubles every 18 months”! ● Empirical Observations and prediction – goal for an entire industry. ● Moore's law means an average performance improvement in the industry as a whole of over 1% a week. ● A new product that is expected to take three years to develop and is just two or three months late is 10 to 15% slower, bulkier, or lower in storage capacity! II. History/Hardware
33
Dr. 33 Moore's law II. History/Hardware
34
Dr. 34 Moore's Law effect II. History/Hardware
35
Dr. 35 Moore's Law limitation ● 2006 state of the art ● IBM published a paper for a 30 nm technology ● April 2005 ● Gordon Moore stated in an interview that the law may not hold valid for too long, since transistors may reach the limits of miniaturization at atomic levels ● 2003: Kurzweil conjecture ● Moore's Law of Integrated Circuits was not the first, but the fifth paradigm to provide accelerating price-performance. ● New type of technology will replace current integrated-circuit technology, and that Moore's Law will hold true long after 2020. II. History/Hardware
36
Dr. 36 General Moore's Law II. History/Hardware
37
Dr. 37 2006 Trends (http://en.wikipedia.org/wiki/Multicore_CPU) ● Major misunderstanding: – Performance is not equivalent to clock speed ! – Moore's law is not about doubling performance anyway! ● Doubling the number of transistors: – Put two CPUs on the same silicon die: dual-core ● The future is multi-core systems – Intel, AMD, IBM, Sun are focusing on this – No need for a new CPU design: less risk ● Major issue at the software level – How to deal with concurrency?
38
Dr. 38 Theory II. History
39
Dr. 39 The Godel Theorem (1931) (http://en.wikipedia.org/wiki/Gödel's_incompleteness_theor ems) ● In some cases, it is possible to prove something and its contrary (inconsistency). ● Some mathematical truth are impossible to prove (incompleteness) – Idea: “Any French is a lier has said by a French” – Sketch of the proof: ● suppose a program 'P' can tell if a proposition is TRUE or FALSE without error. ● Proposition: “The program 'P' does not reply TRUE to this proposition”. – Can the program reply TRUE or FALSE? Neither! – And what about us? Is the proposition TRUE? Yes! II. History/Theory
40
Dr. 40 Alan Turing Machine (1936) (http://en.wikipedia.org/wiki/Turing_machine) ● Infinite tape (divided into adjacent cells) – Each cell contains a symbol from some finite alphabet: {a,..., z}; {0,...,9}; {0,1} ● Head – read/write symbols – move the tape left and right one cell at a time. ● Table of instructions that tells the machine: – what symbol to write – how to move the head – what its new state will be ● State register that stores the (finite) state of the table. – One special start state II. History/Theory
41
Dr. 41 Turing Machine (Abbrev: TM) (http://en.wikipedia.org/wiki/Turing_machine) II. History/Theory
42
Dr. 42 Alan Turing Machine (1936) (http://en.wikipedia.org/wiki/Turing_machine) ● Stone (1972): fully description requires – The alphabet – The input form in which the parameters are presented on the tape – The output form in which answers will be represented on the tape when the Turing machine halts – The initial state of the Turing machine – The machine program II. History/Theory
43
Dr. 43 Turing Machine (http://en.wikipedia.org/wiki/Turing_machine) ● Example: increment function: inc(x)=x+1 – Tape alphabet: {0,1} – Input: A number in base one enclosed by zero 0 10 :0...010...0 1 10 :0...0110...0 4 10 :0...0111110...010 10 :0...0111111111110...0 – Output: written in place of the input (same form) s0s1s2 1,>> 0,10,>> 1,<< Starting points Starting state II. History/Theory
44
Dr. 44 Turing Machines ● Turing Machines can be composed to create more complex ones. ● Example: f(x)=x+2 II. History/Theory s0s1s2 1,>> 0,10,>> 1,<< s0s1s2 1,>> 0,10,>> 1,<<
45
Dr. 45 Turing Machines ● Turing Machines can be composed to create more complex ones. ● Example: f(x)=x+2 II. History/Theory s0s1s2 1,>> 0,10,>> 1,<< s2s3s4 1,>> 0,10,>> 1,<< Only one initial state! Only one terminal state! Only one initial state!
46
Dr. 46 Turing Machines ● Turing Machines can be composed to create more complex ones. ● Example: f(x)=x+2 II. History/Theory s0s1 1,>> 0,1 0,>> 1,<< s2s3s4 1,>> 0,10,>> 1,<< Relabel states Make the new link
47
Dr. 47 Turing Machines and Algorithms ● A Turing Machine describes a “mechanical procedure” – Sort of recipe – Each step is simple and well defined so it can be followed by any human using a paper and a pencil ● Very complex procedures can be described using Turing machines – Addition, multiplication,... (anything?) ● A Turing machine provides an easy to understand abstraction of how computers (humans or machines) are actually working ● Turing Machines are the actual formalisation of what is called algorithms II. History/Theory
48
Dr. 48 Algorithms (http://en.wikipedia.org/wiki/Algorithm) ● From the famous Arab scientist Al-khwarizmi – Solving problems in an ordered step-by-step sequence ● An algorithm is a finite set of well-defined instructions for accomplishing some task which, given an initial state, will terminate in a defined end-state. – Order of computation is usually critical to the functioning of the algorithm. – Instructions are usually listed explicitly starting 'from the top' and going 'down to the bottom': this is what is formally called the flow of control. II. History/Theory
49
Dr. 49 Algorithm Representations ● A Turing Machine is one representation of an algorithm ● Other representations include: ● Natural language (too verbose and ambiguous) ● pseudo code (no standard) – derived from programming languages ● flowcharts (too verbose) – schematic representation of a process – derived from Turing Machines representation ● programming languages (too detailed) ● So which one to choose? It depends! – All of them but for different situations II. History/Theory
50
Dr. 50 Algorithm Example: largest number Natural Language ● Input: an unsorted list of numbers ● Output: the index (rank) of the largest number in the list 1. Assume the first item is largest. 2. Look at each of the remaining items in the list and if it is larger than the largest item so far, make a note of its rank. 3. The last noted rank is the one of the largest element in the list when the process is complete. ● Complexity: requires N comparisons where N is the size of the list II. History/Theory
51
Dr. 51 max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT L max Loo p Conditio n Assignmen t Output ● Made of statements ● Four basic constructions: ● assignements, ● conditions ● Loops ● input/output ● Made of statements ● Four basic constructions: ● assignements, ● conditions ● Loops ● input/output ● An expression is something that evaluate to a value ● 3 + 4 * 2 is an expression ● PRINT “Hello” is not. ● An expression is something that evaluate to a value ● 3 + 4 * 2 is an expression ● PRINT “Hello” is not. Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) II. History/Theory
52
Dr. 52 max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT L max Loo p Conditio n Assignmen t Output ● Assignment: left_value = right_value ● left_value represents the content of a RAM cell ● '=' means: “store the value of the expression right_value in left_value ” ● Not a 'true statement' neither an equation to solve!! ● Assignment: left_value = right_value ● left_value represents the content of a RAM cell ● '=' means: “store the value of the expression right_value in left_value ” ● Not a 'true statement' neither an equation to solve!! Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) II. History/Theory
53
Dr. 53 Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT L max Loo p Conditio n Assignmen t Output Condition: two forms If (boolean expression) expression_if_true If (boolean expression) { expression_if_true }else{ expression_if_false } Condition: two forms If (boolean expression) expression_if_true If (boolean expression) { expression_if_true }else{ expression_if_false } II. History/Theory
54
Dr. 54 Boolean Algebra (http://en.wikipedia.org/wiki/Boolean_algebra) ● Name in honour of George Boole (1825-1864) ● Inventor of the Boolean Algebra – Consider a set A, supplied with two binary operations ∧ (called AND), ∨ (called OR), a unary operation ¬ (called NOT) and two elements 0 (called zero) and 1 (called one), such that, for all elements a, b and c of set A, the following axioms hold: a ∨ (b ∨ c) = (a ∨ b) ∨ c associativity a ∧ (b ∧ c) = (a ∧ b) ∧ c a ∨ b = b ∨ a commutativitya ∧ b = b ∧ a a ∨ (a ∧ b) = a absorptiona ∧ (a ∨ b) = a a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c) distributivitya ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) a ∨ ¬a = 1 complementsa ∧ ¬a = 0 a ∨ (b ∨ c) = (a ∨ b) ∨ c associativity a ∧ (b ∧ c) = (a ∧ b) ∧ c a ∨ b = b ∨ a commutativitya ∧ b = b ∧ a a ∨ (a ∧ b) = a absorptiona ∧ (a ∨ b) = a a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c) distributivitya ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) a ∨ ¬a = 1 complementsa ∧ ¬a = 0 II. History/Theory
55
Dr. 55 Boolean Algebra and Logic ● From that axioms, one can prove some theorem such as: a ∨ 0 = a; a ∧ 1 = a; a ∨ 1 = 1; a ∧ 0 = 0 ● Interpretation: – 0 means “FALSE”, 1 means “TRUE” – A statement 'a' and its contrary cannot both be true: a ∧ ¬a = 0 ● Truth values can be represented as binary numbers or as voltage levels in logic circuits – many practical applications in electrical engineering and CS, as well as in maths logic. II. History/Theory
56
Dr. 56 Boolean Expressions ● In computer science, a boolean expression evaluates only to either TRUE or FALSE – Representation of truth values may differ from one language to another ● C: FALSE = 0, TRUE = !FALSE ● Java: TRUE= true, FALSE= false ● LISP: FALSE= '(), TRUE= NOT FALSE,... ● A boolean expression can be almost anything... 3>5 2<3 1≤1 FTTFTT 1≤1 AND 2<3 2 5 NOT 1≤1 TTFTTF “bye” == “boa” “by” < “bye” NOT “by” FT?FT? II. History/Theory Symbol for comparison in C Symbol for NOT in C
57
Dr. 57 Boolean Operators Table II. History/Theory
58
Dr. 58 Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) PRINT “Hello” If (person has a PhD) PRINT “Dr.” PRINT name PRINT “Hello” If (person has a PhD) PRINT “Dr.” PRINT name II. History/Theory PRINT “Hello” If (person is a male) { PRINT “Mr.” }else{ PRINT “Mrs.” } PRINT name PRINT “Hello” If (person is a male) { PRINT “Mr.” }else{ PRINT “Mrs.” } PRINT name Execution for Dr.Pierre: “Hello Dr. Pierre” Execution for Dr.Pierre: “Hello Dr. Pierre” Execution for Mrs. Bhutto “Hello Mrs. Bhutto” Execution for Mrs. Bhutto “Hello Mrs. Bhutto” Indentation and brackets are very important! Indentation and brackets are very important!
59
Dr. 59 Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT max Loo p Conditio n Assignmen t Output Loop: many forms For (variable in “a finite set of values”) expression While (boolean expression) expression Do { expression } while (boolean expression) In all forms, you have a stop condition Loop: many forms For (variable in “a finite set of values”) expression While (boolean expression) expression Do { expression } while (boolean expression) In all forms, you have a stop condition II. History/Theory
60
Dr. 60 Count-controlled loop (http://en.wikipedia.org/wiki/Control_flow) ● The loop is repeated a given number of times – Called the “for-loop” in C language (and all its kids) II. History/Theory READ n (from keyboard?) f = 1; for (all i such that 0< i< n+1) { f = f * i; } READ n (from keyboard?) f = 1; for (all i such that 0< i< n+1) { f = f * i; } Execution for n=4 f = 1*2*3*4 = 24 = 4! Execution for n=4 f = 1*2*3*4 = 24 = 4! Is it smart to compute (n+1) on each loop? Is it smart to compute (n+1) on each loop? READ n (from keyboard?) f = 1; bound = n+1 for (all i such that 0< i< bound) { f = f * i; } READ n (from keyboard?) f = 1; bound = n+1 for (all i such that 0< i< bound) { f = f * i; } Input Output? Input Output?
61
Dr. 61 Condition-controlled Loop (http://en.wikipedia.org/wiki/Control_flow) ● Loop repeats until a given condition change – Two versions II. History/Theory READ n; f = 1 while (n > 0) { f = f * n n = n - 1 } READ n; f = 1 while (n > 0) { f = f * n n = n - 1 } “While” Loop Condition checked at the beginning password = “I4m4g33k” do { PRINT “Enter the password:“ READ string } while (string != password); password = “I4m4g33k” do { PRINT “Enter the password:“ READ string } while (string != password); “Do-While” Loop Condition checked at the end
62
Dr. 62 Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT max Loo p Conditio n Assignmen t Output Input/Output: many forms Input from keyboard, mice, file, network, parameters Output to screen, file, network, printer, returned values Input/Output: many forms Input from keyboard, mice, file, network, parameters Output to screen, file, network, printer, returned values II. History/Theory
63
Dr. 63 Input/Output: Bad example Avoid interactions PRINT “Size of the list?” READ size FROM KEYBOARD for (all i such that 0<i<size) { L i = a random number } max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT L max ON SCREEN PRINT “Size of the list?” READ size FROM KEYBOARD for (all i such that 0<i<size) { L i = a random number } max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT L max ON SCREEN Algorith m Interactions List construction II. History/Theory
64
Dr. 64 Input/Output: Functions f(x) = 3x+2 Nam e Input Output g(M) = M' such that if M(x,y), M'(0,y) Nam e Input Output What is missing for real stricter maths? Type of Input and Output! Guessed usually! Same thing in Pseudo-code! II. History/Theory
65
Dr. 65 Input/Output: Good example Use functions (subroutines) list Construct(size) { for (all i such that 0<i<size) { L i = a random number } return L; } list Construct(size) { for (all i such that 0<i<size) { L i = a random number } return L; } Index GetLargest(list) { max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } return max } PRINT “Size of the list?” READ size T = Construct(size) mi = GetLargest(T) PRINT L mi PRINT “Size of the list?” READ size T = Construct(size) mi = GetLargest(T) PRINT L mi Function calls Nam e Input Output Functions are defined by: – name – input (max?) – output (max?) Functions are defined by: – name – input (max?) – output (max?) II. History/Theory Unrelated variables Variables are only visible inside their enclosing block delimited by brackets Unrelated variables Variables are only visible inside their enclosing block delimited by brackets
66
Dr. 66 max = 0 for (all i such that 0<i<|L|) { if (L max < L i ) max = i } PRINT max Loo p Conditio n Assignmen t Output Example: 31415 Value Printed is 4 Example: 31415 Value Printed is 4 Algorithm Example: largest number Pseudo-code (http://en.wikipedia.org/wiki/Pseudo-code) II. History/Theory Index is returned, not the actual value!
67
Dr. 67 index = 0 max = index index < |L| ? L max < L index ? max = index Yes NoNo NoNo index = index + 1 Algorithm Example: largest number Flowchart (http://en.wikipedia.org/wiki/Flow_chart) Star t End return max II. History/Theory Should be explicit here! Example: 27182 Largest: 3 Example: 27182 Largest: 3
68
Dr. 68 Flowcharts – Common Symbols SymbolName Terminal Process Flow- line Decisio n Input/Output Functio n Beginning or end of a program Flow of logic Calculation or data manipulation Comparison, Question, Decision that determines alternative paths to be followed Input or Output of data II. History/Theory
69
Dr. 69 int largest_index(numbers[] t, int n) { int i = 0; int max = i; for (i = 0; i < n; i++) { if (t[max] < t[i]) max = i; } return max; } int largest_index(numbers[] t, int n) { int i = 0; int max = i; for (i = 0; i < n; i++) { if (t[max] < t[i]) max = i; } return max; } II. History/Theory Algorithm Example: largest number C-code (http://en.wikibooks.org/wiki/Computer_programming) Data Type List represented as an array Abbreviations: i++ means i = i +1 Statements end with a semi- colon
70
Dr. 70 Back to Turing Machines ● We have seen that a Turing Machine is one representation of an algorithm – There are other ways to represent algorithm – A string of characters can represent an algorithm ● Pseudo code or Programming Language ● A TM needs an Input to work properly (as any algorithm) ● So, given a string of characters, can we prove it is the actual representation of a TM? ● Given a TM and a string, can we prove that the given string represents the given TM? II. History/Theory
71
Dr. 71 The Halting Problem (Turing, 1936) Given a TM, say t, and its initial input, say n, can we construct another TM that determines whether t halts on 'n' (the alternative is that t runs forever). ● halt(t,n) == true if t halts on n, false otherwise. ● Suppose that such a TM machine exists. ● Consider: boolean trouble(s) { if (halt(s,s) == true) { loop forever; // Implementation? else { return true; } } String representing an algorithm II. History/Theory
72
Dr. 72 Halting Problem (Turing, 1936) ● trouble() takes the string 's' (representing an algorithm) and gives it to the (supposed existing) function halt() both as the the algorithm to check and as its initial input. ● Consider the string 't' that represents the algorithm trouble() ● If trouble(t) halts (it returns true ) – halt(t,t) returns false, hence trouble(t) does not halt! ● If trouble(t) does not halt – halt(t,t) returns true, hence trouble(t) does halt! II. History/Theory
73
Dr. 73 Halting Problem (Turing, 1936) ● The Halting Problem is undecidable in the Turing system – And also in any other computation model that is equivalent ( Markov algorithms, Lambda calculus,... ) ● Many other problems are undecidable – Proved by reduction: ● we don't know if a given problem is decidable or not. ● we prove that solving this problem is equivalent to solving the HT problem. ● So it is also undecidable! – Informally, such problems cannot be solved in general by computers II. History/Theory
74
Dr. 74 Decision Problems (http://en.wikipedia.org/wiki/Decision_problem) ● A decision problem is a question in some formal system with a yes-or-no answer. ● Problems with more complex answers are called function problems. ● The problem itself is distinct from the methods used to solve it, called algorithms. ● A decision problem which can be solved by some algorithm is called decidable. ● Example: – "Given two numbers x and y, does x evenly divide y?". II. History/Theory
75
Dr. 75 Computability Theory (http://en.wikipedia.org/wiki/Recursion_theory http://en.wikipedia.org/wiki/Computability_theory_(computer_scien ce)) ● Which problems are computationally solvable using different models of computation. ● Do not deal with how efficiently a problem can be solved, rather than whether it is solvable at all – The amount of resources is not take into account ● Formal models of computation have been defined – TM is only one of them ● Classification of unsolvable problems – Turing degree (degree of unsolvability) II. History/Theory
76
Dr. 76 Church's Lambda Calculus (1936) (http://en.wikipedia.org/wiki/Lambda_calculus) ● Formal system designed to investigate function definition, function application, and recursion. ● Every expression stands for a function with a single argument – f(x) = x + 2 --> x. x+2 f(1)=3 --> (x. x+2) 1=1+2=3 – g(x,y)=x-y --> x. (y. x-y)=xy. x-y; g(3,2)=1--> (xy. x-y)) 3 2 = (y. 3-y) 2 = 3-2 = 1 – g(f(1),f(0)) = f(1)-f(0) = (1+2)-(0+2) = 3+2 = 5 --> (xy. x-y) ((x. x+2) 1) ((x. x+2) 0) Returns a number Returns a function II. History/Theory
77
Dr. 77 Church's Lambda Calculus (1936) (http://en.wikipedia.org/wiki/Lambda_calculus) ● (xy. x - y) 7 2; (y. 7 - y) 2 and 7 - 2 are equivalent ● This equivalence of lambda expressions can not be decided by an algorithm in general ● Consider: (x. x x) (x. x x) --> No reduction! ● Logic and predicates TRUE := xy. x, FALSE := xy. y AND := pq. p q FALSE, OR := pq. p TRUE q NOT := p. p FALSE TRUE, IFTHENELSE := pxy. p x y II. History/Theory
78
Dr. 78 Basis of Programming Languages ● Turing Machine leads to usual representation of algorithms – expressed in an iterative way, in sequences of well defined steps ● -calculus leads to another way of expressing algorithms – expressed using only functions – Use recursivity extensively ● Same expressive power than Turing Machine – Proven! II. History/Theory
79
Dr. 79 (defun f (n) (if (< n 2) 1 (* n (f (- n 1))) ) (defun f (n) (if (< n 2) 1 (* n (f (- n 1))) ) II. History/Theory Functionnal language Example (http://en.wikibooks.org/wiki/Computer_programming) Only functions Prefix notation Recursive call (f 4) = 24 = 4! ; (f n) = n! Prefix notation example: f(x-y)+ z --> (+ (f (- x y)) z) Where are data types? Inferred!
80
Dr. 80 Church-Turing Thesis (http://en.wikipedia.org/wiki/Church-Turing_thesis) ● hypothesis about the nature of computers – digital computer – human with a pencil and a paper following a set of rules. ● claims that any calculation that is possible can be performed by an algorithm running on a computer, provided that sufficient time and storage space are available. – may be regarded as a physical law or as a definition, as it has not been mathematically proven. II. History/Theory
81
Dr. 81 The Art of Computer Programming (http://en.wikipedia.org/wiki/The_Art_of_Computer_Programming) ● Monograph written by Donald. E. Knuth ● Started in 1962 ● 2006: 7 Volumes ! ● Considered by the American Scientist as one of the best twelve physical-science monographs of the 21 th century ● Computer science community regards it as the first and still the best comprehensive treatment of its subject. ● Bill Gates: "If you think you're a really good programmer... read (Knuth's) book...You should... send me a resume if you can read the whole thing." II. History/Theory
82
Dr. 82 – Gives solutions to common programming problems found in computer sciences ● Data structures, sorting, searching, lexical analysis, graphs,... – Complexity analysis of each solution is also described ● Example: number of steps required to sort a list – Algorithms are written in pseudo-assembly language called MIX ● May be hard to understand – Accessible algorithms textbooks use high-level languages II. History/Theory The Art of Computer Programming
83
Dr. 83 Complexity Theory (http://en.wikipedia.org/wiki/Computational_complexity_theory) ● Study the resources, or cost, of the computation required to solve a given computational problem. ● Cost is measured in terms of abstract parameters such as time and space – computational resources. ● Time: number of steps required ● Space: quantity of information storage required ● A Complexity Class is the set of all of the problems which can be solved using a certain amount of a certain computational resource. II. History/Theory
84
Dr. 84 Complexity Theory (http://en.wikipedia.org/wiki/Computational_complexity_theory) ● Tradeoffs between time and space ● Alternative algorithm may require less time but more space (or vice versa) to solve a given problem. ● Parallel processors can also be considered. – "parallelizable time" and "non-parallelizable time" (i.e. sequential time) are considered. – Sequential time gives a limit to how far the computation can be parallelized. Some steps must be done sequentially because they depend on the results of previous steps. II. History/Theory
85
Dr. Practical Complexities II. History/Theory
86
Dr. Practical Complexities II. History/Theory Complexities below exponential are practically feasible
87
Dr. Complexities Consequences ● www.top500.org: best computers in the world www.top500.org ● 2006: next generation will be beyond PetaFLOPS/s – 10 ^12 instructions per second! ● For a problem of “size” 100 – Algorithm in n 2 instructions requires 100*100 = 10,000 instructions, less than 1 second – Algorithm in 2 n requires 2 100 instructions – 2 100 > 10 ^30 instructions, more than 400 millions of years of computation!! II. History/Theory
88
Dr. 88 Example: Travelling Salesman Problem (TSP) ● Given: – a set of cities, – the distance between them ● Find the cheapest round- trip route that visits each city exactly once and then returns to the starting city Brute force requires n! steps Best algorithm requires 2 n steps Brute force requires n! steps Best algorithm requires 2 n steps II. History/Theory
89
Dr. 89 Polynomial Complexity Class: P (http://en.wikipedia.org/wiki/P_(complexity)) ● P is the set of decision problems that can be solved by a TM in polynomial time. – Intuitively, set of problems which can be effectively solved in the worst cases ● Examples: – Greatest Common Divider, – Sorting, Searching, Merging,... – “is a number prime” (proven in 2002) ● Majority of problems in P are “practically feasibles” – Rare are the ones that needs n 10000 steps! II. History/Theory
90
Dr. 90 Non-deterministic Polynomial Complexity Class: NP (http://en.wikipedia.org/wiki/NP_(complexity)) ● The complexity class NP is the set of decision problems that can be "verified" by a TM in polynomial time – They may not be solved by a TM in polynomial time but the answer should be checkable efficiently (in polynomial time) ● Examples: – Integer factorization – Decision version of the TSP (is there a route with cost < x?) – Subset-sum problem (is there any subset of {-2, -3, 15, 14, 7, - 10} that sum to zero? II. History/Theory
91
Dr. 91 P vs NP (http://en.wikipedia.org/wiki/Complexity_classes_P_and_NP) ● P: the set of “easy to solve” problems ● NP: the set of “easy to check” problems ● P ⊆ NP – Easy to solve problem are also easy to check! – Is the reverse true: is P ⊇ NP, hence is P == NP? ● Is an easy to check problem, easy to solve? ● Concept of NP-completeness – NP-complete problems are the most difficult problems in NP II. History/Theory
92
Dr. 92 NP-Complete Problems (http://en.wikipedia.org/wiki/NP-complete) ● A decision problem C is NP-C if: – it is in NP and it is NP-hard (every other problem in NP is reducible in polynomial time to it) – A reduction is a transformation of one problem into another problem. ● Intuitively, if problem A is reducible to problem B, a solution to B gives a solution to A. Thus solving A cannot be harder than solving B (we write A ≤ B) ● TSP is NP-Complete – So any instance of any problem in NP can be transformed mechanically into an instance of the TSP problem in polynomial time!! II. History/Theory
93
Dr. 93 Consequences ● If one find a polynomial algorithm that solves TSP, then polynomial algorithms can be provided for any other problems in NP And in this case, P == NP!! II. History/Theory
94
Dr. 94 List of NP-C Problems (http://en.wikipedia.org/wiki/List_of_NP-complete_problems) ● First NP-C by Cook in 1971 – The boolean satisfiability problem (very complex proof) – Proof by reduction was then used to show than many other problems are NP-C (more than 3000 are known to be NP-C problems)! – TSP is just one of them ● Many important problems are NP-C – Mathematics, Physics, Computer Sciences, Biology, Finance,... II. History/Theory
95
Dr. 95 The big question: is P == NP ? ● Not a single fast algorithm for any of the known NP-C problem is known ● Hence, we don't know if P==NP – Unsolved question in theoretical computer science. – One of the most important unsolved problems in all mathematics. – The Clay Mathematics Institute has offered a USD 1,000,000 prize for a correct solution. – 2002: poll of 100 researchers: 61 no, 9 yes, 22 unsure, 8 impossible to prove or disprove! II. History/Theory
96
Dr. 96 Theory of Computation (http://en.wikipedia.org/wiki/Theory_of_comp) ● Two major fields ● Computability theory (Turing, Church, Bool) – Is a given problem computable? ● Complexity Theory (Knuth et al.) – How much ressources (instructions, storage) are required to compute a solution for a given problem? – Some problems are theorically computable but seems practically unfeasible (take centuries even with the tomorrow best machine available). ● Example: Factorisation of big prime numbers (crypto) ● Still not proven today! II. History/Theory
97
Dr. 97 Languages http://en.wikipedia.org/wiki/History_of_programming_language s II. History
98
Dr. 98 Programming Languages (http://en.wikipedia.org/wiki/Programming_languages) ● Writing program in the machine language – called assembly language -- is painful and error prone ● Define languages that are more or less human friendly – Use a syntax, a grammar and define the semantic ● Translate human-friendly languages into machine language – Compilation: translate entirely, then execute – Interpretation: translate partially, then execute (repeat until the end of the program) II. History/Languages
99
Dr. 99 Operating System Compilation vs Interpretation (http://en.wikipedia.org/wiki/Interpreted_language http://en.wikipedia.org/wiki/Compiled_language) X=20; while(X > 0) { PRINT X; X := X-1; } X=20; while(X > 0) { PRINT X; X := X-1; } 011001010110110110 100101011010101011 001100110010101011 011001010100011000 001110101010101001 Compile r Interpretor X=20->0110 While->1010 Source file Executabl e file Executabl e file running II. History/Languages
100
Dr. 100 Compilation vs Interpretation (http://en.wikipedia.org/wiki/Interpreted_language http://en.wikipedia.org/wiki/Compiled_language) ● In theory, any language can be interpreted or compiled (implementation problem) ● In practice, language designers make choices that ease either interpretation or compilation ● Static variable type declaration (i.e. number, characters) ● Compilation – Pros: speed, error checking – Cons: complexity, long edit-run cycles ● Interpretation – Pros: short edit-run cycles, flexibility – Cons: slow, lack of checks II. History/Languages
101
Dr. 101 Mixed mode ● Compile source code into a bytecode – Perform all required checks – Bytecode is independent of any real hardware architecture ● Interpret the bytecode – A bytecode interpreter is required on each hardware you want to run your (compiled) program on ● Write once, run anywhere – This is called transportability: only the bytecode is needed to execute a program, neither the source nor the machine dependant code. II. History/Languages
102
Dr. 102 Programming Paradigms (http://en.wikipedia.org/wiki/Programming_paradigm) ● Logic Programming – Define assertions to find a goal – Based (roughly) on the Boolean Algebra ● Imperative languages – List of statements that change a program state – Based on the Turing Machine model ● Functional languages – Sequence of stateless function evaluations – Based on the Church -calculus II. History/Languages
103
Dr. 103 Type System (http://en.wikipedia.org/wiki/Type_system) ● Anything in a computer is represented by 0&1 – How to distinguish 11 10 (eleven), 11 2 (three), and “11” the string of two characters '1' and '1'? – A type give a meaning to a collection of bits ● inform programs and programmers how they should treat a given collection of bits. ● hardware makes no distinction between memory addresses, instruction code, characters, integers and floating-point numbers. II. History/Languages
104
Dr. 104 Type Functions ● Safety – “Hello World”/3 is meaningless ● Documentation – “ Integer x = 24; ” versus “ Age x = 24; ” ● Abstraction ● e.g: “ String ” represents an abstract data type ● The underlying implementation (typically) uses an array of characters ● Functions can be defined on String without any knowledge of their actual representation – Substring(String s, String p), Match(String s, String p), getChar(Index i),... II. History/Languages
105
Dr. 105 Type Checking ● Verify and enforce the constraints of types ● Static type checking – At compile time ● Dynamic type checking – At runtime II. History/Languages
106
Dr. 106 Static vs Dynamic ● Static Pros – Reliability – Optimisation for runtime speed – Documentation ● Static Cons – More things to write – Illusion that the code is safe – Longer Edit-Compile-Test- Debug cycle ● Dynamic Pros – Rapid prototyping – Edit-compile-test-debug cycle reduced – Generic constructions (eval function over anything) – Metaprogramming easy ● Dynamic Cons – Runtime speed II. History/Languages
107
Dr. 107 Strong vs Weak Typing var x := 5; // (1) var y := “20”; // (2) var z := x + y;// (3) var x := 5; // (1) var y := “20”; // (2) var z := x + y;// (3) Is this allowed? ● Strong typing: refused because x and y are of inconsistent type. ● Weak typing system: accepted ● Result can be: 25 or “25” or “520”... ● Depends on the language ● Strong typing: refused because x and y are of inconsistent type. ● Weak typing system: accepted ● Result can be: 25 or “25” or “520”... ● Depends on the language II. History/Languages
108
Dr. 108 Primitive Types (http://en.wikipedia.org/wiki/Primitive_type)http://en.wikipedia.org/wiki/Primitive_type ● Basic building block – Any other data type is a composition of primitive types – Integer, booleans, characters, floating point numbers – Reference ● An abstract value refering to another object's possibly a much larger one. ● Operations on primitive types are usually mapped to direct machine instruction – Fastest operation available II. History/Languages
109
Dr. 109 Primitive Type Representation in C (Int, Bool & Char) ● Integer: binary notation on 32 bits – Signed [-2 31,2 31 -1] & unsigned [0,2 32 -1] ● Boolean: FALSE == 0, TRUE == !FALSE ● Character: encoding in ASCII (1 byte) – 33 non-printable characters (ENTER, DELETE,...) ● Control characters – 95 printable characters inluding space !"#$%&'()*+,-./0123456789:; ?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` abcdefghijklmnopqrstuvwxyz{|}~ II. History/Languages
110
Dr. 110 ASCII Table (http://en.wikipedia.org/wiki/ASCII) ● Only 127 values – Only English – Extensions to 255 values ● Spanish, French,... ● Unicode is a better encoding ● 16 bits, 65536 values ● Any language in the world! ● Supported by new OS and languages II. History/Languages
111
Dr. 111 Real numbers and other-than-decimal bases ● How to represent 0.1 in base 2? – 320.14 = 3.10²+2.10 1 +0.10 0 +1.10 -1 +4.10 -2 – so, in a base b, we have (a n...a 1 a 0.c 1 c 2...) b = a n.b n +...+a 1.b 1 +a 0.b 0 +c 1.b -1 +c 2.b -2 +... – (0.1) 10 =(1) 10 /(10) 10 =(1) 2 /(1010) 2 =(0.000110011001100....) 2 =(0.00220022...) 3 =(0.01212...) 4... – (1/3) 10 =(0.33...) 10 =(0.1) 3 ● =(11.0010010000111111011010101...) 2 II. History/Languages
112
Dr. 112 The IEEE 754 standard – Float: 32 bits, double: 64 bits II. History/Languages ● Mantissa is normalized: always a '1' before the comma (hidden bit) 0.0000111010x2 0 0.000000111010x2 2 1.111010x2 -5 all represent the same number! ● Exponent is biased: only positive values [-127,128]=[0,255]-127
113
Dr. 113 IEEE 754 Standard Example ● Consider only 5 bits (1,2,2) biased is 1 2134567 0 1.5 1.2 5 1.7 5 2.53.5 0.87 5 All Positive Number s 0.5 0.7 5 0.62 5 - 0.5 II. History/Languages
114
Dr. 114 ● No representation for 0 (zero) – Reserve 0 00 00 and 1 00 00 for (+0 & -0) (symetric) – We lose +0.5 and -0.5 IEEE 754 Standard Example Problems & Solutions 2134567 1.5 1.2 5 1.7 5 2.53.5 0.87 5 0 0.7 5 0.62 5 - 0.625 II. History/Languages
115
Dr. 115 ● Big hole around 0 – Reserve 'e=0' for denormalized number ● The hidden bit is '0' in this case: 0.2 0 +(m) 0 00 01 = 0.2 0 +0.2 -1 +1.2 -2 =0.25 0 00 10 = 0.2 0 +1.2 -1 +0.2 -2 =0.5 0 00 11 = 0.2 0 +1.2 -1 +1.2 -2 =0.75 IEEE 754 Standard Example Problems & Solutions 2134567 1.5 1.2 5 1.7 5 2.53.5 0 0.7 5 0.5 - 0.25 - 0.5 0.2 5 - 0.75 II. History/Languages
116
Dr. 116 ● Define meaning for infinite and indefinite – Reserve e=3 for that purpose IEEE 754 Standard Example Problems & Solutions 213 1.5 1.2 5 1.7 5 2.53.5 0 0.7 5 0.5 - 0.25 - 0.5 0.2 5 - 0.75 II. History/Languages
117
Dr. 117 – Even if we cannot represent all integers (infinite), we can represent correctly a small interval ● With real numbers, it is not possible!! ● Between two reals, you can always find a new one! ● So we can only represent a subset of rationals ( ℚ ) – Computing with floating points is very time consuming ● Specific hardware for that purpose (integrated FPU) ● Floating Point Operations/second (Flops) is a standard metric of processor performance. ● 2006: IBM Blue Gene: 65536 Dual-Processor (PowerPC ) 360 TeraFLOPS! Problems with the representation of real numbers II. History/Languages
118
Dr. Primitive Type Representation in C (pointers) ● References are implemented as pointers – Pair (a,t) where: – a : is an integer representing a RAM cell address – t : is a type that gives the interpretation of the memory cells that starts from address a ● t is mandatory, how can you know how to interpret the data at the given address 'a' otherwise? II. History/Languages
119
Dr. 119 – 'int* p': declares a reference (a pointer) called p on an 'int' value ● 'p' holds a number (a positive integer called a word) – '&v' is the address of the variable v in the RAM ● It is a number (a positive integer called a word) – *p holds the value contained in the cell at address 'p' Primitive Type Representation in C (pointers) II. History/Languages
120
Dr. 120 char c = 'A'; char* pc = &c; *(pc+1)='C'; *((int *) (pc)) = 'D'; &p c 65 ?? ? &c 66 67? ? &c 65 ?? ? &c&c 0 00 68 &c *pc = 'B'; 66 ?? ? &c We can change the content of the memory through pointers. We can change the content of the memory through pointers. We can do some arithmetic with pointers. We can change the type of a data (cast). Using Pointers (in C) '&' == "address of" II. History/Languages
121
Dr. 121 Pointers Manipulation ● The pointer concept is a very efficient mechanism to manipulate directly the memory – Almost everything is possible ● Used for system programming ● Also responsible for the vast majority of bugs – New trend is to forbid the use of pointers (Java, C#) ● In C, arrays, functions and strings are de facto pointers – char * s = "Hello World"; – char[] c = s; *(c+1) = '3'; printf(s); --> H3llo World II. History/Languages
122
Dr. 122 Important Languages ● 1954 – FORTRAN (imp., comp., static, strong) – Designed for scientist – Versions for Parallel Machine ● 1958 – LISP (func., inter & comp, dyn, strong) – Based on -calculus – Used in Artificial Intelligence ● 1959 – COBOL (irrelevant, comp, static, strong) – For Business – Still widely used but no more learnt II. History/Languages
123
Dr. 123 Important Languages ● 1964 – BASIC (imp, inter. & comp, static, weak) – For beginner ● 1970 – Pascal (imp, comp, static, strong) – Structured programming ● 1972 – C (imp, comp, static, weak) – System programming – UNIX Systems (and Linux) are written in C – Gnome is written in C ● 1972 – Smalltalk (imp, mixed, dynamic, strong) – Object Oriented (OO) Programming II. History/Languages
124
Dr. 124 Important Languages ● 1972 – Prolog (logic, inter, dynamic, strong) – Based on Boolean Algebra – Natural language processing ● 1978 – SQL (irrelevant, inter, dynamic, strong) – Database oriented languages (Query) ● 1983 – Ada (imp, comp, static, strong) – Embedded and real-time systems – Ariane space launcher II. History/Languages
125
Dr. 125 Important Languages ● 1983 – C++ (imp, comp, static, ~strong) – Patchwork of C ;-) – Claim to be an OO Language ;-) – Widely used because of Microsoft adoption – Windows (95, 98, NT, XP) is written in C++ – KDE is also written in C++ ● 1985 – Eiffel (imp, comp, static, strong) – True OO Language! – Design by contract (software quality) II. History/Languages
126
Dr. 126 Important Languages ● 1987 – Perl (imp, inter, dynamic, weak) ● Easy & Widely used by web designers ● 1995 – Java (imp, mixed, static & dyn, strong) ● “write once, run anywhere” language ● Widely used (smartcards to supercomputers) ● Object Oriented ● 2000 – C# (imp, mixed, static & dyn, strong) ● Microsoft defence against Java ● Similar to Java on many aspects II. History/Languages
127
Dr. 127 Language Trends ● Ruby – Multi-paradigm programming language ● Concurrency and distribution – E: java based – C: microsoft based ● And many others... II. History/Languages
128
Dr. 128 Operating Systems II. History
129
Dr. 129 Objectives ● Theories provide strong fondations to: – Express algorithms (TM, -calculus,...) – To analyse them (Computability/Complexity) ● Languages have been defined to help in the writing of programs (hence algorithms) ● Even if not required, a computer system usually has an operating system. II. History/OS
130
Dr. 130 OS definition ● No widely admitted definition ● Fact: a computer is made of several parts – devices (keyboard, hard drive, memory, CPU,...) – programming them is a very complex task ● the OS provides an abstract view of the real machine that is much simpler to program – Data on an hard drive is seen as an organized collection of files instead of a collection of bits – their management should be optimal ● the OS handles all different resources for the user – If three print jobs are simultaneously submitted on the same printer, they should be queued II. History/OS
131
Dr. 131 OS composition ● kernel (strictly equal to OS) – handles resources and provides the abstract “easy to program” machine ● shell – interaction with the user through command line – Syntax: command -option parameter ● e.g: mail -u pierre@giki.edu.pk “Mail example”pierre@giki.edu.pk ● Applications for System Administration – Managing user accounts – Managing storage spaces – Managing devices II. History/OS
132
Dr. 132 OS composition ● Graphical User Interface is not (and should not) be part of an OS – code complexity – security ● GUI provides a user-friendly way of using a computer ● Some OS neither have a shell nor a GUI – Embedded devices (satellite, smart cards,...) II. History/OS
133
Dr. 133 pre-Multics systems ● 1950: computers were giant personal computers ● Only one user at a given time ● 1960: Batch systems ● Users submit their job to the operator (cards) ● Operator groups jobs into batch and enter them for execution ● Most of the time, the CPU is idle waiting for some input (user, disk, network,...) ● 1962: Time sharing (CTSS at the MIT) ● When the CPU is idle for one job/user, execute/resume another one II. History/OS
134
Dr. 134 Market evolution: Multics ● 1964: Success of CTSS leads to Multics ● By the MIT, Bell Labs and General Electric ● Very advanced operating system – Hundreds of users on a pre-Pentium machine (Intel 386)! – Hardware components could be added at runtime (even CPU) ● Not a success anyway: too much in advance! ;-( ● Many ideas of current operating systems comes from it! ● Highly influential! ● 1970: Unix comes out from Ken Thompson ● Worked at Bell on Multics before Bell pulled out ● He developed a smaller Multics version called Unics, that should do only one thing, but do it well. II. History/OS
135
Dr. 135 Market evolution: the Unix fashion ● 1974: Research paper by Ritchie & Thompson ● Describe the Unix system (re)-written in the C language ● Received the prestigious ACM Turing Award ● Many universities asked for a copy of Unix ● Unix: widely adopted ● Availability of the source code: modifications by any one to fit the needs ● USENIX Conferences --> lots of enhancements ● 80's: The Portability Chaos ● Many Unix existed (and still exist), some are incompatibles --> POSIX (Portable Operating System) ● Commercial failure for IBM, Sun, Bell,... and Microsoft! II. History/OS
136
Dr. 136 Unix Wars II. History/OS
137
Dr. 137 The Home Computer Era (http://en.wikipedia.org/wiki/History_of_computing_hardware_(1960s-present)) ● 1973: Xerox Alto mini-computer – first mouse and GUI concept ● 1975: MITS Altair 8800 first home computer – Great success: 10,000 shipped – Paul Allen and Bill Gates developed a BASIC interpreter for the Altair, and then formed Microsoft. – CP/M-80 is the OS developed by Digital Research ● 1977: Apple II phenomenon – Steve Jobs founded Apple Computer. – Color graphics, open architecture, floppy disk drive II. History/OS
138
Dr. 138 The IBM Personal Computer Era (http://en.wikipedia.org/wiki/History_of_computing_hardware_(1960s-present)) ● Many other concurrent – Commodore, Atari, Amiga,... – Closed architecture --> disappeared ● 1981: IBM PC model – IBM replied to Apple – Open architecture – Uses Intel 8088 processor – OS: MS-DOS provided by Microsoft ● MS-DOS is based on QDOS, a CP/M compatible OS which Microsoft had obtained the copyrights. ● Digital Research refused to provide CP/M to IBM in 1980 II. History/OS
139
Dr. 139 The Mac Era (http://en.wikipedia.org/wiki/History_of_computing_hardware_(1960s-present) http://en.wikipedia.org/wiki/Apple_Computer) ● 1981: Xerox Star – Bit-mapped display, windows-based GUI, icons, folders, mouse, Ethernet networking, file servers, print servers and e- mail. ● 1984: Apple Macintosh – First mass-marketed microcomputer with a GUI – Standard for the personal computer for years ● Until 1990 in the IBM PC world – Gaming is the big market – It requires power --> faster CPU, bigger RAM,... II. History/OS
140
Dr. 140 The Microsoft Era (http://en.wikipedia.org/wiki/Microsoft_Windows http://en.wikipedia.org/wiki/Windows_NT) ● 1990: Windows 3.0 by Microsoft – First GUI in the IBM PC world – On top of MS-DOS (highly limited) ● 1995: Windows 95, 1998: Windows 98 – Still based on MS-DOS – End of Apple domination until 1998 with the iMac series by Steve Jobs ● 1993: Windows NT 3.1 – Fully 32-bits OS written from scratch – Uses concepts derived from DEC VAX OS ● 2001: Windows XP, is in fact NT v 5.1 II. History/OS
141
Dr. 141 The Open Source Revolution (http://en.wikipedia.org/wiki/GNU) ● 1983: Richard Stallman quit its job at MIT – Refused to work in a closed environment – Creates the GNU project: a free operating system ● Free as in free speech: free to study and modify the code as it was in the 60's and 70's ● 1985: RS creates the Free Software Foundation ● 1989: Creation of the GNU Public Licence – Basically, you can redistribute (even a modified version of) a GPL software but with its code – Virus-like licence – You can sell a GPL software (Redhat, Suse,...) II. History/OS
142
Dr. 142 The GNU Project (http://en.wikipedia.org/wiki/GNU) ● GNU means Gnu's Not UNIX (recursive) – Should be UNIX compatible anyway – GNU Hurd will be the name of the kernel ● 1990: GNU System almost complete – Compiler: GNU C Compiler – Editor: GNU Emacs – All other parts (shell, libraries, GUI,...) – A lot have been done but, the kernel (Hurd) is the only piece that is missing... II. History/OS
143
Dr. 143 The Linux Kernel (http://en.wikipedia.org/wiki/Linux_kernel) ● August 1991: Linus Torvalds posts in Internet – “I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. [...] I'd like any feedback [...].” – He wrote a kernel, using all the GNU tools – A kernel was the only thing that GNU was lacking to become operational ● Evolution: – 1991: v 0.01 (10,239 lines of code) – 2006: v 2.6.16.11 (6,981,110 lines of code) ● Big support from IBM, HP,... II. History/OS
144
Dr. 144 GNU/Linux Distributions (http://en.wikipedia.org/wiki/Comparison_of_Linux_distributions http://en.wikipedia.org/wiki/Linux) ● Distribution: GNU + linux kernel + tools for system administration – Installing the system – Installing, upgrading, removing softwares – Configuring softwares ● Many flavors – User friendly: Fedora, Mandrake, Suse, Ubuntu – LiveCD: Knoppix, Mandrake-CD – Stability: Debian – Source based: Gentoo II. History/OS
145
Dr. 145 Other open source UNIX projects ● BSD based (Open source) – FreeBSD (Optimized for x86) – NetBSD (Portable) – OpenBSD (Security) ● Sun Solaris (Open Source) – For SPARC and x86 – Designed for the industry (stable,...) ● And many others... II. History/OS
146
Dr. 146 Open Source Equivalences (http://en.wikipedia.org/wiki/List_of_open_source_software_packag es) – GUI: Windows (Microsoft), Darwin (Mac OS X) ● KDE, GNOME, CDE, Enlightenment,... – Web Browsers: IE (Microsoft), Safari (Mac OS X) ● Firefox (available on Windows), Konqueror – Email: Outlook (Microsoft) ● Evolution, Kmail – Office Suite: MS Office (Microsoft) ● OpenOffice (available on Windows), KOffice – Image Manipulation: Photoshop (Adobe) ● The Gimp – etc... II. History/OS
147
Dr. 147 File System (http://en.wikipedia.org/wiki/File_system) ● Method for storing and organizing compuer files and the data they contain – Easy to find, and access ● Usually use an underlying storage device – Hard Drive – CD-ROM – USB Stick ● Not required – Network connection – Any informations (/proc on Linux) II. History/OS
148
Dr. 148 File System Files & Directories ● A directory (folder) is a mapping between a file name and the actual file (data) ● Directory structure can be: – Flat: all files into one folder – Hierarchical: folder can contain files and folders ● Attributes – Permissions (owner, groups, others in UNIX) – Creation, Modification date ● Extended Attributes – Icons, Author,... II. History/OS
149
Dr. 149 File System Files & Directories ● In console mode, ● '.' means the current directory ● '..' means the parent directory ● MS-DOS comes from CP/M which comes from UNIX hence the similarities ● Hierarchical File System ● Shell and command (cp, mv,...) ● Unfortunately Bill Gates also wanted to mark its differences ● Hence drive letters (A:, B:, C:,...) ● Hence the '\' vs '/' as a path separator ● Problems nowadays when building applications for both world! II. History/OS
150
Dr. 150 File System Issue Example: External Fragmentation (http://en.wikipedia.org/wiki/Fragmentation_(computer)) Remove C,E ABCD FE ABD F Create: G = G1G1 G2G2 + ABG1G1 D FG2G2 After many operations (Create, Remove): Leads to performance problem: reading the red file requires 4 movements. Hard Drives are 1,000,000 times slower than CPU! II. History/OS
151
Dr. 151 File System Issue Example: External Fragmentation (http://en.wikipedia.org/wiki/Fragmentation_(computer)) ● Solutions: – Windows (FAT, NTFS): defragment ● Run a software that reorganize files in a contiguous manner. ● 30 % of available free space is recommanded for the defragmentation process (source: Microsoft) – UNIX: keep external fragmentation below a given treshold (~5, 10 %) ● When file system operations are performed, it uses a smart algorithm. ● Works very well when the free space available is above 20% II. History/OS
152
Dr. 152 Other OS Issues ● Process Scheduling – Ensuring fairness, performance, throughput, interactivity, all at the same time! – Dealing with multi-CPU, multi-cores, multi-threads,... ● Memory Management – Preventing fragmentation – Efficiency (cache,...) ● And also... – Security, stability, reliability, usability,... II. History/OS
153
Dr. 153 Networking II. History http://en.wikipedia.org/wiki/Computer_networking
154
Dr. 154 Networking Needs ● Now we have: – Computer Hardware – Theory to describe algorithms – Languages to write algorithms – Operating Systems to manage resources to make the use of hardware user and programmer friendly ● Problem at the beginning: – few computers were available; – Lots of researchers widespread ● How to share the access to costly computers? II. History/Network
155
Dr. 155 Computer Networking Definition ● Scientific (research) and engineering discipline concerned with communication between computer systems. ● Involve at least two devices – Usually, at least one is a computer. – Devices can be separated by: ● a few meters (e.g. via Bluetooth) ● or thousands of kilometers (e.g. via the Internet). ● Computer networking is sometimes considered a sub- discipline of Telecommunication II. History/Network
156
Dr. 156 Pre-ARPANet Era ● Before 1940, carrying instructions between calculation machines and early computers was done by human users. ● 1940 George Stibitz used a teletype machine to send instructions from Dartmouth College in New Hampshire to his Complex Number Calculator in New York ● 1960-1970 Kleinrock, Baran and Davies had independently conceptualized and developed network systems consisting of datagrams or packets that could be used in a packet switching network between computer systems. II. History/Network
157
Dr. ARPANet (http://en.wikipedia.org/wiki/ARPANET) ● Advanced Research Projects Agency Network – United States Department of Defense ● 1962, J.C.R. Licklider was hired by the ARPA and developed the "Intergalactic Network" working group – His ideas contained almost everything that the Internet is today. – Special type of computers will take care of the packet switching on the behalf of end-users one (big mainframe at that time) II. History/Network
158
Dr. ARPANet ● 1969: connection using 50 kbit/s circuits. – University of California at Los Angeles, – SRI (in Stanford), – University of California at Santa Barbara, – University of Utah ● Development centred around Request For Comment (RFC) still used today. ● In the World, other technology – X.25 in Europe, DataPac in Canada, FidoNet,... – and others... II. History/Network
159
Dr. ARPANet II. History/Network
160
Dr. Birth of Internet (http://en.wikipedia.org/wiki/History_of_the_Internet) ● Many different networks leads to problem in communication ● Internet is the Esperanto of Communication between Computers ● Reduce the role of network to the bare minimum ● Joining any network together whatever their characteristics are ● RFCs 791 (IP), 792 (ICMP) and 793 (TCP) defines the Internet ● Published in 1982 (First draft in 1974) ● 1983: TCP/IP becomes the only approved protocol on ARPANET II. History/Network
161
Dr. Internet for Everyone? ● ARPA's business was funding R&D – US Government Funded – Unrelated commercial use was strictly forbidden ● Connections to Military sites and Universities ● Some companies either helped in research project or provided services (e.g.: HP) ● They asked for connections and they had! ● Difficulties to define “commercial use” ● 1983, the U.S. military portion of the ARPANET was broken off as a separate network: MILNET ● 1989: first dial-up ISP (world.std.com) – Controversy in Universities! II. History/Network
162
Dr. The Growth of Internet The Exponential Growth started thanks to the WWW II. History/Network
163
Dr. The World Wide Web (http://en.wikipedia.org/wiki/History_of_the_World_Wide_Web) ● Until the 90's, finding and accessing documents available on the Internet was a real pain ● 1991: Tim Berners-Lee from the CERN Labs developed a network-based implementation of the hypertext concept ● “The WorldWideWeb (WWW) project aims to allow links to be made to any information anywhere. [...] The WWW project was started to allow high energy physicists to share data, news, and documentation. We are very interested in spreading the web to other areas, and having gateway servers for other data. Collaborators welcome!” II. History/Network
164
Dr. Web Browsers War (http://en.wikipedia.org/wiki/Browser_wars) ● 1992: Mosaic (Andreessen & Bina, UIUC Students) – First Modern (Graphical) Web Browser available for the mass market (Windows, UNIX) for free – A Revolution! ● 1994: Anderseen & Clark created Netscape – Company & Browser name – 80% used in 1996 ● 1995: Microsoft released IE v1.0 – Part of Windows 95+ (quite late!) ● The war then started! II. History/Network
165
Dr. Web Browsers War (http://en.wikipedia.org/wiki/Browser_wars) II. History/Network
166
Dr. Netscape vs Microsoft (http://en.wikipedia.org/wiki/Browser_wars) ● Adding features took precedence over bug fixing! – Derivation from standards ● “Best Viewed with XX” Campaign! ● Unfair: Microsoft released their browser packaged with their OS ● IE is not the first source of income for Microsoft, it is for Netscape ● Even if until IE v4.0, Netscape was by far superior, Microsoft was enlarging its market share automatically after each OS installation! II. History/Network
167
Dr. Netscape vs Microsoft (http://en.wikipedia.org/wiki/Browser_wars) ● Netscape business model was to sell server software ● Microsoft decided to provide for “free” IIS (Web Server) with server version of Windows ● Microsoft created licensing agreements: – With computer manufacturers requiring them to provide desktop icons for IE – With AOL to base AOL's primary interface on IE rather than Netscape ● Microsoft imposed Apple to provide IE as the default browser on the Mac for five years II. History/Network
168
Dr. First Browser War Winner: Microsoft ● 1998: End of Netscape – Purchased by AOL afterwards. ● Lack of challengers == Lack of inventions – 2001: IE v6.0 (small improvement over IE v5.5) – 2006: IE v7.0 (reason: the success of Firefox) ● When Netscape died in 1998, its source code was released with an Open-Source licence – This product was renamed Mozilla – 2002: Mozilla v1.0 rewritten from scratch ● Very popular in the Open-Source Community – 2003: AOL refused to support any longer Mozilla II. History/Network
169
Dr. Second Browser War ● From Mozilla v1.0 many other products have been created – 2004: Firefox v1.0 is released by the Mozilla foundation (light-weight cross-platform version of Mozilla) ● June 2004, major security hole in IE – Security companies and US-CERT recommend Firefox ● 2005: IE usage share dropped down to 85% – It was 95% in 2003. ● The war continue... II. History/Network
170
Dr. Searching on the Web (http://en.wikipedia.org/wiki/Search_engine) ● 1993: Lycos ● 1994: WebCrawler – First full text www search engine ● 1995: Yahoo & Altavista – Leader since 2001 ● 2001: Google – Minimal interface – Smart “unbiased” algorithm (PageRank) – Revolution: results become ordered by their relevance! ● 2004: MSN Search II. History/Network
171
Dr. Google vs Microsoft ● Linux may not be the Microsoft killer – But may be a UNIX killer! ;-) ● Google is providing many web-enabled desktop services – Search, Mail, Forums, Word, SpreadSheet,... ● Concurrent to MS Office product ● The OS does not really matter! – Having a good web browser is important! – Google is founding the Mozilla Foundation that is developing Firefox (on both Windows and UNIX) ● To be followed... II. History/Network
172
Dr. Vocabulary ● Internet: the giant Wide Area Network (WAN) of networks that uses the TCP/IP protocol for communication ● Intranet: a Local Area Network (LAN) that is using TCP/IP but that is not necessarily connected to the Internet – e.g: GIKI Intranet ● Extranet: An Intranet that is extended outside of a company – (usually over encryption on top of Internet) ● Ethernet: “hardware” link (TCP/IP is on top) II. History/Network
173
Dr. Internet “Killer Applications” ● Email was used before the Internet, it actually helps the development of Internet! ● Newsgroup: discussion in forums ● FTP: File Transfer Protocol ● WWW: World Wide Web ● Search Engines ● P2P: User to User Data Exchange ● Web 2.0 (everything runs on the server) – Word Processor, Spreadsheet, Mail Reader,... – Google is the leader (Microsoft Challenger?) II. History/Network
174
Dr. Network OSI Model (http://en.wikipedia.org/wiki/OSI_model) ● A networking system is divided into layers. ● Within each layer, one or more entities implement its functionality. ● Each entity interacts directly only with the layer immediately beneath it, and provides facilities for use by the layer above it. ● Protocols enable an entity in one host to interact with a corresponding entity at the same layer in a remote host. II. History/Network
175
Dr. Network OSI Model ● X.25 follows the OSI Model ● Internet (TCP/IP) does not!! II. History/Network
176
Dr. OSI & TCP/IP II. History/Network
177
Dr. Layers at work Abstraction: Communication from process to process Implementation: Communication from layer to layer II. History/Network
178
Dr. Layers at work Example: UDP Data UDP Data UDP Header IP Data IP Header Frame Header Frame Trailer Frame Data Application Layer Transport Layer Network Layer Link Laye r II. History/Network
179
Dr. Internet Topology (2003-11-23) Asia Pacific Europe Middle East Central Asia Africa North America Latin American Caribbean RFC1918 Unknown II. History/Network
180
Dr. Network Topology (http://en.wikipedia.org/wiki/Network_topology) II. History/Network
181
Dr. Trends ● Asymmetric DSL: download >> upload ● Wireless ● Wi-Fi, Blutooth,... ● IP implementation? ● Mobility, Topology,... ● Multimedia – VoIP -- Voice Over IP (Skype) ● Peer to Peer – Performance ● Link Layer for Wan (ATM,...) II. History/Network
182
Dr. IPv6, the future ● IPv6 (Xerox) adopted by IETF in 1994 – IPv4 address: 32 bits (4.3 billions), – IPv6 address: 128 bits (5×10 28 for each 6.5 billion people) – Many features (e.g: autoconfiguration, security) ● Support on Linux started in 1996! – 2001 fully supported ● Windows Vista will support it by default... ● Adopted by China and India – Facing problems with their population – Taking the leadership?! II. History/Network
183
Dr. 183 Conclusion III. Conclusion
184
Dr. 184 History of Computer Sciences ● Everything started with counting ● Hardware has been designed to help ● Theory were needed to understand hardware ● Languages were required to ease the commanding of hardware ● Operating Systems were designed to manage hardware and to make it appears a single unit ● Networking was set up to share the access to costly hardware. III. Conclusion
185
Dr. 185 Other CS Fields include ● Software Engineering – Project Management,... ● Artificial Intelligence – Neural Network,... ● Multimedia – Image Processing,... ● Simulation & Modelling ● Distributed Systems – Web Services,... ● Parallel Programming – Cluster, Grid Computing,... III. Conclusion
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.