The Impedance Mismatch is Our...

47
The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core, Relevance 1

Transcript of The Impedance Mismatch is Our...

Page 1: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

The Impedance Mismatch is Our FaultStuart Halloway

Datomic Team, Clojure/core, Relevance

1

Page 2: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

All information in the database is to be represented in only one way, namely by values in column positions within rows of tables.

http://en.wikipedia.org/wiki/Codd%27s_12_rules

2

Page 3: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.

It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.

http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en

3

Page 4: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

“...Essentially the ORM can handle about 80-90% of the mapping problems...”

http://java.dzone.com/articles/martin-fowler-orm-hate

4

Page 5: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

“...I think NoSQL is technology to be taken very seriously....”

http://java.dzone.com/articles/martin-fowler-orm-hate

5

Page 6: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

“...Not all problems are technically suitable for a NoSQL database...”

http://java.dzone.com/articles/martin-fowler-orm-hate

6

Page 7: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

“...early successes yield a commitment to use O/R-M...”

http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

7

Page 8: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

“...the Slippery Slope...”

http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

8

Page 9: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

“...the Last Mile Problem...”

http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

9

Page 10: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Code Phrases for “I Give Up”

• “use ORM for the 80% case”

• “polyglot persistence”

• “right tool for the job”

• “use NoSQL where appropriate”

• “hybrid approach”

10

Page 11: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Don’t Give Up!

Mainstream OO and RDBMS approaches are hopelessly complected.

If you simplify them, you will find the building blocks for a general-purpose

approach to data

11

Page 12: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

OO RDBMS

processing object at a time set at a time

structure dictionaries rectangles

access navigation query

location over here over there

12

Page 13: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

DRY vs. Rectangular

• join table

• person table

• club table

• id key in person table

• person key in join table

• club key in join table

• id key in club table

“People can belong tomultiple clubs”

13

Page 14: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

The “Over There” Problem

“the query can be decorated with spans that instruct the persistence layer to

fetch related objects at the same time."

http://www.codeproject.com/Articles/20849/ORM-as-Vietnam-of-Computer-Science-A-Response

14

Page 15: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

The “Over There” Problem

http://stackoverflow.com/questions/404083/is-orm-still-the-vietnam-of-computer-science

"RoR and the ActiveRecord pattern have deservedly earned a reputation as dbms resource hogs for this reason. Optimized

ActiveRecord design is more often than not suboptimal SQL design, because it encourages

SQL statement decomposition."

15

Page 16: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

OO RDBMS

processing object at a time set at a time

structure dictionaries rectangles

access navigation query

location over here over there

programmable? no no

perception coordinated coordinated

action assist use of tx system

transactions

16

Page 17: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Programmability of SQL?

http://imgs.xkcd.com/comics/exploits_of_a_mom.png

17

Page 18: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

// build generator for the new class String tname = tclas.getName(); ClassPool pool = ClassPool.getDefault(); CtClass clas = pool.makeClass(cname); clas.addInterface(pool.get("IAccess")); CtClass target = pool.get(tname); // add target object field to class CtField field = new CtField(target, "m_target", clas); clas.addField(field); // add public default constructor method to class CtConstructor cons = new CtConstructor(NO_ARGS, clas); cons.setBody(";"); clas.addConstructor(cons);

Programmability of Java?

http://www.ibm.com/developerworks/java/library/j-dyn0610/

18

Page 19: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Coordinating Perception is Insane

• I don’t slow down when you watch me

• Records are immutable

• Reality is cumulative

• new time requires new space

19

Page 20: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Transactions are awesome

20

Page 21: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

OO RDBMS Imagine!

processing object at a time

set at a time both

structure dictionaries rectangles any

access navigation query both

location over here over there anywhere

programmable? no no yes

perception coordinated coordinated values

action assist use of tx system transactions any

21

Page 22: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

OO RDBMS Imagine!

processing object at a time

set at a time both

structure dictionaries rectangles any

access navigation query both

location over here over there anywhere

programmable? no no yes

perception coordinated coordinated values

action assist use of tx system transactions any

22

Page 23: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Rebuilding

23

Page 24: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure

access

location

programmable?

perception

action

24

Page 25: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure

access

location

programmable? yes

perception

action

Everything is made of data

25

Page 26: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure

access

location anywhere

programmable? yes

perception values

action

Data isimmutable

26

Page 27: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure

access

location anywhere

programmable? yes

perception values

action

The fundamental unit of data is the

datom:E / A / V / T

27

Page 28: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure dictionary

access

location anywhere

programmable? yes

perception values

action

A set of datoms has a 100% mechanical transformation to a

dictionary.

28

Page 29: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure dictionary rectangle

access

location anywhere

programmable? yes

perception values

action

A set of datoms has a 100% mechanical transformation to

rectangles.

29

Page 30: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure dictionary rectanglecolumns

access

location anywhere

programmable? yes

perception values

action

A set of datoms has a 100% mechanical transformation to

columns.

30

Page 31: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure dictionary rectanglecolumn graph

access

location anywhere

programmable? yes

perception values

action

A set of datoms has a 100% mechanical transformation to a

graph.

31

Page 32: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure dictionary rectanglecolumn graph entity

access

location anywhere

programmable? yes

perception values

action

A set of datoms has a 100% mechanical

transformation to an entity.

32

Page 33: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Stop Abusing Documents

33

Page 34: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing

structure any

access query

location anywhere!!

programmable? yes

perception values!!

action

Datalog haspower equivalent to

the relational algebra

34

Page 35: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing set at a time

structure any

access query

location anywhere!!

programmable? yes

perception values!!

action

Datalog is set-at-a-time

35

Page 36: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing set at a time,tuple at a time

structure any

access query

location anywhere!!

programmable? yes

perception values!!

action

core.logic is tuple at a time

36

Page 37: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing set or tuple at a timeentity at a time

structure any

access querynavigation

location anywhere!!

programmable? yes

perception values!!!!

action

Entity provides generic, lazy

traversal

37

Page 38: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere!!

programmable? yes

perception values!!!!

action transactions

serialized transactions

ACID and easy

38

Page 39: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere

programmable? yes!!

perception values!!!!!!

action transactionstransaction fns

transaction functions

pure functionscomposable

installed in dbrun anywhere

39

Page 40: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere

programmable? yes!!

perception values!!!!!!

action txes, tx fns

bonus round

40

Page 41: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere

programmable? yes!!

perception values!!!!!!

action txes, tx fns

bonus round

time model

db.asOf(lastMonth)

41

Page 42: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere

programmable? yes!!

perception values!!!!!!

action txes, tx fns

bonus round

time model

scale read and query horizontally

42

Page 43: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere

programmable? yes!!

perception values!!!!!!

action txes, tx fns

bonus round

time model

scale read and query horizontally

“what if” queries

db.with(newData)

43

Page 44: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing any

structure any

access any

location anywhere

programmable? yes!!

perception values!!!!!!

action txes, tx fns

bonus round

time model

scale read and query horizontally

“what if” queries

multi-source queries

44

Page 45: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Imagine!

processing ?

structure ?

access ?

location anywhere

programmable? ?

perception values

action ?

?? ?

you can play the home game!

simplify

program with values

fill in your own answers

45

Page 46: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

"I think that if you if you're going to dump on something in the way many people do about ORMs,

you have to state the alternative"

http://java.dzone.com/articles/martin-fowler-orm-hate

46

Page 47: The Impedance Mismatch is Our Faultgotocon.com/dl/goto-cph-2012/slides/iconoclasts/ImpedanceMismat… · The Impedance Mismatch is Our Fault Stuart Halloway Datomic Team, Clojure/core,

Thanks!

@stuarthalloway

47