SlideShare uma empresa Scribd logo
1 de 45
Baixar para ler offline
Why Clojure?
Why Clojure?
 Why was it created?

What do we mean with
    complexity?

How does clojure makes
 things more simple?
When was Clojure
● 2007: introduction by Rich Hickey

● 2009: version 1.0

  ....

● 2013: version 1.5
What is Clojure
● A Lisp

● for Functional Programming

● Running on the JVM, CLR and browsers

● Designed for concurrency
A Lisp
Many concepts of Lisps are taken over by other
languages:
● Conditionals
● First-class functions
● Recursion
● Garbage collection
● Programs made up out of expressions
Functional Programming
● Provides a way out of the multi-core
  conundrum

● Makes programs simpler by decomplecting
  them.
Running on the JVM, CLR, browser
● JVM / CLR have huge benefits:
   ○ Libraries
   ○ Memory and resource management
   ○ Efficient and robust
● JavaScript has a huge reach:
   ○ It's the most widely deployed language
   ○ Through ClojureScript, we can target everywhere
     JavaScript runs.
● Clojure is symbiotic with its host platform.
Designed for Concurrency
● Machines are not getting faster, they just
  have more cores.

● Shared access to mutable state makes
  multi-core programming a nightmare.

● Immutability makes many of the problems go
  away.

● Separating identity and state can solve all
  the other problems.
Why is Clojure
● Reducing complexity

● to be easy? not exactly...
What do we mean with
● Complex

● Simple

● Hard

● Easy
Complexity




                    Complex

Consisting of many different and connected parts.

   To Complect
   be interwoven or interconnected
Complexity

Simple




Complex
How I/we made things complex
● Teamwork
● Robots
  ○ Explore unknown maze

  ○ Detect barcodes --> action

  ○ Travel over seesaw

● How to test?
  ○ We couldn't

● Unmanageable complexity
Complexity




Simple                Easy
Complexity


Complex                Hard




Simple                 Easy
Complexity
Objective                             Subjective

Complex                                  Hard

      "Elegance and familiarity are
      orthogonal."
              — Rich Hickey




 Simple                                  Easy
Types of Complexity
● Essential Complexity



● Accidental Complexity
Examples of complexity
● State

● Inheritance

● Objects
  ○ state
  ○ identity
  ○ value

● Memory management
● Variables
Why does simple matter?
● Formal reasoning
   ○ can be hard

● Extendability
   ○ Composing


● Testability
   ○ isolation
How is Clojure simple(r)
● Functional Programming
   ○ Pure functions

● Immutable data structures

● Thinking with data

● Decomplecting state / value / identity
Immutability
● Numbers are immutable in your language

● If you use Java, Strings are immutable

● Imagine if they're not!
Immutable building blocks
● Primitives: numbers, strings

● Collections: lists, vectors, strings, maps, sets

● "Changing" a collection creates an (efficient)
  copy. (think: Git)

● Don't worry about state
Thinking with data
● data is simple

● Why wrap it in classes


"It is better to have 100 functions operate on one data
structure than 10 functions on 10 data structures."
   — Alan Perlis
Thinking with data
● data is simple

● Clojure map
Thinking with data


; Get the first name
(get-in person [:name :first-name])

; Get all birth dates from a list of persons.
(map :birthdate people)
Identity/state/value model
● Object Oriented Approach
                                   Memory

                                   SpaceShip

ship1                        - name
                             -x
                             -y
                             - velocity
Identity/state/value model
● Object Oriented Approach

● Problems
  ○ Stable value

  ○ history (snapshot)

  ○ Concurrent modification
Stable value
● Spaceship
  ○ position
    ■ x,y
    ■ Position object

  ○ velocity
    ■ MovementState
Stable value
● Spaceship
  ○ position
    ■ x,y
    ■ Position object

  ○ velocity
    ■ MovementState

  ○ ...


  ○ Consistent and stable object!
Stable value
● Spaceship
  ○ position
    ■ x,y
    ■ Position object

  ○ velocity
    ■ MovementState

  ○ ...


  ○ Consistent and stable object! NO!
Stable value
● Creating the object

● Not consistent
Identity/state/value model
● Object Oriented Approach

● Problems
  ○ Stable value

  ○ history (snapshot)

  ○ Concurrent modification
Snapshot & history
● Take a picture

● Look later at it again.
Identity/state/value model
● Object Oriented Approach

● Problems
  ○ Stable value

  ○ history (snapshot)

  ○ Concurrent modification
Concurrent modification
● Guarantee consistency?

● Stop the world!
Clojure approach
● Remove ambiguity of definitions
  ○ value
  ○ state
  ○ identity
Identity/state/value model
● Value
  ○ fixed: 42 , "answer"

● Identity
  ○ series of different values over time
    Me, a car,


● State
  ○ Value of an identity at a certain point in time
Identity/state/value model
● OOP
  ○ complects state and identity



● Clojure
  ○ Separation value / state / identity

  ○ Perception becomes possible

  ○ Consistency management trivial
Clojure reference model

                                 Value
                         :name Heart Of Gold
                         :position (0,0)
                         :velocity 100 km/s
              Ref
ship1
Clojure reference model

                                 Value
                         :name Heart Of Gold
                         :position (0,0)
                         :velocity 100 km/s
              Ref
ship1
                                 Value
                         :name Heart Of Gold
                         :position (100,100)
                         :velocity 100 km/s
Clojure reference model

                                 Value
                         :name Heart Of Gold
                         :position (0,0)
                         :velocity 100 km/s
              Ref
ship1
                                 Value
                         :name Heart Of Gold
                         :position (100,100)
                         :velocity 100 km/s
Clojure reference model
● Perception without stopping the world


● Atomic updates
  ○ Transactions
Why Clojure?
  Simplicity

Expressiveness

 Concurrency
Why Clojure?
        Are we there yet?
http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey




        Simple made easy
     http://www.infoq.com/presentations/Simple-Made-Easy




         Out of The Tarpit
             http://shaffner.us/cs/papers/tarpit.pdf
Why Clojure?




  ?

Mais conteúdo relacionado

Semelhante a Why clojure

"Testing of Helm Charts or There and Back Again", Yura Rochniak
"Testing of Helm Charts or There and Back Again", Yura Rochniak"Testing of Helm Charts or There and Back Again", Yura Rochniak
"Testing of Helm Charts or There and Back Again", Yura RochniakFwdays
 
Object Oriented Programming_combined.ppt.pdf
Object Oriented Programming_combined.ppt.pdfObject Oriented Programming_combined.ppt.pdf
Object Oriented Programming_combined.ppt.pdfAshutoshKumar211882
 
The power of datomic
The power of datomicThe power of datomic
The power of datomicKonrad Szydlo
 
Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008Yardena Meymann
 
The Bleeding Edge
The Bleeding EdgeThe Bleeding Edge
The Bleeding EdgejClarity
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building BlocksCate Huston
 
Introduction to Clojure - EDGE Lviv
Introduction to Clojure - EDGE LvivIntroduction to Clojure - EDGE Lviv
Introduction to Clojure - EDGE Lvivzenyk
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxJoão Esperancinha
 
Reactive Software Systems
Reactive Software SystemsReactive Software Systems
Reactive Software SystemsBehrad Zari
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns IllustratedHerman Peeren
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Haim Yadid
 
Solid modeling
Solid modelingSolid modeling
Solid modelingKRvEsL
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languagesStarTech Conference
 
Melbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event Slides
Melbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event SlidesMelbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event Slides
Melbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event SlidesVictoria Schiffer
 

Semelhante a Why clojure (20)

"Testing of Helm Charts or There and Back Again", Yura Rochniak
"Testing of Helm Charts or There and Back Again", Yura Rochniak"Testing of Helm Charts or There and Back Again", Yura Rochniak
"Testing of Helm Charts or There and Back Again", Yura Rochniak
 
Object Oriented Programming_combined.ppt.pdf
Object Oriented Programming_combined.ppt.pdfObject Oriented Programming_combined.ppt.pdf
Object Oriented Programming_combined.ppt.pdf
 
Children of Ruby
Children of RubyChildren of Ruby
Children of Ruby
 
The power of datomic
The power of datomicThe power of datomic
The power of datomic
 
Yes scala can!
Yes scala can!Yes scala can!
Yes scala can!
 
Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008
 
Go_ Get iT! .pdf
Go_ Get iT! .pdfGo_ Get iT! .pdf
Go_ Get iT! .pdf
 
Ooad Uml
Ooad UmlOoad Uml
Ooad Uml
 
The Bleeding Edge
The Bleeding EdgeThe Bleeding Edge
The Bleeding Edge
 
The Bleeding Edge
The Bleeding EdgeThe Bleeding Edge
The Bleeding Edge
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
 
Introduction to Clojure - EDGE Lviv
Introduction to Clojure - EDGE LvivIntroduction to Clojure - EDGE Lviv
Introduction to Clojure - EDGE Lviv
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptx
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
 
Reactive Software Systems
Reactive Software SystemsReactive Software Systems
Reactive Software Systems
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014
 
Solid modeling
Solid modelingSolid modeling
Solid modeling
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languages
 
Melbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event Slides
Melbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event SlidesMelbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event Slides
Melbourne, Australia Global Day of Code Retreat 2018 gdcr18 - Event Slides
 

Último

Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 

Último (20)

Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
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
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 

Why clojure

  • 2. Why Clojure? Why was it created? What do we mean with complexity? How does clojure makes things more simple?
  • 3. When was Clojure ● 2007: introduction by Rich Hickey ● 2009: version 1.0 .... ● 2013: version 1.5
  • 4. What is Clojure ● A Lisp ● for Functional Programming ● Running on the JVM, CLR and browsers ● Designed for concurrency
  • 5. A Lisp Many concepts of Lisps are taken over by other languages: ● Conditionals ● First-class functions ● Recursion ● Garbage collection ● Programs made up out of expressions
  • 6. Functional Programming ● Provides a way out of the multi-core conundrum ● Makes programs simpler by decomplecting them.
  • 7. Running on the JVM, CLR, browser ● JVM / CLR have huge benefits: ○ Libraries ○ Memory and resource management ○ Efficient and robust ● JavaScript has a huge reach: ○ It's the most widely deployed language ○ Through ClojureScript, we can target everywhere JavaScript runs. ● Clojure is symbiotic with its host platform.
  • 8. Designed for Concurrency ● Machines are not getting faster, they just have more cores. ● Shared access to mutable state makes multi-core programming a nightmare. ● Immutability makes many of the problems go away. ● Separating identity and state can solve all the other problems.
  • 9. Why is Clojure ● Reducing complexity ● to be easy? not exactly...
  • 10. What do we mean with ● Complex ● Simple ● Hard ● Easy
  • 11. Complexity Complex Consisting of many different and connected parts. To Complect be interwoven or interconnected
  • 13. How I/we made things complex ● Teamwork ● Robots ○ Explore unknown maze ○ Detect barcodes --> action ○ Travel over seesaw ● How to test? ○ We couldn't ● Unmanageable complexity
  • 15. Complexity Complex Hard Simple Easy
  • 16. Complexity Objective Subjective Complex Hard "Elegance and familiarity are orthogonal." — Rich Hickey Simple Easy
  • 17. Types of Complexity ● Essential Complexity ● Accidental Complexity
  • 18. Examples of complexity ● State ● Inheritance ● Objects ○ state ○ identity ○ value ● Memory management ● Variables
  • 19. Why does simple matter? ● Formal reasoning ○ can be hard ● Extendability ○ Composing ● Testability ○ isolation
  • 20. How is Clojure simple(r) ● Functional Programming ○ Pure functions ● Immutable data structures ● Thinking with data ● Decomplecting state / value / identity
  • 21. Immutability ● Numbers are immutable in your language ● If you use Java, Strings are immutable ● Imagine if they're not!
  • 22. Immutable building blocks ● Primitives: numbers, strings ● Collections: lists, vectors, strings, maps, sets ● "Changing" a collection creates an (efficient) copy. (think: Git) ● Don't worry about state
  • 23. Thinking with data ● data is simple ● Why wrap it in classes "It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures." — Alan Perlis
  • 24. Thinking with data ● data is simple ● Clojure map
  • 25. Thinking with data ; Get the first name (get-in person [:name :first-name]) ; Get all birth dates from a list of persons. (map :birthdate people)
  • 26. Identity/state/value model ● Object Oriented Approach Memory SpaceShip ship1 - name -x -y - velocity
  • 27. Identity/state/value model ● Object Oriented Approach ● Problems ○ Stable value ○ history (snapshot) ○ Concurrent modification
  • 28. Stable value ● Spaceship ○ position ■ x,y ■ Position object ○ velocity ■ MovementState
  • 29. Stable value ● Spaceship ○ position ■ x,y ■ Position object ○ velocity ■ MovementState ○ ... ○ Consistent and stable object!
  • 30. Stable value ● Spaceship ○ position ■ x,y ■ Position object ○ velocity ■ MovementState ○ ... ○ Consistent and stable object! NO!
  • 31. Stable value ● Creating the object ● Not consistent
  • 32. Identity/state/value model ● Object Oriented Approach ● Problems ○ Stable value ○ history (snapshot) ○ Concurrent modification
  • 33. Snapshot & history ● Take a picture ● Look later at it again.
  • 34. Identity/state/value model ● Object Oriented Approach ● Problems ○ Stable value ○ history (snapshot) ○ Concurrent modification
  • 35. Concurrent modification ● Guarantee consistency? ● Stop the world!
  • 36. Clojure approach ● Remove ambiguity of definitions ○ value ○ state ○ identity
  • 37. Identity/state/value model ● Value ○ fixed: 42 , "answer" ● Identity ○ series of different values over time Me, a car, ● State ○ Value of an identity at a certain point in time
  • 38. Identity/state/value model ● OOP ○ complects state and identity ● Clojure ○ Separation value / state / identity ○ Perception becomes possible ○ Consistency management trivial
  • 39. Clojure reference model Value :name Heart Of Gold :position (0,0) :velocity 100 km/s Ref ship1
  • 40. Clojure reference model Value :name Heart Of Gold :position (0,0) :velocity 100 km/s Ref ship1 Value :name Heart Of Gold :position (100,100) :velocity 100 km/s
  • 41. Clojure reference model Value :name Heart Of Gold :position (0,0) :velocity 100 km/s Ref ship1 Value :name Heart Of Gold :position (100,100) :velocity 100 km/s
  • 42. Clojure reference model ● Perception without stopping the world ● Atomic updates ○ Transactions
  • 43. Why Clojure? Simplicity Expressiveness Concurrency
  • 44. Why Clojure? Are we there yet? http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey Simple made easy http://www.infoq.com/presentations/Simple-Made-Easy Out of The Tarpit http://shaffner.us/cs/papers/tarpit.pdf