SlideShare una empresa de Scribd logo
1 de 27
Class 26:
Objectifying Objects

           cs1120 Fall 2011
           David Evans
           24 October 2011
Thanks for the comments!
Subject: Re: The book is now available for students
Date: Thu, 20 Oct 2011 22:08:17 -0400
From: Stephen Solomon <sps@elevenlearning.com>
To:    evans@virginia.edu
CC:    Andrew Bender <bender@elevenlearning.com>,
       Dev Purkayastha <devp@elevenlearning.com>

Dave,

… Most of this is pure gold, and will be incredibly helpful to us as
we continue development of the Reader. It's greatly motivating
to see so many of our ideas validated by your students.

Stephen

                                                                       2
Plan
PS6, PS7, Rest of the Class / cs2110
Objects
PS5 vs. “Real” Databases
   Quiz 3 is Wednesday: Course book through
   end of Chapter 10, The Information through
   end of Chapter 8

               Note: we haven’t given up on mlist-reverse!
               …but will delay it (and do it in Scheme and
               Python) next class
Remaining Problem Sets
                        PS6: Programming with Objects




                                                              Python
                        PS7: Implementing Interpreters


    Plan J: (Java)                       Plan W:              Plan X:


  PS8: Static Types                                       Something Else
(Interpreter in Java)          Build a Web Application
                                                           (mostly using
                                (mostly using Python)
                                                         English or Video)
        PS9
Which Plan to Pick
If you indicated Computer Science major or
   potential major on your registration survey:
   You must pick Plan J or provide a convincing
   reason why you aren’t picking Plan J
    If you do Plan J, you will satisfy the prerequisite to take
    cs2110 (Software Development Methods) in the
    Spring, and are encouraged to take cs2110 this Spring.
    (You will actually be much better prepared for cs2110
    than the students who took cs1110.)    cs2110: MWF 11-11:50, Rice 130

Otherwise, choose any plan (more information later).
                                                                            5
from Class 22: nextx
(define x 0)
(define (nextx)
 (set! x (+ x 1)) x)
> (nextx)
1
> (set! x 23)
> (next x)
24
Can we make a better counter?
The place that keeps track of the count
  should be part of the counter, not part
  of the global environment

  Can have more than one counter
  Counter state is encapsulated: can only be
   modified by counter procedure
Stateful Application Rule:
To apply a constructed procedure:
1. Construct a new environment, whose parent is the
   environment of the applied procedure.
2. For each procedure parameter, create a place in the frame
   of the new environment with the name of the parameter.
   Evaluate each operand expression in the environment or the
   application and initialize the value in each place to the value
   of the corresponding operand expression.
3. Evaluate the body of the procedure in the newly created
   environment. The resulting value is the value of the
   application.
Making a Better Counter




                          9
A Better Counter
(define (make-counter)
  ((lambda (count)
    (lambda ()
      (set! count (+ 1 count))
      count))
  0))
Sweeter Version

     (define (make-counter)
       (let ((count 0))
         (lambda ()
           (set! count (+ 1 count))
           count)))
This is easier to read (syntactic sugar), but means the same thing. The place for
count is created because of the application that is part of the let expression.
(let ((Name1 Expression1) (Name2 Expression2)
      ... (Namek Expressionk))
   Expressionbody)

is equivalent to                                Draw the environment
                                                after evaluating:
((lambda (Name1 Name2 . . . Namek)              > (define mycount
                                                    (make-counter))
   Expressionbody)                              > (mycount)
 Expression1 Expression2 . . . Expressionk)     1
                                                > (mycount)
                                                2
   (define (make-counter)
     (let ((count 0))
       (lambda ()
         (set! count (+ 1 count))
         count)))
(define (make-counter)
  ((lambda (count)
    (lambda ()
      (set! count (+ 1 count))
      count))
    0))

> (define mycount
    (make-counter))
> (mycount)
1
> (mycount)
2
> (mycount)
3




                                 13
global
(define (make-counter)                     environment
  ((lambda (count)
    (lambda ()
      (set! count (+ 1 count))                 + : #<primitive:+>
      count))
    0))                                                         make-counter:
                                            mycount:
> (define mycount
    (make-counter))
> (mycount)                                                  environment:
1                                                            parameters: ()
> (mycount)                                3
                                           1
                                           0                 body: ((lambda …
2
                                 count :   2
> (mycount)
3
                                    environment:
                                    parameters: ()
                                    body: (lambda () (set! count …)
Versatile Counter
   (define (make-counter)
     ((lambda (count)
       (lambda ()
         (set! count (+ 1 count))
         count))
       0))

How can we make a counter that can do
things other than just add 1?
An Even Sweeter Counter
(define (make-counter)
  (let ((count 0))
    (lambda (message)
      (cond ((eq? message ’reset!) (set! count 0))
             ((eq? message ’next!)
                (set! count (+ 1 count)))
            ((eq? message ’current) count)
            (else
              (error "Unrecognized message"))))))
Using Counter
> (define bcounter (make-counter))
> (bcounter 'next)
> (bcounter 'next)
> (bcounter 'next)
> (bcounter 'how-many)
3
> (bcounter 'reset)
> (bcounter 'how-many)
0
Objects

An object packages:
state (“instance variables”)
procedures for manipulating and
 observing that state (“methods”)

    Why is this such a big deal?
Problem-Solving Strategies
PS1-PS4: Functional Programming
  Focused on procedures
  Break a problem into procedures that can be composed
PS5: Imperative Programming
  Focused on data
  Design data for representing a problem and procedures for
    updating that data
PS6: “Object-Oriented Programming”
  Focused on objects that package state and procedures
  Solve problem by designing objects that model the problem
  Lots of problems in real (and imaginary) worlds can be
    thought of this way
Python!
                                     We can do imperative and
                                     object-oriented style
                                     programming using Scheme, but
                                     it was designed only for
                                     functional programming.

                                     Python is a programming
                                     language designed to provide
                                     support for
                                     functional, imperative, and
We will use Python for PS6 and PS7   object-oriented style
                                     programming.

                                                                     20
Python Version
                                            class defines a new class
class Counter:
  def __init__(self):        The __init__ method is special: it constructs
                             a new object of the class.
     self.count = 0
                             self is the object we are creating (for __init__)
  def reset(self):           or manipulating (for the other methods).
     self.count = 0
                                self.count = 0 (like (let ((count 0)) …)
  def current(self):            In __init__: creates a new place named
     return self.count          count as part of this object’s frame, and
                                initializes its value to 0.
  def advance(self):
     self.count = self.count + 1
      Python’s built-in support for objects should (soon) make this easier to
      read and understand than the Scheme object system.
PS5
How are commercial databases different from
what you implemented for PS5?

  UVa’s Integrated Systems Project to convert
  all University information systems to use an
  Oracle database was originally budgeted for
  $58.2 Million (starting in 1999). Actual cost
  ended up over $100 Million.
                      http://www.virginia.edu/isp/
                      www.virginia.edu/isp/timeline.html
Real Databases
Atomic Transactions
     a transaction may involve many modifications to database tables, but the
     changes should only happen if the whole transaction happens (e.g., don’t
     charge the credit card unless the order is sent to the shipping dept)

Security
  limit read/write access to tables, entries and fields
Storage
  efficiently store data on disk, backup mechanisms
Scale
  support really big data tables efficiently
Shannon’s Sketch     (The Information, p. 232)
              Library of Congress: < 1014 = 100 TB
              Library of Congress (2009):
                      74 TB (publicly-available digital)
                      Scanning: 5 PB/year
                     1 Petabyte = 1000 Terabytes
                                = 1015 bytes
              < 105: Genetic constitution on human
                    Note: this was 1949, DNA discovered in 1953!
                       Human genome is 3B base pairs:
                                6 109 bits
                         but much less information
                            (1.5% coding ~ 107)
                                                               24
Big Databases Today
Internal Revenue Service
   150 Terabytes
ChoicePoint
   250 TB
Wal-Mart                            1 Petabyte = 1000 Terabytes
   > 500 Terabytes (2004)                      = 1015 bytes
Yahoo! (2008)
   2 Petabytes
   Analyze behavior of 500 M web      Lots more information to be collected:
      visitors per month
                                      telephone calls in one year ~ 20
National Security Agency              Exabytes
  trillions of call records
World Data Center for Climate      1 Exabyte = 1000 Petabytes = 1018 bytes
  6 Petabytes
How much work?
 table-select is in (n) where n is the number of
 entries in the table
Would your table-select work for Wal-Mart?
    If 1M entry table takes 1s, how long would it take
    Wal-Mart to select from >500TB ~ 2 Trillion Entries?
                                2 000 000s ~ 23 days

 How do expensive databases perform table-select
 so much faster?
                     Indexing is the key! See Section 8.2.3
Charge
Quiz 3 Wednesday
PS6 will be posted by tomorrow
Wednesday: Python, Object-Oriented
  Programming

Register for cs2110 for the Spring
 cs1120 Plan J satisfies the prerequisite

Más contenido relacionado

La actualidad más candente

From Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn IntroductionFrom Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn Introductionelliando dias
 
Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Mark Rees
 
Machine(s) Learning with Neural Networks
Machine(s) Learning with Neural NetworksMachine(s) Learning with Neural Networks
Machine(s) Learning with Neural NetworksBruno Gonçalves
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data ScienceMike Anderson
 
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTKStatistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTKOlivier Grisel
 
Python for R Users
Python for R UsersPython for R Users
Python for R UsersAjay Ohri
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Data Con LA
 
A practical Introduction to Machine(s) Learning
A practical Introduction to Machine(s) LearningA practical Introduction to Machine(s) Learning
A practical Introduction to Machine(s) LearningBruno Gonçalves
 
Machine Learning Live
Machine Learning LiveMachine Learning Live
Machine Learning LiveMike Anderson
 
Introduction to Big Data Science
Introduction to Big Data ScienceIntroduction to Big Data Science
Introduction to Big Data ScienceAlbert Bifet
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNetAI Frontiers
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수용 최
 
Killing The Unit test talk
Killing The Unit test talkKilling The Unit test talk
Killing The Unit test talkdor sever
 
Python for R developers and data scientists
Python for R developers and data scientistsPython for R developers and data scientists
Python for R developers and data scientistsLambda Tree
 
Internet of Things Data Science
Internet of Things Data ScienceInternet of Things Data Science
Internet of Things Data ScienceAlbert Bifet
 
Goal Based Data Production with Sim Simeonov
Goal Based Data Production with Sim SimeonovGoal Based Data Production with Sim Simeonov
Goal Based Data Production with Sim SimeonovDatabricks
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia岳華 杜
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
 
Python Pandas
Python PandasPython Pandas
Python PandasSunil OS
 
NLP on a Billion Documents: Scalable Machine Learning with Apache Spark
NLP on a Billion Documents: Scalable Machine Learning with Apache SparkNLP on a Billion Documents: Scalable Machine Learning with Apache Spark
NLP on a Billion Documents: Scalable Machine Learning with Apache SparkMartin Goodson
 

La actualidad más candente (20)

From Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn IntroductionFrom Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn Introduction
 
Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014
 
Machine(s) Learning with Neural Networks
Machine(s) Learning with Neural NetworksMachine(s) Learning with Neural Networks
Machine(s) Learning with Neural Networks
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTKStatistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
 
Python for R Users
Python for R UsersPython for R Users
Python for R Users
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
 
A practical Introduction to Machine(s) Learning
A practical Introduction to Machine(s) LearningA practical Introduction to Machine(s) Learning
A practical Introduction to Machine(s) Learning
 
Machine Learning Live
Machine Learning LiveMachine Learning Live
Machine Learning Live
 
Introduction to Big Data Science
Introduction to Big Data ScienceIntroduction to Big Data Science
Introduction to Big Data Science
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNet
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수
 
Killing The Unit test talk
Killing The Unit test talkKilling The Unit test talk
Killing The Unit test talk
 
Python for R developers and data scientists
Python for R developers and data scientistsPython for R developers and data scientists
Python for R developers and data scientists
 
Internet of Things Data Science
Internet of Things Data ScienceInternet of Things Data Science
Internet of Things Data Science
 
Goal Based Data Production with Sim Simeonov
Goal Based Data Production with Sim SimeonovGoal Based Data Production with Sim Simeonov
Goal Based Data Production with Sim Simeonov
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Python Pandas
Python PandasPython Pandas
Python Pandas
 
NLP on a Billion Documents: Scalable Machine Learning with Apache Spark
NLP on a Billion Documents: Scalable Machine Learning with Apache SparkNLP on a Billion Documents: Scalable Machine Learning with Apache Spark
NLP on a Billion Documents: Scalable Machine Learning with Apache Spark
 

Similar a Class 26: Objectifying Objects

Whats_new_Conan 2_0_MeetingC++7557.pdf
Whats_new_Conan 2_0_MeetingC++7557.pdfWhats_new_Conan 2_0_MeetingC++7557.pdf
Whats_new_Conan 2_0_MeetingC++7557.pdfEric Pederson
 
AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)Paul Chao
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in RAndrew Lowe
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fpAlexander Granin
 
Study material ip class 12th
Study material ip class 12thStudy material ip class 12th
Study material ip class 12thanimesh dwivedi
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Jay Coskey
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Ganesan Narayanasamy
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schoolsDan Bowen
 
Stack squeues lists
Stack squeues listsStack squeues lists
Stack squeues listsJames Wong
 
Stacksqueueslists
StacksqueueslistsStacksqueueslists
StacksqueueslistsFraboni Ec
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues listsYoung Alista
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues listsTony Nguyen
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues listsHarry Potter
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
MapReduce: teoria e prática
MapReduce: teoria e práticaMapReduce: teoria e prática
MapReduce: teoria e práticaPET Computação
 
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017Amazon Web Services
 
Advance Map reduce - Apache hadoop Bigdata training by Design Pathshala
Advance Map reduce - Apache hadoop Bigdata training by Design PathshalaAdvance Map reduce - Apache hadoop Bigdata training by Design Pathshala
Advance Map reduce - Apache hadoop Bigdata training by Design PathshalaDesing Pathshala
 

Similar a Class 26: Objectifying Objects (20)

Whats_new_Conan 2_0_MeetingC++7557.pdf
Whats_new_Conan 2_0_MeetingC++7557.pdfWhats_new_Conan 2_0_MeetingC++7557.pdf
Whats_new_Conan 2_0_MeetingC++7557.pdf
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in R
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
 
Study material ip class 12th
Study material ip class 12thStudy material ip class 12th
Study material ip class 12th
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2
 
Flink internals web
Flink internals web Flink internals web
Flink internals web
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
 
Stack squeues lists
Stack squeues listsStack squeues lists
Stack squeues lists
 
Stacksqueueslists
StacksqueueslistsStacksqueueslists
Stacksqueueslists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
Stacks queues lists
Stacks queues listsStacks queues lists
Stacks queues lists
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
MapReduce: teoria e prática
MapReduce: teoria e práticaMapReduce: teoria e prática
MapReduce: teoria e prática
 
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
Scalable Deep Learning on AWS Using Apache MXNet - AWS Summit Tel Aviv 2017
 
Advance Map reduce - Apache hadoop Bigdata training by Design Pathshala
Advance Map reduce - Apache hadoop Bigdata training by Design PathshalaAdvance Map reduce - Apache hadoop Bigdata training by Design Pathshala
Advance Map reduce - Apache hadoop Bigdata training by Design Pathshala
 

Más de David Evans

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!David Evans
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksDavid Evans
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeDavid Evans
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in BitcoinDavid Evans
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm ConfirmationsDavid Evans
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting TransactionsDavid Evans
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in ParadiseDavid Evans
 
Mining Economics
Mining EconomicsMining Economics
Mining EconomicsDavid Evans
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More ParanoidDavid Evans
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key SignaturesDavid Evans
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyDavid Evans
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?David Evans
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the MassesDavid Evans
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of ReserveDavid Evans
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!David Evans
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinDavid Evans
 

Más de David Evans (20)

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in Bitcoin
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm Confirmations
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting Transactions
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in Paradise
 
Bitcoin Script
Bitcoin ScriptBitcoin Script
Bitcoin Script
 
Mining Economics
Mining EconomicsMining Economics
Mining Economics
 
Mining
MiningMining
Mining
 
The Blockchain
The BlockchainThe Blockchain
The Blockchain
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More Paranoid
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key Signatures
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the Masses
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of Reserve
 
Silk Road
Silk RoadSilk Road
Silk Road
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Class 26: Objectifying Objects

  • 1. Class 26: Objectifying Objects cs1120 Fall 2011 David Evans 24 October 2011
  • 2. Thanks for the comments! Subject: Re: The book is now available for students Date: Thu, 20 Oct 2011 22:08:17 -0400 From: Stephen Solomon <sps@elevenlearning.com> To: evans@virginia.edu CC: Andrew Bender <bender@elevenlearning.com>, Dev Purkayastha <devp@elevenlearning.com> Dave, … Most of this is pure gold, and will be incredibly helpful to us as we continue development of the Reader. It's greatly motivating to see so many of our ideas validated by your students. Stephen 2
  • 3. Plan PS6, PS7, Rest of the Class / cs2110 Objects PS5 vs. “Real” Databases Quiz 3 is Wednesday: Course book through end of Chapter 10, The Information through end of Chapter 8 Note: we haven’t given up on mlist-reverse! …but will delay it (and do it in Scheme and Python) next class
  • 4. Remaining Problem Sets PS6: Programming with Objects Python PS7: Implementing Interpreters Plan J: (Java) Plan W: Plan X: PS8: Static Types Something Else (Interpreter in Java) Build a Web Application (mostly using (mostly using Python) English or Video) PS9
  • 5. Which Plan to Pick If you indicated Computer Science major or potential major on your registration survey: You must pick Plan J or provide a convincing reason why you aren’t picking Plan J If you do Plan J, you will satisfy the prerequisite to take cs2110 (Software Development Methods) in the Spring, and are encouraged to take cs2110 this Spring. (You will actually be much better prepared for cs2110 than the students who took cs1110.) cs2110: MWF 11-11:50, Rice 130 Otherwise, choose any plan (more information later). 5
  • 6. from Class 22: nextx (define x 0) (define (nextx) (set! x (+ x 1)) x) > (nextx) 1 > (set! x 23) > (next x) 24
  • 7. Can we make a better counter? The place that keeps track of the count should be part of the counter, not part of the global environment Can have more than one counter Counter state is encapsulated: can only be modified by counter procedure
  • 8. Stateful Application Rule: To apply a constructed procedure: 1. Construct a new environment, whose parent is the environment of the applied procedure. 2. For each procedure parameter, create a place in the frame of the new environment with the name of the parameter. Evaluate each operand expression in the environment or the application and initialize the value in each place to the value of the corresponding operand expression. 3. Evaluate the body of the procedure in the newly created environment. The resulting value is the value of the application.
  • 9. Making a Better Counter 9
  • 10. A Better Counter (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0))
  • 11. Sweeter Version (define (make-counter) (let ((count 0)) (lambda () (set! count (+ 1 count)) count))) This is easier to read (syntactic sugar), but means the same thing. The place for count is created because of the application that is part of the let expression.
  • 12. (let ((Name1 Expression1) (Name2 Expression2) ... (Namek Expressionk)) Expressionbody) is equivalent to Draw the environment after evaluating: ((lambda (Name1 Name2 . . . Namek) > (define mycount (make-counter)) Expressionbody) > (mycount) Expression1 Expression2 . . . Expressionk) 1 > (mycount) 2 (define (make-counter) (let ((count 0)) (lambda () (set! count (+ 1 count)) count)))
  • 13. (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0)) > (define mycount (make-counter)) > (mycount) 1 > (mycount) 2 > (mycount) 3 13
  • 14. global (define (make-counter) environment ((lambda (count) (lambda () (set! count (+ 1 count)) + : #<primitive:+> count)) 0)) make-counter: mycount: > (define mycount (make-counter)) > (mycount) environment: 1 parameters: () > (mycount) 3 1 0 body: ((lambda … 2 count : 2 > (mycount) 3 environment: parameters: () body: (lambda () (set! count …)
  • 15. Versatile Counter (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0)) How can we make a counter that can do things other than just add 1?
  • 16. An Even Sweeter Counter (define (make-counter) (let ((count 0)) (lambda (message) (cond ((eq? message ’reset!) (set! count 0)) ((eq? message ’next!) (set! count (+ 1 count))) ((eq? message ’current) count) (else (error "Unrecognized message"))))))
  • 17. Using Counter > (define bcounter (make-counter)) > (bcounter 'next) > (bcounter 'next) > (bcounter 'next) > (bcounter 'how-many) 3 > (bcounter 'reset) > (bcounter 'how-many) 0
  • 18. Objects An object packages: state (“instance variables”) procedures for manipulating and observing that state (“methods”) Why is this such a big deal?
  • 19. Problem-Solving Strategies PS1-PS4: Functional Programming Focused on procedures Break a problem into procedures that can be composed PS5: Imperative Programming Focused on data Design data for representing a problem and procedures for updating that data PS6: “Object-Oriented Programming” Focused on objects that package state and procedures Solve problem by designing objects that model the problem Lots of problems in real (and imaginary) worlds can be thought of this way
  • 20. Python! We can do imperative and object-oriented style programming using Scheme, but it was designed only for functional programming. Python is a programming language designed to provide support for functional, imperative, and We will use Python for PS6 and PS7 object-oriented style programming. 20
  • 21. Python Version class defines a new class class Counter: def __init__(self): The __init__ method is special: it constructs a new object of the class. self.count = 0 self is the object we are creating (for __init__) def reset(self): or manipulating (for the other methods). self.count = 0 self.count = 0 (like (let ((count 0)) …) def current(self): In __init__: creates a new place named return self.count count as part of this object’s frame, and initializes its value to 0. def advance(self): self.count = self.count + 1 Python’s built-in support for objects should (soon) make this easier to read and understand than the Scheme object system.
  • 22. PS5 How are commercial databases different from what you implemented for PS5? UVa’s Integrated Systems Project to convert all University information systems to use an Oracle database was originally budgeted for $58.2 Million (starting in 1999). Actual cost ended up over $100 Million. http://www.virginia.edu/isp/ www.virginia.edu/isp/timeline.html
  • 23. Real Databases Atomic Transactions a transaction may involve many modifications to database tables, but the changes should only happen if the whole transaction happens (e.g., don’t charge the credit card unless the order is sent to the shipping dept) Security limit read/write access to tables, entries and fields Storage efficiently store data on disk, backup mechanisms Scale support really big data tables efficiently
  • 24. Shannon’s Sketch (The Information, p. 232) Library of Congress: < 1014 = 100 TB Library of Congress (2009): 74 TB (publicly-available digital) Scanning: 5 PB/year 1 Petabyte = 1000 Terabytes = 1015 bytes < 105: Genetic constitution on human Note: this was 1949, DNA discovered in 1953! Human genome is 3B base pairs: 6 109 bits but much less information (1.5% coding ~ 107) 24
  • 25. Big Databases Today Internal Revenue Service 150 Terabytes ChoicePoint 250 TB Wal-Mart 1 Petabyte = 1000 Terabytes > 500 Terabytes (2004) = 1015 bytes Yahoo! (2008) 2 Petabytes Analyze behavior of 500 M web Lots more information to be collected: visitors per month telephone calls in one year ~ 20 National Security Agency Exabytes trillions of call records World Data Center for Climate 1 Exabyte = 1000 Petabytes = 1018 bytes 6 Petabytes
  • 26. How much work? table-select is in (n) where n is the number of entries in the table Would your table-select work for Wal-Mart? If 1M entry table takes 1s, how long would it take Wal-Mart to select from >500TB ~ 2 Trillion Entries? 2 000 000s ~ 23 days How do expensive databases perform table-select so much faster? Indexing is the key! See Section 8.2.3
  • 27. Charge Quiz 3 Wednesday PS6 will be posted by tomorrow Wednesday: Python, Object-Oriented Programming Register for cs2110 for the Spring cs1120 Plan J satisfies the prerequisite

Notas del editor

  1. http://www.computerworld.com/s/article/9087918/Size_matters_Yahoo_claims_2_petabyte_database_is_world_s_biggest_busiest