Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am the author of the SAM pattern. It is based on the semantics of the work of Dr. Leslie Lamport who got a Turing award for it (TLA+ - Temporal Logic of Actions). TLA+ was popularized by Amazon as a tool to help fix complex defects in AWS.

SAM fixes three approximations that we have been using in Software Engineering for Decades:

- actions can manipulate application state

- assignments are equivalent to mutation

- there is no need to define precisely what is a programming step (for instance when you write a = b + c, is that a step or is it 3 steps: read b,c, compute b+c, mutate the value of a)

To a certain degree, Redux and Elm are trying to address these three approximations as well, but they do it from a FP point of view, not from a TLA+ point of view.

Their definition of action aligns with the one of event and their approach to mutation is immutability. The main difference between SAM and Redux/Elm is the way side-effects are treated. SAM embraces side-effects (in particular asynch calls) while Redux/Elm don't know how to deal with them. Redux for instance breaks its principle #1 (single state tree) by introducing Sagas.

SAM is a factoring of your code that fits in one line of code: V = State(Model.present(Action(event))).then(nextAction)

No need for a nebula of libraries or inventing a whole new language.



Redux-thunk makes it async aware without breaking the convention.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: