SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
Are We There Yet?


A deconstruction of object-oriented time

                                           Rich Hickey
Provocation

 !   Are we being well served by the popular OO languages?

 !   Have we reached consensus that this is the best way to
     build software?

     !   Is there any evidence that this is so?

 !   Is conventional OO a known good?

     !   or just so widely adopted we no longer have the ability
         to see its attendant costs or limitations?
A Deeply
Entrenched Model

!   Popular languages today are
    more similar than they are
    different

    !   Single-dispatch, stateful OO

    !   Classes, inheritance, fields,
        methods, GC

!   Smalltalk, Java, C#, Python,
    Ruby, Scala...
Not so Different
!   Differences are superficial

    !   MI/Mixins/Interfaces

    !   Static/Dynamic typing

    !   Semicolons/indentation/blocks

    !   Closures/Inner-classes

!   Preferences have more to do with
    programmer sensibilities and
    expressivity than core principles

!   Different cars, same road
Has OO “Won” ?

 !   Are we just going to tweak this model for the next few
     decades?

     !   People seem to like it

     !   Success has bred increasing conservatism, and slowed the
         pace of change

 !   The purpose of this talk is not to beat up on OO

     !   Just admit the possibility that not only are we not there, we
         may be driving on the wrong road.
What are we
    missing?

!   Are we ready for an increasingly
    complex, concurrent and
    heterogeneous world, or will we
    be facing some fundamental
    impedance mismatch?

!   What pressures should drive the
    adoption of new (and often old)
    ideas not yet in the mainstream?
Some Critical Ideas


!   Incidental complexity

!   Time/Process

!   Functions/Value/Identity/State

!   Action/Perception
“Seek simplicity, and distrust it.”


Alfred North Whitehead
Incidental complexity



!   Not the complexity inherent in the problem

!   Comes along as baggage in the way we formulate our solutions, our
    tools or languages

!   Worst when a side effect of making things appear simple
C++

!   Foo *bar(...); //what’s the problem?

    !   Simple constructs for dynamic memory

    !   Simple? - same syntax for pointers to heap and non-heap things

    !   Complexity - knowing when/if to delete

!   No standard automatic memory management

    !   Presents inherent challenge to C++ as a library language

    !   Implicit complexity we are no longer willing to bear
Java

!   Date foo(...); //what’s the problem?

    !   Simple - only references to dynamic memory, plus GC

    !   Simple? - same syntax for references to mutable/immutable things

    !   Complexity - knowing when you will see a consistent value

        !   Not (just) a concurrency problem. Can we ‘remember’ this
            value, is it stable? If aliased and mutated, who will be affected?

!   No standard automatic time management
Familiarity Hides Complexity
!   For too many programmers, simplicity is measured superficially:

    !   Surface syntax

    !   Expressivity

!   Meanwhile, we are suffering greatly from incidental complexity

    !   Can’t understand larger programs

    !   Can’t determine scope of effects of changes to our programs

    !   Concurrency is the last straw
“Civilization advances by
extending the number of
important operations which we
can perform without thinking
about them.”
Alfred North Whitehead
Pure Functions are Worry-Free

!   Take/return values                !   Huge benefits to using pure
                                          functions wherever possible
!   Local scope
                                      !   In contrast:
    !   No remote inputs or effects
                                          !   Objects + methods fail to
    !   No notion of time                     meet the “without thinking
                                              about them” criteria
!   Same arguments, same result

!   Easy to understand, change,
    test, compose
But - many interesting programs
aren’t functions
!   E.g. - ‘google’ is not a function

!   Our programs are increasingly
    participants in the world

    !   Not idealized timeless
        mathematical calculations

!   Have observable behavior over time

    !   get inputs over time

!   We are building processes
“That ‘all things flow’ is the first
vague generalization which the
unsystematized, barely analysed,
intuition of men has produced.”
Alfred North Whitehead
OO and “Change”

!   Object systems are very simplistic models of the real world

!   Most embody some notion of “behavior” associated with data

!   Also, no notion of time

    !   Or, presume a single universal shared timeline

        !   When concurrency makes that not true, breaks badly

        !   Locking an attempt to restore single timeline

!   No recipe for perception/memory - call clone()?
We have gotten this wrong!

!   By creating objects that could
    ‘change’ in place

!   ... objects we could 'see' change

!   Left out time and left ourselves
    without values

!   Conflated symbolic reference
    (identity) with actual entities

!   Perception is fragile
“No man can cross the same river
twice.”


Heraclitus
Oops!

!   Seemed to be able to change memory in place

!   Seemed to be able to directly perceive change

    !   Thus failed to associate values with points in time

!   New architectures forcing the distinctions more and more

    !   Caching

    !   Multiple versions of the value associated with an address

!   Maintaining the illusion is getting harder and harder
A Simplified View
(apologies to A.N.W.)
!   Actual entities are atomic immutable values

!   The future is a function of the past, it doesn’t change it

    !   Process creates the future from the past

!   We associate identities with a series of causally related values

    !   This is a (useful) psychological artifact

    !   Doesn’t mean there is an enduring, changing entity

!   Time is atomic, epochal succession of process events
“There is a becoming of
continuity, but no continuity of
becoming”

Alfred North Whitehead
Terms (for this talk)
!   Value                            !   State

    !   An immutable magnitude,          !   Value of an identity at a
        quantity, number... or               moment in time
        immutable composite
        thereof                      !   Time

!   Identity                             !   Relative before/after
                                             ordering of causal values
    !   A putative entity we
        associate with a series of
        causally related values
        (states) over time
Why should we care?
!   Our programs need to make decisions

!   Making decisions means operating on stable values

!   Stable values need to be:

    !   Perceived

    !   Remembered

!   We need identity to model things similarly to the way we think about
    them

    !   while getting state and time right
We don't make decisions about
things in the world by taking turns
rubbing our brains on them.
Nor do we get to stop the world
when we want to look around
Perception is massively parallel and
requires no coordination
This is not message passing!
Perception

!   We are always perceiving the (unchanging!)
    past

!   Our sensory/neural system is oriented
    around:

    !   Discretization

    !   Simultaneity detection

!   Ignoring feedback, we like snapshots
Action, in a place, must be sequential
Action and perception are different!
Epochal Time Model                            Process events
                                                  (pure functions)

                         F        F          F




              v1             v2       v3            v4




                                                      States
      Identity                                   (immutable values)
(succession of states)




                   Observers/perception/memory
Implementation ideas
!   We need language constructs        !   We can (must?) consume
    that will let us efficiently:           memory to model time!

    !   Represent values. Create and       !   Old value -> pure function ->
        share.                                 new value

    !   Manage value succession/           !   Values can be used as
        causation/obtention                    perceptions/memories

!   We need coordination constructs        !   GC will clean up the no-
    to moderate value succession               longer-referenced ‘past’

    !   Can also serve as identities
Persistent data structures
!   Immutable                         !   Creation of next value never
                                          disturbs prior, nor impedes
    !   Ideal for states, snapshots       perceivers of prior
        and memories
                                      !   Substantial reduction in
    !   Stable values for decision        complexity:
        making and calculation
                                          !   APersistentStructure foo();
    !   Never need synchronization!
                                          !   Alias freely, make modified
!   ‘Next’ values share structure             versions cheaply
    with prior, minimizing copying
                                          !   Rest easy, stay sane
Trees!




      0 1 2 3 4




!   Shallow, high branching factor   !   Can implement vectors and
                                         hash maps/sets etc
!   Nodes use arrays
Structural Sharing
                     Next
           Past
Declarativeness and Parallelism
!   Performance gains in the future   !   Tree-based persistent data
    will come from parallelism            structures are a perfect fit

!   Parallel code needs to be             !   Already set up for divide
    declarative - no loops!                   and conquer and
                                              composable construction
    !   map/reduce etc
                                      !   IMO - These should be the
!   Parallel code is easier when          most common data structures
    functional                            in use, yet almost unused
                                          outside of FP
    !   else will get tied up by
        coordination
“It’s the performance, stupid!”
the Audience


!   Persistent data structures are   !   I.e. the ‘birthing process’ of the
    slower in sequential use             next value can use our old (and
    (especially ‘writing’)               new) performance tricks:

!   But - no one can see what            !   Mutation and parallelism
    happens inside F
                                     !   Parallel map on persistent
                F                        vector same speed as loop on
                                         j.u.ArrayList on quad-core

                                     !   Safe ‘transient’ versions of PDS
         vN           vN+1
                                         possible, with O(1) conversions
                                         between persistent/transient
Epochal Time Model                            Process events
                                                  (pure functions)

                         F        F          F




              v1             v2       v3            v4




                                                      States
      Identity                                   (immutable values)
(succession of states)




                   Observers/perception/memory
Time constructs

!   Need to ensure atomic state     !   CAS - uncoordinated 1:1
    succession
                                    !   Agents - uncoordinated,
!   Need to provide point-in-time       async. (Like actors, but local
    value perception                    and observable)

!   Multiple timelines possible     !   STM - coordinated, arbitrary
    (and desirable)                     regions

!   Many implementation             !   Maybe even ... locks?
    strategies with different
    characteristics/semantics           !   coordinated, fixed regions
CAS as Time Construct
                         F


                    vN         vN+1             F           F




                         vNs          v2               v3        v4




AtomicReference



   !   swap(aRef, f, args)                 !   1:1 timeline/identity

       !   f(vN, args) becomes vN+1        !   Atomic state succession

       !   can automate spin               !   Point-in-time value perception
Agents as Time Construct
              F      F        F     F         F        F


                                                  vN         vN+1



!   send(aRef, f, args)
                                                       vNs

    !   returns immediately

!   queue enforces serialization

    !   f(vN, args) becomes vN+1        !   1:1 timeline/identity

    !   happens asynchronously in       !   Atomic state succession
        thread pool thread
                                        !   Point-in-time value perception
STM

!   Coordinates action in (arbitrary) regions involving multiple
    identities/places

!   Multiple timelines intersect in a transaction

!   ACI properties of ACID

!   Individual components still follow functional process model

    !   f(vN, args) becomes vN+1
STM as Time Construct
          v1       v2                v3            v4




          v1       v2       v3            v4




          v1                v2       v3            v4




          v1                v2       v3            v4




Transactions   F        F        F             F

               F        F        F   F     F

                        F        F             F
Perception in (MVCC) STM
  v2   v3                v2     v3


                                          Transactional
                                            snapshots
  v2   v3                v2     v3




                                     v2          v3


            Non-transactional
                 scans
                                     v2          v3
Multiversion concurrency control
!   No interference with processes   !   Allows observers/readers to
                                         have timeline
!   Models light propagation,
    sensory system delay                 !   Composite snapshots are like
                                             visual glimpses, from a
    !   By keeping some history              point-in-time in the
                                             transaction universe
    !   Persistent data structures
        make history cheap               !   Free reads are like visual
                                             scans that span time
STMs differ

!   Without MVCC you will either be:

    !   limited to scans

    !   back to “stop the world while I look at it”

!   Granularity matters!

    !   STMs that require a transaction in order to see consistent values of
        individual identities are not getting time right, IMO
Conclusions

!   Excessive implicit complexity begs for (and sometimes begets) change

!   The conflation of behavior, state, identity and time is a big source of
    implicit complexity in current object systems

!   We need to be explicit about time

!   We should primarily be programming with pure functions and
    immutable values

!   Epochal time model a general solution for the local process

!   Current infrastructures (JVM) are sufficient for implementation
Future Work

!   Coordinating internal time with external time

    !   Tying STM transactions to I/O transactions

    !   e.g. transactional queues and DB transactions

!   Better performance, more parallelism

!   More data structures

!   More time constructs

!   Reconciling epochal time with OO - is it possible?
"It is the business of the future to
be dangerous; and it is among the
merits of science that it equips the
future for its duties."
Alfred North Whitehead

Contenu connexe

Similaire à Hickey jvm summit2009

Astitva jneyatva-abhideyatva
Astitva jneyatva-abhideyatvaAstitva jneyatva-abhideyatva
Astitva jneyatva-abhideyatvaNagaraju Pappu
 
M01 Oo Intro
M01 Oo IntroM01 Oo Intro
M01 Oo IntroDang Tuan
 
Tiii presentation by dr. ir S.A.G. Stephan Wensveen
Tiii presentation by dr. ir S.A.G. Stephan WensveenTiii presentation by dr. ir S.A.G. Stephan Wensveen
Tiii presentation by dr. ir S.A.G. Stephan WensveenIndustrial Design Center
 
EPFL - PxS, week 4 - UX design techniques
EPFL - PxS, week 4 - UX design techniquesEPFL - PxS, week 4 - UX design techniques
EPFL - PxS, week 4 - UX design techniqueshendrikknoche
 
Metaphors of Code
Metaphors of CodeMetaphors of Code
Metaphors of CodeTomi Dufva
 
Making an Impact: UX Team of One
Making an Impact: UX Team of OneMaking an Impact: UX Team of One
Making an Impact: UX Team of Onevmcagwin
 
Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...
Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...
Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...IT Arena
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
First things first: get your message right
First things first: get your message rightFirst things first: get your message right
First things first: get your message rightDuo Consulting
 
Morris prototyping - oredev - share
Morris   prototyping - oredev - shareMorris   prototyping - oredev - share
Morris prototyping - oredev - shareShane Morris
 
How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...
How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...
How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...Michael Riegler
 
Prototypes, Prototypes, Prototypes
Prototypes, Prototypes, PrototypesPrototypes, Prototypes, Prototypes
Prototypes, Prototypes, PrototypesShane Morris
 
Experimental Media Voodoo™
Experimental Media Voodoo™Experimental Media Voodoo™
Experimental Media Voodoo™SkyRonDotOrg
 
DevOpsDays Chicago 2019 "To comment or not to comment?"
DevOpsDays Chicago 2019 "To comment or not to comment?"DevOpsDays Chicago 2019 "To comment or not to comment?"
DevOpsDays Chicago 2019 "To comment or not to comment?"Veronica Hanus
 
Training Avatars for the Metaverse
Training Avatars for the MetaverseTraining Avatars for the Metaverse
Training Avatars for the MetaverseBrentDavis68
 
EPFL - PxS, week 8 - conceptual design
EPFL - PxS, week 8 - conceptual designEPFL - PxS, week 8 - conceptual design
EPFL - PxS, week 8 - conceptual designhendrikknoche
 
Everything you always wanted to know about psychology and technical communica...
Everything you always wanted to know about psychology and technical communica...Everything you always wanted to know about psychology and technical communica...
Everything you always wanted to know about psychology and technical communica...Chris Atherton @finiteattention
 

Similaire à Hickey jvm summit2009 (20)

Astitva jneyatva-abhideyatva
Astitva jneyatva-abhideyatvaAstitva jneyatva-abhideyatva
Astitva jneyatva-abhideyatva
 
Looking at the wetware stakeholders in communities - fossa2011
Looking at the wetware   stakeholders in communities - fossa2011Looking at the wetware   stakeholders in communities - fossa2011
Looking at the wetware stakeholders in communities - fossa2011
 
Transforming Teaching & Learning
Transforming Teaching & LearningTransforming Teaching & Learning
Transforming Teaching & Learning
 
M01 Oo Intro
M01 Oo IntroM01 Oo Intro
M01 Oo Intro
 
Tiii presentation by dr. ir S.A.G. Stephan Wensveen
Tiii presentation by dr. ir S.A.G. Stephan WensveenTiii presentation by dr. ir S.A.G. Stephan Wensveen
Tiii presentation by dr. ir S.A.G. Stephan Wensveen
 
Theseus' data
Theseus' dataTheseus' data
Theseus' data
 
EPFL - PxS, week 4 - UX design techniques
EPFL - PxS, week 4 - UX design techniquesEPFL - PxS, week 4 - UX design techniques
EPFL - PxS, week 4 - UX design techniques
 
Metaphors of Code
Metaphors of CodeMetaphors of Code
Metaphors of Code
 
Making an Impact: UX Team of One
Making an Impact: UX Team of OneMaking an Impact: UX Team of One
Making an Impact: UX Team of One
 
Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...
Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...
Iulia Pasov, Sixt. Trends in sentiment analysis. The entire history from rule...
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
First things first: get your message right
First things first: get your message rightFirst things first: get your message right
First things first: get your message right
 
Morris prototyping - oredev - share
Morris   prototyping - oredev - shareMorris   prototyping - oredev - share
Morris prototyping - oredev - share
 
How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...
How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...
How ‘How’ Reflects What’s What: Content-based Exploitation of How Users Frame...
 
Prototypes, Prototypes, Prototypes
Prototypes, Prototypes, PrototypesPrototypes, Prototypes, Prototypes
Prototypes, Prototypes, Prototypes
 
Experimental Media Voodoo™
Experimental Media Voodoo™Experimental Media Voodoo™
Experimental Media Voodoo™
 
DevOpsDays Chicago 2019 "To comment or not to comment?"
DevOpsDays Chicago 2019 "To comment or not to comment?"DevOpsDays Chicago 2019 "To comment or not to comment?"
DevOpsDays Chicago 2019 "To comment or not to comment?"
 
Training Avatars for the Metaverse
Training Avatars for the MetaverseTraining Avatars for the Metaverse
Training Avatars for the Metaverse
 
EPFL - PxS, week 8 - conceptual design
EPFL - PxS, week 8 - conceptual designEPFL - PxS, week 8 - conceptual design
EPFL - PxS, week 8 - conceptual design
 
Everything you always wanted to know about psychology and technical communica...
Everything you always wanted to know about psychology and technical communica...Everything you always wanted to know about psychology and technical communica...
Everything you always wanted to know about psychology and technical communica...
 

Plus de Kwanzoo Dev

Getting started erlang
Getting started erlangGetting started erlang
Getting started erlangKwanzoo Dev
 
Programming.clojure
Programming.clojureProgramming.clojure
Programming.clojureKwanzoo Dev
 
Clojure forbeginners
Clojure forbeginnersClojure forbeginners
Clojure forbeginnersKwanzoo Dev
 
2010 05-20-clojure concurrency--jugd
2010 05-20-clojure concurrency--jugd2010 05-20-clojure concurrency--jugd
2010 05-20-clojure concurrency--jugdKwanzoo Dev
 
Profession android application development
Profession android application developmentProfession android application development
Profession android application developmentKwanzoo Dev
 
Hello, android introducing google’s mobile development platform, 2nd editio...
Hello, android   introducing google’s mobile development platform, 2nd editio...Hello, android   introducing google’s mobile development platform, 2nd editio...
Hello, android introducing google’s mobile development platform, 2nd editio...Kwanzoo Dev
 

Plus de Kwanzoo Dev (6)

Getting started erlang
Getting started erlangGetting started erlang
Getting started erlang
 
Programming.clojure
Programming.clojureProgramming.clojure
Programming.clojure
 
Clojure forbeginners
Clojure forbeginnersClojure forbeginners
Clojure forbeginners
 
2010 05-20-clojure concurrency--jugd
2010 05-20-clojure concurrency--jugd2010 05-20-clojure concurrency--jugd
2010 05-20-clojure concurrency--jugd
 
Profession android application development
Profession android application developmentProfession android application development
Profession android application development
 
Hello, android introducing google’s mobile development platform, 2nd editio...
Hello, android   introducing google’s mobile development platform, 2nd editio...Hello, android   introducing google’s mobile development platform, 2nd editio...
Hello, android introducing google’s mobile development platform, 2nd editio...
 

Dernier

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Dernier (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Hickey jvm summit2009

  • 1. Are We There Yet? A deconstruction of object-oriented time Rich Hickey
  • 2. Provocation ! Are we being well served by the popular OO languages? ! Have we reached consensus that this is the best way to build software? ! Is there any evidence that this is so? ! Is conventional OO a known good? ! or just so widely adopted we no longer have the ability to see its attendant costs or limitations?
  • 3. A Deeply Entrenched Model ! Popular languages today are more similar than they are different ! Single-dispatch, stateful OO ! Classes, inheritance, fields, methods, GC ! Smalltalk, Java, C#, Python, Ruby, Scala...
  • 4. Not so Different ! Differences are superficial ! MI/Mixins/Interfaces ! Static/Dynamic typing ! Semicolons/indentation/blocks ! Closures/Inner-classes ! Preferences have more to do with programmer sensibilities and expressivity than core principles ! Different cars, same road
  • 5. Has OO “Won” ? ! Are we just going to tweak this model for the next few decades? ! People seem to like it ! Success has bred increasing conservatism, and slowed the pace of change ! The purpose of this talk is not to beat up on OO ! Just admit the possibility that not only are we not there, we may be driving on the wrong road.
  • 6. What are we missing? ! Are we ready for an increasingly complex, concurrent and heterogeneous world, or will we be facing some fundamental impedance mismatch? ! What pressures should drive the adoption of new (and often old) ideas not yet in the mainstream?
  • 7. Some Critical Ideas ! Incidental complexity ! Time/Process ! Functions/Value/Identity/State ! Action/Perception
  • 8. “Seek simplicity, and distrust it.” Alfred North Whitehead
  • 9. Incidental complexity ! Not the complexity inherent in the problem ! Comes along as baggage in the way we formulate our solutions, our tools or languages ! Worst when a side effect of making things appear simple
  • 10. C++ ! Foo *bar(...); //what’s the problem? ! Simple constructs for dynamic memory ! Simple? - same syntax for pointers to heap and non-heap things ! Complexity - knowing when/if to delete ! No standard automatic memory management ! Presents inherent challenge to C++ as a library language ! Implicit complexity we are no longer willing to bear
  • 11. Java ! Date foo(...); //what’s the problem? ! Simple - only references to dynamic memory, plus GC ! Simple? - same syntax for references to mutable/immutable things ! Complexity - knowing when you will see a consistent value ! Not (just) a concurrency problem. Can we ‘remember’ this value, is it stable? If aliased and mutated, who will be affected? ! No standard automatic time management
  • 12. Familiarity Hides Complexity ! For too many programmers, simplicity is measured superficially: ! Surface syntax ! Expressivity ! Meanwhile, we are suffering greatly from incidental complexity ! Can’t understand larger programs ! Can’t determine scope of effects of changes to our programs ! Concurrency is the last straw
  • 13. “Civilization advances by extending the number of important operations which we can perform without thinking about them.” Alfred North Whitehead
  • 14. Pure Functions are Worry-Free ! Take/return values ! Huge benefits to using pure functions wherever possible ! Local scope ! In contrast: ! No remote inputs or effects ! Objects + methods fail to ! No notion of time meet the “without thinking about them” criteria ! Same arguments, same result ! Easy to understand, change, test, compose
  • 15. But - many interesting programs aren’t functions ! E.g. - ‘google’ is not a function ! Our programs are increasingly participants in the world ! Not idealized timeless mathematical calculations ! Have observable behavior over time ! get inputs over time ! We are building processes
  • 16. “That ‘all things flow’ is the first vague generalization which the unsystematized, barely analysed, intuition of men has produced.” Alfred North Whitehead
  • 17. OO and “Change” ! Object systems are very simplistic models of the real world ! Most embody some notion of “behavior” associated with data ! Also, no notion of time ! Or, presume a single universal shared timeline ! When concurrency makes that not true, breaks badly ! Locking an attempt to restore single timeline ! No recipe for perception/memory - call clone()?
  • 18. We have gotten this wrong! ! By creating objects that could ‘change’ in place ! ... objects we could 'see' change ! Left out time and left ourselves without values ! Conflated symbolic reference (identity) with actual entities ! Perception is fragile
  • 19. “No man can cross the same river twice.” Heraclitus
  • 20. Oops! ! Seemed to be able to change memory in place ! Seemed to be able to directly perceive change ! Thus failed to associate values with points in time ! New architectures forcing the distinctions more and more ! Caching ! Multiple versions of the value associated with an address ! Maintaining the illusion is getting harder and harder
  • 21. A Simplified View (apologies to A.N.W.) ! Actual entities are atomic immutable values ! The future is a function of the past, it doesn’t change it ! Process creates the future from the past ! We associate identities with a series of causally related values ! This is a (useful) psychological artifact ! Doesn’t mean there is an enduring, changing entity ! Time is atomic, epochal succession of process events
  • 22. “There is a becoming of continuity, but no continuity of becoming” Alfred North Whitehead
  • 23. Terms (for this talk) ! Value ! State ! An immutable magnitude, ! Value of an identity at a quantity, number... or moment in time immutable composite thereof ! Time ! Identity ! Relative before/after ordering of causal values ! A putative entity we associate with a series of causally related values (states) over time
  • 24. Why should we care? ! Our programs need to make decisions ! Making decisions means operating on stable values ! Stable values need to be: ! Perceived ! Remembered ! We need identity to model things similarly to the way we think about them ! while getting state and time right
  • 25.
  • 26. We don't make decisions about things in the world by taking turns rubbing our brains on them.
  • 27. Nor do we get to stop the world when we want to look around
  • 28. Perception is massively parallel and requires no coordination This is not message passing!
  • 29. Perception ! We are always perceiving the (unchanging!) past ! Our sensory/neural system is oriented around: ! Discretization ! Simultaneity detection ! Ignoring feedback, we like snapshots
  • 30. Action, in a place, must be sequential Action and perception are different!
  • 31. Epochal Time Model Process events (pure functions) F F F v1 v2 v3 v4 States Identity (immutable values) (succession of states) Observers/perception/memory
  • 32. Implementation ideas ! We need language constructs ! We can (must?) consume that will let us efficiently: memory to model time! ! Represent values. Create and ! Old value -> pure function -> share. new value ! Manage value succession/ ! Values can be used as causation/obtention perceptions/memories ! We need coordination constructs ! GC will clean up the no- to moderate value succession longer-referenced ‘past’ ! Can also serve as identities
  • 33. Persistent data structures ! Immutable ! Creation of next value never disturbs prior, nor impedes ! Ideal for states, snapshots perceivers of prior and memories ! Substantial reduction in ! Stable values for decision complexity: making and calculation ! APersistentStructure foo(); ! Never need synchronization! ! Alias freely, make modified ! ‘Next’ values share structure versions cheaply with prior, minimizing copying ! Rest easy, stay sane
  • 34.
  • 35. Trees! 0 1 2 3 4 ! Shallow, high branching factor ! Can implement vectors and hash maps/sets etc ! Nodes use arrays
  • 36. Structural Sharing Next Past
  • 37. Declarativeness and Parallelism ! Performance gains in the future ! Tree-based persistent data will come from parallelism structures are a perfect fit ! Parallel code needs to be ! Already set up for divide declarative - no loops! and conquer and composable construction ! map/reduce etc ! IMO - These should be the ! Parallel code is easier when most common data structures functional in use, yet almost unused outside of FP ! else will get tied up by coordination
  • 38. “It’s the performance, stupid!” the Audience ! Persistent data structures are ! I.e. the ‘birthing process’ of the slower in sequential use next value can use our old (and (especially ‘writing’) new) performance tricks: ! But - no one can see what ! Mutation and parallelism happens inside F ! Parallel map on persistent F vector same speed as loop on j.u.ArrayList on quad-core ! Safe ‘transient’ versions of PDS vN vN+1 possible, with O(1) conversions between persistent/transient
  • 39. Epochal Time Model Process events (pure functions) F F F v1 v2 v3 v4 States Identity (immutable values) (succession of states) Observers/perception/memory
  • 40. Time constructs ! Need to ensure atomic state ! CAS - uncoordinated 1:1 succession ! Agents - uncoordinated, ! Need to provide point-in-time async. (Like actors, but local value perception and observable) ! Multiple timelines possible ! STM - coordinated, arbitrary (and desirable) regions ! Many implementation ! Maybe even ... locks? strategies with different characteristics/semantics ! coordinated, fixed regions
  • 41. CAS as Time Construct F vN vN+1 F F vNs v2 v3 v4 AtomicReference ! swap(aRef, f, args) ! 1:1 timeline/identity ! f(vN, args) becomes vN+1 ! Atomic state succession ! can automate spin ! Point-in-time value perception
  • 42. Agents as Time Construct F F F F F F vN vN+1 ! send(aRef, f, args) vNs ! returns immediately ! queue enforces serialization ! f(vN, args) becomes vN+1 ! 1:1 timeline/identity ! happens asynchronously in ! Atomic state succession thread pool thread ! Point-in-time value perception
  • 43.
  • 44. STM ! Coordinates action in (arbitrary) regions involving multiple identities/places ! Multiple timelines intersect in a transaction ! ACI properties of ACID ! Individual components still follow functional process model ! f(vN, args) becomes vN+1
  • 45. STM as Time Construct v1 v2 v3 v4 v1 v2 v3 v4 v1 v2 v3 v4 v1 v2 v3 v4 Transactions F F F F F F F F F F F F
  • 46. Perception in (MVCC) STM v2 v3 v2 v3 Transactional snapshots v2 v3 v2 v3 v2 v3 Non-transactional scans v2 v3
  • 47. Multiversion concurrency control ! No interference with processes ! Allows observers/readers to have timeline ! Models light propagation, sensory system delay ! Composite snapshots are like visual glimpses, from a ! By keeping some history point-in-time in the transaction universe ! Persistent data structures make history cheap ! Free reads are like visual scans that span time
  • 48. STMs differ ! Without MVCC you will either be: ! limited to scans ! back to “stop the world while I look at it” ! Granularity matters! ! STMs that require a transaction in order to see consistent values of individual identities are not getting time right, IMO
  • 49. Conclusions ! Excessive implicit complexity begs for (and sometimes begets) change ! The conflation of behavior, state, identity and time is a big source of implicit complexity in current object systems ! We need to be explicit about time ! We should primarily be programming with pure functions and immutable values ! Epochal time model a general solution for the local process ! Current infrastructures (JVM) are sufficient for implementation
  • 50. Future Work ! Coordinating internal time with external time ! Tying STM transactions to I/O transactions ! e.g. transactional queues and DB transactions ! Better performance, more parallelism ! More data structures ! More time constructs ! Reconciling epochal time with OO - is it possible?
  • 51. "It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties." Alfred North Whitehead