COS 109 Monday October 19 • Housekeeping – Problem Set 5 and Lab 4 are available Problem Set 5 due after break!! – Midterm next week 90 minutes to take it No class next Wednesday (can do midterm here then) Will be available from Wednesday 1201 AM to Friday 1159PM on blackboard Midterm review Next Monday (10/26) at 7PM in room to be announced – Problem Set 3 returned today Second part of second problem caused some problems (adding numbers as you count down) Fibonacci problem seems to have been very challenging (flow chart easier than actual coding) • Today’s class – Programming languages (continued) – Software we depend on The operating system The file system The cloud Grades on Problem Set 3 35 30 25 20 15 10 5 0 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 Graded out of 30; average score 24.5 If you didn’t hand it in or scored below 15, you may want to talk to me Evolution of programming languages • 1940's: machine level – use binary or equivalent notations for actual numeric values • 1950's: "assembly language" – names for instructions: ADD instead of 0110101, etc. – names for locations: assembler keeps track of where things are in memory; translates this more humane language into machine language – this is the level used in the "toy" machine – needs total rewrite if moved to a different kind of CPU • Late 1950’s – Fortran and Cobol (first higher level languages) • 50’s into 60’s – Algol, Basic and LISP • 1970’s – C C code compiled to assembly language #include <stdio.h> main() { int num, sum = 0; while (scanf("%d", &num) != -1 && num != 0) sum = sum + num; printf("%d\n", sum); } (x86, Mac) Ltmp2: movl $0, -8(%rbp) movl $0, -12(%rbp) jmp LBB1_2 LBB1_1: movl -12(%rbp), %eax movl -8(%rbp), %ecx addl %eax, %ecx movl %ecx, -8(%rbp) LBB1_2: leaq -12(%rbp), %rax xorb %cl, %cl leaq L_.str(%rip), %rdx movq %rdx, %rdi movq %rax, %rsi movb %cl, %al callq _scanf movl %eax, %ecx cmpl $-1, %ecx je LBB1_4 movl -12(%rbp), %eax cmpl $0, %eax jne LBB1_1 LBB1_4: C code compiled to assembly language .LL2: #include <stdio.h> main() { int num, sum = 0; while (scanf("%d", &num) != -1 && num != 0) sum = sum + num; printf("%d\n", sum); } .LL3: add sethi or mov call mov cmp be ld cmp be ld ld add st b sethi or ld call mov ret (SPARC) %fp, -20, %g1 %hi(.LLC0), %o5 %o5, %lo(.LLC0), %o0 %g1, %o1 scanf, 0 %o0, %g1 %g1, -1 .LL3 [%fp-20], %g1 %g1, 0 .LL3 [%fp-24], %g1 [%fp-20], %o5 %g1, %o5, %g1 %g1, [%fp-24] .LL2 %hi(.LLC1), %g1 %g1, %lo(.LLC1), %o0 [%fp-24], %o1 printf, 0 %g1, %i0 Sun SPARC .LL2: .LL3: add sethi or mov call mov cmp be ld cmp be ld ld add st b sethi or ld call mov ret vs %fp, -20, %g1 .L2: %hi(.LLC0), %o5 %o5, %lo(.LLC0), %o0 %g1, %o1 scanf, 0 %o0, %g1 %g1, -1 .LL3 [%fp-20], %g1 %g1, 0 .LL3 [%fp-24], %g1 [%fp-20], %o5 %g1, %o5, %g1 %g1, [%fp-24] .LL2 %hi(.LLC1), %g1 .L3: %g1, %lo(.LLC1), %o0 [%fp-24], %o1 printf, 0 %g1, %i0 Intel x86 leal movl movl call -4(%ebp), %eax %eax, 4(%esp) $.LC0, (%esp) scanf cmpl je cmpl je $-1, %eax .L3 $0, -4(%ebp) .L3 movl leal addl jmp -4(%ebp), %edx -8(%ebp), %eax %edx, (%eax) .L2 movl movl movl call leave ret -8(%ebp), %eax %eax, 4(%esp) $.LC1, (%esp) printf Evolution of programming languages, 1980's • "object-oriented" languages: C++ – better control of structure of really large programs better internal checks, organization, safety – a program ("compiler", "translator") converts into assembler or C – enormous advantages: portable: same program can be translated for different machines faster, cheaper hardware helps make this happen #include <iostream> main() { int num, sum = 0; while (cin >> num && num != 0) sum += num; cout << sum << endl; } Bjarne Stroustrup, creator of C++ "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." Evolution of programming languages, 1990's • "scripting", Web, component-based, ...: Java, Perl, Python, Ruby, Visual Basic, Javascript, ... – write big programs by combining components already written – often based on "virtual machine": simulated, like fancier toy computer – enormous advantages: portable: same program can be translated for different machines faster, cheaper hardware helps make this happen var sum = 0; // javascript var num = prompt("Enter new value, or 0 to end") while (num != 0) { sum = sum + parseInt(num) num = prompt("Enter new value, or 0 to end") } alert("Sum = " + sum) Javascript • JavaScript, not to be confused with Java, was created in 10 days in May 1995 by Brendan Eich James Gosling, creator of Java Separated at birth? (James Gosling, creator of Java) Programming languages in the 21st century? • new general-purpose languages – Go, Rust, Swift, Scala, ... • ongoing refinements / evolution of existing languages – C, C++, Fortran, Cobol all have new standards in last few years • specialized languages for specific application areas – e.g., R for statistics • old languages rarely die – it costs too much to rewrite programs in a new language • Ultimately, natural language Most popular programming languages Trending languages from http://spectrum.ieee.org/static/interactive-the-top-programming-languages2015#index/2015/1/1/1/1/1/50/1/50/1/50/1/30/1/30/1/30/1/20/1/20/1/5/1/5/1/20/1/100/ Website of the day • Sorting algorithms choreographed Software systems and issues • operating systems – controlling the computer • file systems and databases – storing information • applications – programs that do things • cloud computing, virtual machines, platforms – where boundaries become even less clear • intellectual property – copyrights, patents, licenses • interfaces, standards, antitrust – agreements on how to communicate and inter-operate • open source software – freely available software Operating system • a program that controls the resources of a computer – interface between hardware and all other software • runs other programs ("applications", your programs) • manages information on disk (file system) • controls peripheral devices, communicates with outside • provides a level of abstraction above the raw hardware – makes the hardware appear to provide higher-level services than it really does – makes programming much easier Examples of Operating system • DOS, Windows 3.0/3.1/95/98/NT/ME/2000/XP/Vista/7/8/10 Unix/Linux, Mac OS X, iOS, Android, ... Mac OS X 10.0 Cheetah 24-Mar-01 Mac OS X 10.1 Puma 25-Sep-01 Mac OS X 10.2 Jaguar 24-Aug-02 Mac OS X 10.3 Panther 24-Oct-03 Mac OS X 10.4 Tiger 29-Apr-05 Mac OS X 10.5 Leopard 26-Oct-07 Mac OS X 10.6 Snow Leopard 28-Aug-09 Mac OS X 10.7 Lion 20-Jul-11 OS X 10.8 Mountain Lion 25-Jul-12 OS X 10.9 Mavericks 22-Oct-13 OS X 10.10 Yosemite 16-Oct-14 What's an operating system? "Operating system" means the software code that, inter alia, (i) controls the allocation and usage of hardware resources (such as the microprocessor and various peripheral devices) of a Personal Computer, (ii) provides a platform for developing applications by exposing functionality to ISVs through APIs, and (iii) supplies a user interface that enables users to access functionality of the operating system and in which they can run applications. US District Court for the District of Columbia Final Judgment, State of New York, et al v. Microsoft Corporation November 1, 2002 ISV = Independent Software Vendors API = Application Program Interface History of general-purpose operating systems • • 1950's: signup sheets 1960's: batch operating systems (largely IBM) – operators running batches of jobs – OS/360 (IBM) • 1970's: time-sharing (minicomputers e.g. Digital Equipment Corporation) – simultaneous access for multiple users – Unix (Bell Labs; Ken Thompson & Dennis Ritchie) • 1980's: personal computers, single user systems – DOS, Windows, MacOS – Unix • 1990's: personal computers, PDA's, … – PalmOS, Windows CE, … – Unix / Linux • 2000's: Windows vs. Unix/Linux? – MacOSX is a Unix system • 2010's: Apple vs. Google • not all computers have general-purpose operating systems – iOS, Android, Chrome-OS, … (Unix/Linux-based) – "embedded systems": small, specialized, but increasingly general Unix operating system • developed ~1971 at Bell Labs – by Ken Thompson and Dennis Ritchie • clean, elegant design – at least in the early days • efficient, robust, easy to adapt, fun – widely adopted in universities, spread from there • written in C, so easily ported to new machines – runs on everything (not just PC's) • influence – – – – – languages, tools, de facto standard environment supported minicomputer manufacturer (Digital Equipment) rewritten at UC Berkeley to be in public domain enabled workstation hardware business (e.g., Sun Microsystems) supports a lot of Internet services and infrastructure often Linux Ken Thompson and Dennis Ritchie (circa 1972) "It's a Unix system. I know this." http://www.youtube.com/watch?v=dFUlAQZB9Ng Linux • a version of Unix written from scratch – by Linus Torvalds, Finnish student (started 1991) • source code freely available (kernel.org) – – – – large group of volunteers making contributions anyone can modify it, fix bugs, add features Torvalds approves, sets standard commercial versions make money by packaging and support, not by selling the code itself • used by major sites, including – Google, Amazon, Facebook, Twitter, YouTube, ABC, CBS, CNN, ... and www.microsoft.com, www.apple.com, itunes.apple.com, … User experience at the computer • You turn it on – System boots First the hardware, then the Windows operating system – Your desktop appears First icons, then applications – Interaction devices can be used Machine is listening to mouse, keyboard, etc. – Machine enters new version of the fetch/execute cycle Machine fetches command from user Machine executes commands What happens when machine boots • Power goes on, each device is turned on • BIOS lets you talk to hardware – Change order devices are turned on – Set system clock – Identify new interaction devices • Then, the boot program for Windows starts – You tell it an order in which to look at disks – It looks at disks in this order to find operating system • Operating system boots – Simple program called the operating system kernel is loaded (at location 10). This is the program that runs the computer. Operating system kernel • Kernel – Starts Device drivers Talk to RAM, disks, CD/ROM, … Starts subsystems memory management system (to organize data on RAM) file system (to organize files on disk) Gets user started Starts window manager or creates a shell Starts fetch/execute cycle Fetch/execute cycle • Fetch is Event driven • Execution is done by the operating system Fetching • Fetch is Event driven – The window manager listens for an event From keyboard Key down/key up From mouse Mouse motion, mouse button up or down From other device Game controller Speech interface Fetching (cont.) • Identify where the command occurred – In which window on the screen • Identify the action that must be taken – Examples Type text into Word window Click command in window of executing program Click on resize corner of window Click on icon from window Click on icon from task bar