understanding clo ure j through data James Reeves @weavejester - - PowerPoint PPT Presentation

understanding clo ure j through data
SMART_READER_LITE
LIVE PREVIEW

understanding clo ure j through data James Reeves @weavejester - - PowerPoint PPT Presentation

understanding clo ure j through data James Reeves @weavejester booleanknot disclaimer I'll be telling a few lies disclaimer I'll be telling a few lies simplifications j clo ure a functional programming language a lisp (more on


slide-1
SLIDE 1

understanding clo ure
 through data

James Reeves @weavejester boolean·knot

j

slide-2
SLIDE 2

disclaimer

I'll be telling a few lies

slide-3
SLIDE 3

disclaimer

I'll be telling a few lies

simplifications

slide-4
SLIDE 4

clo ure j

slide-5
SLIDE 5

a functional programming language a lisp

(more on that later)

slide-6
SLIDE 6
  • fficially targets Java

(Clojure) .NET (ClojureCLR) javascript (ClojureScript)

slide-7
SLIDE 7

first released in September 2007 by Rich Hickey

slide-8
SLIDE 8

let's start with edn

slide-9
SLIDE 9

extensible data notation

slide-10
SLIDE 10

edn ⊆ clojure json ⊆ javascript

slide-11
SLIDE 11

json edn

3.14159 3.14159 "hello world" "hello world" [1, 2, 3, 4] [1 2 3 4] {"name": "alice"} {"name" "alice"} true true null nil

numbers strings vectors maps booleans nil

slide-12
SLIDE 12

json

[1 2 3]

array

  • rdered, random access

collections

slide-13
SLIDE 13

edn

[1 2 3] (1 2 3) #{1 2 3}

vector list set

  • rdered, random access
  • rdered

unordered, distinct

collections

slide-14
SLIDE 14

json

"name"

string text data and identifier

identifiers

slide-15
SLIDE 15

edn

"name" :name name

string keyword symbol text data references itself references something else

identifiers

slide-16
SLIDE 16

example

{:name "Alice" :sex :female :job cryptographer}

universal definition might reference job description, benefits, etc

slide-17
SLIDE 17

namespaces

mammal.canine/dog :status/ready

slide-18
SLIDE 18

tags

"f81d4fae-7dec-11d0-a765-00a0c91e6bf6" "1985-04-12T23:20:50.52Z" #inst #uuid

slide-19
SLIDE 19

tags

#color/rgb "e8a433" #color/rgb [232 164 51]

slide-20
SLIDE 20

what's the connection to clojure?

slide-21
SLIDE 21

clojure = edn + eval

slide-22
SLIDE 22

evaluation

most data evaluates to itself

"foo" "foo" 123 123

eval

[1 2 3] [1 2 3] {:x 1} {:x 1}

slide-23
SLIDE 23

evaluation

symbols evaluate to a bound value

pi 3.14159

eval

message "Hello World"

slide-24
SLIDE 24

evaluation

lists evaluate based on their first element

(+ 1 1) 2

eval

(and true false) false

slide-25
SLIDE 25

evaluation

functions evaluate their arguments

(+ (* 3 3) (* 4 4)) ⇒ (+ 9 16) ⇒ 25

slide-26
SLIDE 26

evaluation

macros evaluate their return value

(postfix (9 16 +)) ⇒ (+ 9 16) ⇒ 25

slide-27
SLIDE 27

homoiconic

slide-28
SLIDE 28

homo · iconic

the same representation

slide-29
SLIDE 29

homo · iconic

writing code with data

slide-30
SLIDE 30

clojure data

slide-31
SLIDE 31

why such a close relationship?

slide-32
SLIDE 32

macros allow us to add new syntax through libraries

core.async core.logic core.typed async programming logic programming static typing

slide-33
SLIDE 33

but is that the only reason?

slide-34
SLIDE 34

“Simple Made Easy”

slide-35
SLIDE 35

simple complex

why?

slide-36
SLIDE 36

simple complex

slide-37
SLIDE 37

complexity ≠ cardinality

slide-38
SLIDE 38

complexity = interlacing coupling connections

slide-39
SLIDE 39

how do we usually deal with complexity?

slide-40
SLIDE 40

{ }

mutable state

slide-41
SLIDE 41

{ }

mutable state

slide-42
SLIDE 42

{ }

  • bject

encapsulates state

slide-43
SLIDE 43
  • bject
slide-44
SLIDE 44

methods

slide-45
SLIDE 45

encapsulation isolates complexity

slide-46
SLIDE 46

defensive strategy

slide-47
SLIDE 47

what would an offensive strategy look like?

slide-48
SLIDE 48

can something have zero complexity?

slide-49
SLIDE 49

immutable values

slide-50
SLIDE 50

mutable state needed for

  • 1. performance
  • 2. communication across threads
slide-51
SLIDE 51

{ }

  • bject
slide-52
SLIDE 52

do we need encapsulation?

slide-53
SLIDE 53

walls are expensive

slide-54
SLIDE 54

{ }

slide-55
SLIDE 55

can we do that?

slide-56
SLIDE 56

in distributed environments we

  • ften work with immutable values
slide-57
SLIDE 57

are there any immediate benefits?

slide-58
SLIDE 58

free API

getters setters serialisation transversal transformations equality diffing merging deserialisation lensing auditing concurrency

slide-59
SLIDE 59

end

questions?