one slide summary python and
play

One-Slide Summary Python and Real databases, unlike PS5, have many - PDF document

One-Slide Summary Python and Real databases, unlike PS5, have many Object-Oriented Programming concerns, such as scalability and atomic transactions. An object packages state and procedures. A procedure on an object is called a


  1. One-Slide Summary Python and • Real databases, unlike PS5, have many Object-Oriented Programming concerns, such as scalability and atomic transactions. • An object packages state and procedures. • A procedure on an object is called a method . We invoke a method by sending the object a message . • Inheritance allows one object to refine and reuse the behavior of another. This is a good thing. #2 Outline Interlude: PS5 vs. Wild • PS5 vs. the Real World How are commercial databases different • Problem Sets and PS9 from what you implemented for PS5? • Python UVa’s Integrated Systems Project to • Object-Oriented convert all University information Programming systems to use an Oracle database was – Object = State + originally budgeted for $58.2 Million Methods (starting in 1999). Actual cost ended up over $100 Million. • Inheritance http://www.virginia.edu/isp/ #3 #4 Real Databases How big are big databases? • Atomic Transactions: a transaction may involve many • Microsoft TerraServer modifications to database tables, but the changes should only happen if the whole transaction happens (e.g., don’t charge the – Claimed biggest in 1998 credit card unless the order is sent to the shipping dept) – Aerial photos of entire US (1 meter resolution) • Security: limit read/write access to tables, – Let's see an example ... entries and fields • Storage: need to efficiently store data on disk, provide backup mechanisms • Scale: to support really big data tables, real databases do lots of clever things #5 #6

  2. Rotunda Rotunda Big Databases • Microsoft TerraServer – 3.3 Terabytes (claimed biggest in 1998) – 1 Terabyte = 2 40 Bytes ~ 1 Trillion Bytes • Google Maps (possibly bigger?) Amphitheater Amphitheater – Better color ... • Wal-Mart You are here You are here – 285 Terabytes (2003) • Stanford Linear Accelerator (BaBar) – 500 Terabytes (30 KB per particle collision) #7 #8 How much work? How much work? • Suppose we have a huge database. • table-select is in Θ ( n ) where n is the number of entries in the table • table-select is in Θ ( n ) where n is the – Would your table-select work for Wal-Mart? number of entries in the table – If 1M entry table takes 1s, how long would it – Would your table-select work for Wal-Mart? take Wal-Mart to select from 285TB ~ 2 Trillion – If 1M entry table takes 1s, how long would it Entries? 2 000 000s = ~ 23 days take Wal-Mart to select from 285TB ~ 2 Trillion Entries? How do expensive databases perform table-select so much faster? Hint: How did we make sorting faster? #9 #10 Objects Problem-Solving Strategies An object packages: • PS1-PS4: Functional Programming – Focused on procedures – state (“variables”) – Break a problem into procedures that can be combined to solve it – procedures for manipulating • PS5: Imperative Programming and observing that state – Focused on data (“methods”) – Design data for representing a problem and procedures for updating that data Why is this useful? #11 #12

  3. Problem Sets after PS5 Problem-Solving Strategies PS6: Programming with Objects • PS6: Object-Oriented Programming – Focused on objects : package procedures and PS7: Implementing Interpreters state – Model a problem by dividing it into objects Python – Lots of problems in real (and imaginary) PS8: Dynamic Web Application worlds can be thought of this way SQL, HTML, PS9: Project JavaScript or Build a new Scheme dynamic web application #13 #14 PS9 Assignment PS6 PS6 PS6: Programming with Objects Problem: Make an interesting dynamic web site. PS7 PS7: Implementing Interpreters • Teams of 1-78 students • Can be anything you want that: Super Ambitious – Involves interesting computation PS8: Dynamic Web Application PS9 Project Extra Ambitious PS9 Project – Follows University’s use policies (or on external server) Exam 2 PS9: Project – Complies with ADA Section 508 (accessible) Build a dynamic web application A list of example Default Negotiate with Wes in advance topics is provided. #15 #16 Liberal Arts Trivia: Biology Liberal Arts Trivia: Art History • This egg-laying, venomous (from a calcaneus • Name the Spanish surrealist artist who painted spur found on the hind limb), beaver-tailed, The Persistence of Memory (oil on canvas, otter-footed mammal is perhaps best known 1931). for its “nose”, which follows the style of the Anatidae family of birds. It is native to eastern Australia and Tasmania, and occurs on the Australian 20 cent coin. #17 #18

  4. Most Popular The Reveal Programming Languages 1. Java • Scheme is secretly JavaScript 2. C – JavaScript is actually ECMAScript 3. PHP – Brendan Eich, the creator of JavaScript, is on 4. C++ record as saying that "ECMAScript was always an unwanted trade name that sounds like a skin 5. Visual Basic disease." 6. C# 7. Python 8. Perl 9. Delphi TIOBE 10. JavaScript Index, March 2010 #19 #20 Scheme vs JavaScript 1 Scheme vs. JavaScript 2 (define ( length x) function length (x) { (define ( map f lst) function map (f,lst) { (if (null? x) return isNull(x) ? (let ((result null)) var result = [] ; 0 0 : (iter (lambda (elt) forEach(lst,function (elt) { (+ 1 (length (cdr x))) (1 + (length(cdr(x)))) (set! result result.push(f(elt)); )) ; } (cons (f elt) result)) }); )) return result; result)) } #21 #22 Why Learn New Languages? Scheme vs Javascript • Languages change the way we think. • JavaScript is a dynamic, not-strongly-typed – The linguistic relativity principle (also known as the Sapir-Whorf Hypothesis ) is the idea that the language with first-class functions. varying cultural concepts and categories inherent • Scheme is a dynamic, not-strongly-typed in different languages affect the cognitive language with first-class functions. classification of the experienced world in such a way that speakers of different languages think and • For more information, see for example: behave differently because of it. Roger Brown has – The Little JavaScripter drawn a distinction between weak linguistic – http://www.crockford.com/javascript/little.html relativity, where language limits thought, and – The Little Schemer strong linguistic relativity, where language – http://www.amazon.com/exec/obidos/ASIN/0262560992/wrrrldwideweb determines thought. [Wikipedia] • See also: Orwell's 1984 #23 #24

  5. Why Learn New Languages? Why Learn New Languages • Deepening Understanding • Fun! Programming in Python is fun (possibly – By seeing how the same concepts we encountered even more fun than programming in Scheme!) in Scheme are implemented by a different • Especially because: language, you will understand those concepts better (especially procedures, assignment, and – It is an elegant and simple language data abstraction). – Most programs mean what you think they mean • Building Confidence – It is dynamic and interactive – By learning Python (mostly) on your own, the next – It can be used to easily build web applications time you encounter a problem that is best solved – It is named after Monty Python's Flying Circus using a language you don't know, you will be – It was designed by someone named Guido confident you can learn it (rather than trying to use the wrong tool to solve the problem.) #25 #26 Python • Python is a universal programming language . – Everything you can compute in Scheme you can compute in Python, and vice versa – Chapter 11 and PS 7: implement a Scheme interpreter in Python – Chapter 12: more formal definition of a universal programming language • Python is an imperative language . – Designed to support programming where most of the work is done using assignment statements – x = sqrt(4) + 1; #27 #28 Objectifying Python Learning New Languages • Python is also an object-oriented language . • Syntax : Where the {, !, (, :, etc., all go – Objects encapsulate state (i.e., variables and – If you can understand a BNF grammar, this is easy information) and the methods that operate on that – But it still takes some getting used to state together. • Semantics : What does it mean? – In Python, all data are objects. – Learning the evaluation rules – Problem Set 6 covers programming with objects. – This is harder, but most programming languages – Python has built-in support for classes, methods have very similar rules (with subtle differenecs) and inheritance. • Style : What are the idioms and customs? – Many years to be a “professional” Python programmer, but not long to write a program #29 #30

Recommend


More recommend