Skip to content

Latest commit

 

History

History
84 lines (67 loc) · 3.74 KB

lesson-04.org

File metadata and controls

84 lines (67 loc) · 3.74 KB

Lesson Goals

  • [ ] The philosophical underpinning of state handling in clojure
  • [ ] vars, atoms, refs, agents
  • [ ] threads, futures, promises (concurrency primitives)

Preparatory Material for Lesson 4

Lesson goals: This week we’ll focus on clojure’s facilities for multithreading and state management.

  • Attempt the problems assigned at the end of Lesson 3. Raise a pull request when you are done.
  • Read chapters 9 and 10 of Brave and True,
  • Solve the koans in files 16 and 17
  • Watch this online lecture by Rich Hickey, the designers of the clojure language: Are we there yet? Pay particular example to the example of watching the baseball game example, and the “Epochal Time Model” slide. This is Very important!! c.f. first half of Chap 10 of Brave & True. Rich explains, throughout this talk, how confusing the identity of objects with their values breaks our natural understanding of how time evolves in a software system, and his attempt at “decomplecting” these elements. This idea is the key motivation behind the design of clojure. Write down all comments and questions you have about this talk so we can all discuss them together.

Lesson plan

Is my emacs full screen with big fonts? Are we recording? Screen keys on?

Discuss Poker solutions — see these points:

  • many of you leave dangling parens. Talk about paredit again.
  • two of you only did the parsing bit. Perhaps I was unclear in the assignment description? Please go attempt best poker hand.

Discuss: Notes on Rich Hickey’s Are we there yet

0:00:00
Start of talk.
0:00:28
We will discuss time, in software systems.
0:01:47
Most modern OO languages are all “kinda the same”
0:03:20
What are we missing?
0:04:25
Critical ideas
0:05:14
Incidental complexity
0:06:30
C++
0:09:04
Java
0:10:04
Lack of stable values is a big problem! The problem of mutability
0:11:46
Can’t understand large programs
  • can’t determine scope of effects of changes
  • concurrency is last straw
0:13:20
Pure functions
0:14:50
Programs aren’t functions; they’re processes
0:16:36
OO: a simplistic model of the real world. No notion of time
0:18:34
The big mistake: conflation of identity with value
0:20:12
“No man can cross the same river twice.” :-)
0:22:49
The notion of identities. Mental constructs superposed onto succession of values.
0:24:38
Definitions: value, state, identity, time
0:28:52
We don’t get to stop the world
0:29:37
Baseball game - perception is massively parallel
0:32:50
Action (in a given place) must be sequential
0:33:38
Epochal time model. (Most important slide!)
0:39:03
Persistent data structures
0:41:04
We all love trees
0:45:07
Performance hacks
0:47:18
Time constructs
0:49:56
CAS (Compare and swap)
0:51:34
Agents – send
0:53:09
STM. Preserves epochal time model. (slide 45)
1:01:38
Conclusions

Things to explain

Go through lesson_04.clj

atom – compare and swap – atomic state succession – uncoordinated, synchronous agent – uncoordinated, asynchronous. refs – coordinated, synchronous

See you all soon!