These are chat archives for jdubray/sam

5th
Jan 2018
zevenbergm
@zevenbergm
Jan 05 2018 13:25
Here you can find an interesting article about states in the front-end: https://www.smashingmagazine.com/2018/01/rise-state-machines/. I’m wondering what the differences are with SAM… In this article, the action is explicitly transitioning the state where SAM determines the state from the model. Do you guys see other differences / similarities?
Jean-Jacques Dubray
@jdubray
Jan 05 2018 14:20
@zevenbergm I tried to talk to Krasimir, but unfortunately, it looks like he will not question his proposal in any way, which by the way has been tried for decades now (including by myself). The difference with TLA+ state machines is precisely that, actions do not drive the end-state. Which you can also see in the Paxos protocol. Dr. Lamport has never used a single FSM in his career, nor his work can be modeled after FSM. I understand, it's probably hard to let go FSM, they are like pure functions, the concept is simple to understand, almost intuitive.
Jean-Jacques Dubray
@jdubray
Jan 05 2018 14:25
All these concepts work in the small but quickly topple under their own weight. SAM is based on a precise state-machine structure (not a FSM one) that is not conflicting with code. Your code is the state-machine, not the other way around, you don't have to put your code inside an FSM structure.
devin ivy
@devinivy
Jan 05 2018 14:40

Your code is the state-machine, not the other way around

:clap:

Fred Daoud
@foxdonut
Jan 05 2018 14:59
@jdubray @devinivy monads are or are not beneficial in JavaScript, I don't know.. but I do think that some of the other constructs, like Maybe, Either, and Sum Types, are really useful and practical. They can clean up code that would otherwise be a mess if if/else or switch statements. Now, some people don't think that bunches of if/else or switch statements are messy; I'm not here to argue about that :)
Jean-Jacques Dubray
@jdubray
Jan 05 2018 15:02
I find that quite attractive and worth digging into. Anything that makes your code easier to reason about and maintain is worthwhile. if-then-else is clearly a problem in any programming language, far greater than goto (IMHO).
devin ivy
@devinivy
Jan 05 2018 15:31
mapping over a Maybe removing null checks is great!
Jean-Jacques Dubray
@jdubray
Jan 05 2018 15:33
Yes, that "practical" view of Monads is worth looking into.
Artyom Shalkhakov
@ashalkhakov
Jan 05 2018 15:54
Hi all! Has anybody though of SAM and immediate GUIs? I'm currently trying to redesign a system based on MVP and the stateful view gives me troubles.
In existing demos, view rendering is simply a computation that produces HTML (as a string).
However, what if instead, the existing view, is based on WinForms? (So, lots of stateful objects).
What is rendering like in this case?
Jean-Jacques Dubray
@jdubray
Jan 05 2018 16:07

It's been a while I have coded anything in WinForms, the SAM pattern emits props (from the State function) and listens to events, as long as the view can be implemented with that contract it should work. Angular, for instance, does not support functional HTML. Based on my Angular experience, you might want to implement the pattern in two stages:

  • a child for each form which manages the state of the form
  • an overall parent that controls all API calls and the overall application state

If you want to share some code, I can try to illustrate how it would look.

Vertex21
@Vertex21
Jan 05 2018 17:07
Don't mean to get off topic, but has anyone used or have any input on bunnyJS?
david kaye
@dfkaye_twitter
Jan 05 2018 18:46
@metapgmr_twitter "Your code is the state-machine, not the other way around" -- :clap:
Fred Daoud
@foxdonut
Jan 05 2018 20:25
@Vertex21 never heard of it; the site seems a little thin on docs or examples. Having trouble finding something that shows me what is unique about it.
Jean-Jacques Dubray
@jdubray
Jan 05 2018 22:48
@Vertex21 this post details the approach, it's basically "use the platform".