These are chat archives for jdubray/sam

16th
Feb 2018
VaseJS
@VaseJS
Feb 16 2018 00:48
@VaseJS
I figured it out. there were a few transposed letters because the example use launched and launch
also forgot a return statement
VaseJS
@VaseJS
Feb 16 2018 01:02
so the codepen should reflect an ES6 version of the example now
Jean-Jacques Dubray
@jdubray
Feb 16 2018 02:02
I realized I hadn't quite ever written down the complete vision for lit-html as standards until just now. By combining Template Instantiation and HTML-parsing-in-JS we could get much faster than currently possible HTML view creation and updating, with lower memory overhead.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 02:15
@VaseJS :+1:
VaseJS
@VaseJS
Feb 16 2018 02:15
:D
Jean-Jacques Dubray
@jdubray
Feb 16 2018 02:17
@VaseJS This is the original/first example. One of the goals was to show that SAM is well aligned with Finite State Machine, but I emphasize that it is an anti-pattern to try to fit FSMs in SAM. There is no need to. The structure of the pattern allows you to "code" state machines (the TLA+ kind), there is no need to create a separate set of semantics like FSM.
VaseJS
@VaseJS
Feb 16 2018 02:21
Finite state machine and state machine is somewhat over my head. I have a feeling its a simple thing with a scary sounding name. *State Machines are headed towards the Computer science route and i’m a self taught dev like the other 60% of devs out there. those types of things need to be broken down so I can understand the significance of them or at least when I’m using them and don’t know it. TLA mention it, but I still don’t have a clear picture of what the “machine” part means.
then there is state vs control state. I seem to function without having a full understanding of them, but i’d like to understand them better. Googling them does not turn up easy results for education thus far for me
Daniel Neveux
@dagatsoin
Feb 16 2018 07:45
The State function name is one of the main point of friction when trying to understand sam.
Daniel Neveux
@dagatsoin
Feb 16 2018 08:23
I have tried to renamed it as Computation or Derivator sometimes.
Daniel Neveux
@dagatsoin
Feb 16 2018 08:30
Control State is more a mental tool to help having a clearer code design. It is used to define the different main "states" your application/component/module can be in. If it is a GameManager, the different state could be: BOOTING, LOADING, IDLE, READY,... if it is a non playable character (a grunt), it could be: ALIVE, DEAD, SEARCHING_FOR_TARGET, FIGHTING..
It is helpful to write a clean code for getting the right representation (which 3D model/animation to take), or next action predicate, aka Artificial Intelligence (basic one though...).
eg: a grunt is in SEARCHING_FOR_TARGET, and the model was updated with a new targetId. State will compute the new control state to FIGHTING, and the next action predicate could be, goBerserk().
At the scale of a game, Control State is a very good way to organize AI.
VaseJS
@VaseJS
Feb 16 2018 12:56
@dagatsoin that helped a lot. So control stat are the relevant states. In TLA Lamport say state is any possible state a variable can be in, but there also something called safe-state. @jdubray is safe-state similar to control state?
VaseJS
@VaseJS
Feb 16 2018 13:02
so state machine is just all the relevant states we are concerned with. So next would be the NAP. so this, from the example i code, is this case is a simple if statement which helps transition from one state to another (a step) and in a larger project, this could be a huge list i guessing. so for the grunt: state.init = ALIVE and the NAP = searchingForTarget. then from SFT to Fighting and fighting to goBerserk. I’m guessing there is logic in there somewhere that tells the grunt in what conditions to go berserk. So would that be a sub-state? is there such a thing? like if the grunts hp goes below 20% go berserk? or would that be gaming logic? maybe just for that type of grunt?
devin ivy
@devinivy
Feb 16 2018 14:01

state machine is just all the relevant states we are concerned with

from my perspective, state machines are a specific way to think about control state. it involves writing down and naming a list of states and transitions between those states. there are other ways to talk about moving between states that don't involve constructing a state machine, and i think that's actually one big goal of SAM.

in SAM the focus is on the model receiving proposals for changes in state, then validating that those proposals and accepting/rejecting them. so the focus is on staying in a coherent, meaningful state more so than listing all the different ways to transition between states.
VaseJS
@VaseJS
Feb 16 2018 14:15

@devinivy

there are other ways to talk about moving between states that don't involve constructing a state machine, and i think that's actually one big goal of SAM.

As I have never constructed a state machine (i don’t think i have at least, formally), how is SAM doing this different than however its done normally?

Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:23
@VaseJS the whole point of a program is to manage "state" (defined as a series of property values, nothing less, nothing more).
S2 = f12(S1)
S3 = f23(S2)
S4 = f34(S3)
...
when we code we define the structures of S1, S2, ...SN
the program instructions are f12(), f23(), f34()...
VaseJS
@VaseJS
Feb 16 2018 14:25
does f = function?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:25
Finite State Machines abstract f12(), f23()... as Actions
yes f is a function for whatever that means. You can also view it as a relation
VaseJS
@VaseJS
Feb 16 2018 14:26
i thought it look like an action step
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:26
Then you are free to define fxy() any way you want
that is your "programming model" that's where SAM comes into play and expresses that f needs to be expressed as:
State(Model.present(Action(event))).then( stateRepresentation => nap(stateRepresentation))
that decomposition/factoring is arbitrary, it can be "just" a function and the function can change after you reach a new State, Si
however we never "code" like this. Programming languages are very remote from that "State Machine" way of thinking.
Redux for instance says that fxy is one big function (the reducer) with a big switch statement, which means that in practice fxy are individual functions triggered by an "action", which can be viewed as a control state, more than an action. Redux pushes the burden of finding which function you need to use based on some "label"
It is incorrect to name this "label" as an action.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:31
That's why I don't like Redux, overall, it's a very naive way to express the functions fxy and identify which functions need to be used at a given time.
That's why you get lost quickly, in other words Redux doesn't scale.
An event/intent triggers an action, an action does some work (validation, transformation, enrichment) of the event
But stops there, it only creates a proposal to change the application state
and presents it to the model
I suggest using different semantics based on my understanding of TLA+
The Model looks at the proposal and decides if/how to accept it, the proposal can have broad influence in shaping different parts of the application state. The model owns all the mutation rules. The action known nothing about these rules.
Once the application state has mutated, you can "compute" the state representation, i.e. how particular consumers of that state will see the application state. For instance a mobile app and a web app will need to see the state in a slightly different way, however, the application state should be the same in both cases.
One aspect of the state representation is to compute the "control" state, something that decides what happens next, what intent are expected, what automatic actions should be triggered (by the next-action-predicate, nap)
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:37
So in SAM you don't have individual functions fxy() like in Redux. You have Actions Ai(), Acceptors aj(), reactors rk(), and nap()
These building blocks do not need to be tied to a control state like in Redux. They are loosely coupled, independent of each other, this is possible because they perform different, well defined roles, so when you are the model you don't need to think about the action or the state representation
when you are the state representation you don't need to think about the acceptors/mutation or actions (validation, enrichment...)
Redux pushes yet another unnatural constraint which is immutability/no side effects.
It brings nothing other than pushing API calls in places that are even more unnatural
that's why people using Redux by-the book tend to end up in a corner.
Even though Redux's style is aligned with state machines Sy = fxy(Sx)
which should be a good thing
the way Redux (by-the-book) is factored is so naive that it hurts. Nothing prevents you of course to factor your code in a SAM way, but this is considered an anti-pattern by the Redux community
devin ivy
@devinivy
Feb 16 2018 14:42
do you consider the proposals completely agnostic to the model?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:42
what I mean by that is that a given proposal doesn't know which acceptor will be triggered
devin ivy
@devinivy
Feb 16 2018 14:42
one thing i struggle with in SAM is that i feel like the actions are not agnostic to the model
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:43
they cannot be 100% because they decouple events from mutation, so they have to bridge the event to the model
devin ivy
@devinivy
Feb 16 2018 14:43
i hesitate to consider more factoring
but it would be interesting to consider reusable and non-reusable parts of an action
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:45
I know that most people don't like my style of implementing the acceptors (and I don't like it too, until I find a better one). I use these silly if( proposal.xyz !== undefined)...
devin ivy
@devinivy
Feb 16 2018 14:45
perhaps the reusable part is just the implementation, i.e. an API call with a result. not sure!
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:45
but... and this is a big but... the programming model is not composable, for instance you cannot apply more than one action at a time
Sure nothing prevents you to use traditional composition mechanisms to implement any part of the programming model
you can only logically compute a single proposal from two functions which when combined are a single action
devin ivy
@devinivy
Feb 16 2018 14:46
well i am interested in reusable actions
which intrinsically they are not reusable in SAM on their own
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:47
I would disagree that it the case for the implementation but the "envelope" of the action (event, proposal) is specific to the application.
It would only be reusable if the event and the proposal are reusable across applications
Which is not a big problem in general
devin ivy
@devinivy
Feb 16 2018 14:47
and that envelope might have to change if you rearchitect your model, yes?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:47
SAM actions are more reusable because they include no mutation code
devin ivy
@devinivy
Feb 16 2018 14:48
i see what you mean! i think what i'm talking about may not be such a big deal. have you considered a basic specification for proposals?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 14:48
yes exactly from one application to the next or if the requirements evolve, you need to adjust the proposal structure
it's just a bag of property values. You don't want to put too much structure to it. The model and its implementation should be the one that does all the heavy lifting.
I need to get ready to go somewhere. Will continue later
devin ivy
@devinivy
Feb 16 2018 15:10
k!
Jean-Jacques Dubray
@jdubray
Feb 16 2018 17:59
happy to continue if anyone is interested.
Fred Daoud
@foxdonut
Feb 16 2018 18:16
To be clear: I agree with you @jdubray in that Redux has some fundamental problems. BUT some of these problems are the same in SAM.
For example when you say "Redux pushes the burden of finding which function you need to use based on some "label"", and "one big function (the reducer) with a big switch statement"
You have the same problem when accepting a proposal in model.present.
You end up having a big series of if/else branches to figure out what to do with the proposal. That doesn't scale particularly well either.
Yes, you have said so yourself, "(and I don't like it too, until I find a better one). I use these silly if( proposal.xyz !== undefined)"
So it is acknowledged, but when you say this is a problem with Redux, it is incorrect to imply that this problem is solved in SAM.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 18:22
well, I would argue that's very different because of the many-to-many relationship between actions and acceptors. In Redux the relationship between "action" and reducer is one-to-one. When you consider the decoupling SAM action/SAM acceptor that's also very different. In redux people tend to write both together. So I believe your statement is not correct.
I am not saying that part of SAM is elegant, but it's very different from the way Redux works
I honestly never run into issues, inefficiencies, questions, concerns at the interface action/model. I truly feel that's a major achievement with SAM, granted that I'd love to find a better alternative to these if statements.
If you draw the path event -> ... -> rendering for both SAM and Redux, hopefully the decoupling should be visible (please note that an event = a Redux action, a label with a payload that is dispatched to a handler).
Fred Daoud
@foxdonut
Feb 16 2018 18:28
Again, I agree that Redux has its flaws, and that SAM is an improvement. But, "In Redux the relationship between "action" and reducer is one-to-one." is simply untrue. Actions and reducers are also many-to-many in Redux.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 18:46
I am not saying they cannot be, redux is just a function. The way people implement it is one-to-one, an action map to a reducer (which you could factor with a number of function compositions), but that is a lot more rigid that SAM.
in the extreme a proposal can have 20 proposed values that could trigger 50 acceptors, and acceptors know nothing about actions or the overall proposal structure and actions know nothing acceptors. We'll have to disagree on that one, your statements are simply incorrect and misinformed.
We have discussed (the two of us) that question for a very long time now.
SAM is totally inflexible on giving up the flexibility between actions and model. That is absolutely key. Any rigidity at that level will end up becoming a black hole at scale.
Actions cannot be wired to mutations. Again, if you find something even more decoupled that what I suggest, I'll take it, but I won't settle for less.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 18:59
The problem with Redux is that there is no agreed upon best practices and Redux 101 does not land to being in the best practices category. That's my opinion, just an opinion, but so far, it seems that in practice lots of people would agree with that opinion.
devin ivy
@devinivy
Feb 16 2018 19:09
i don't think it's a principal of redux that actions and reducers are paired one-to-one! tools like combine-reducers and reduce-reducers make it easy to segment reducers vertically or horizontally without making any assumptions whatsoever about the relationship between actions and reducers.
i can imagine a different API that actually does couple those two things, but i have never gotten that feeling from redux. although i have seen other tools in the ecosystem that do encourage that kind of factoring.
they aren't necessarily very common, at least in my sphere.
for example, i often see logout actions clear many parts of the store.
Fred Daoud
@foxdonut
Feb 16 2018 19:11
"your statements are simply incorrect and misinformed."
I could say the same.
Once again: I don't like the Action Type/Payload structure of Redux, and I agree that it's not optimal. BUT you could have multiple proposed values and multiple acceptors in Redux.
Also, "acceptors know nothing about actions or the overall proposal structure" -- well they have to know something! Your tons of if something.foo !== undefined is knowing something about the proposal structure. Just because it's not as rigid as a fixed Action Type/Payload, doesn't mean that it doesn't know anything at all about what the action will be proposing. If you don't coordinate the two, nothing will work.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 19:11
Again, I am not saying this cannot be done, I am only commenting on what I perceive people are doing.
@foxdonut again, this is not correct a statement such as if something.foo !== undefined knows nothing is bar1, bar2, bar3 are part of the structure of the proposal. So I stand by what I said, the acceptors don't have to know anything about the proposal structure. The acceptors focus on the proposed mutations only, it doesn't need to know anything about the broad scope of the proposal (hence its structure).
An acceptor would/must be designed to accept only the property values it cares about, without any knowledge about anything else.
Without knowledge of the action which created the proposal or without the structure of the proposal itself.
Fred Daoud
@foxdonut
Feb 16 2018 19:16
I guess we cannot agree on this. This will suffer from the same scalability problem until a better solution than tacking on more and more if/else statements is found.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 19:19
it's ok, we don't have to agree. I am certain someone smart will figure out a better way, but if someone cares about my opinion, that decoupling action/mutation is essential, and cannot be compromised in any way.
This is what prevents writing spaghetti code and helps reason clearly about every event -> render flows.
This is what keeps the application logic complexity constant.
That's why I speak about "building blocks" and not components. All this code cannot be easily assembled into components. The boundary of a component is too constraining to factor typical event->render flows.
devin ivy
@devinivy
Feb 16 2018 19:23
i think that this is partly a communication issue. if i understand correctly, @jdubray you're talking about the many-to-many relationship between actions and acceptors by way of proposal structure. and @foxdonut you're talking about the many-to-many relationship between actions and acceptors by way of factoring the model into smaller parts. i think these two things really go hand-in-hand.
and i see redux as doing a fine job with factoring the model into smaller parts. proposal structure i see as an orthogonal concern to redux, but i appreciate that you don't see actions really looking like proposals in many codebases.
i don't know how many codebases you've seen. i mostly see those of the folks who i work with.
it's hard to know what's happening "in private," which is why i am focused more on what a library allows for.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 19:35
I think this is great summary, after that it's only a matter of opinion.
VaseJS
@VaseJS
Feb 16 2018 19:42
The main communication issue is the assumption that comparing SAM to React in useful. Not everyone has used React (I being one of them) so every time React or anything in its eco system is brought up, people are lost. SAM is a pattern, not a library. React is a framework/lib(idk), not a pattern. Apples and oranges. The only focus should be on how to improve the parts that need work. In order to do so we need more people using SAM to solidify it as a useful pattern.
Putting down React/Redux/etc is like the command pattern author complaining about how ExpressJS does things vs their pattern. It sounds ridiculous even as I make the comparison
Drama is good for tv not software development🎭
devin ivy
@devinivy
Feb 16 2018 19:44
SAM is about state management, especially for the web. so i think it would be sad to lose out on conversations about mobx, redux, meiosis, etc. who are concerned with tooling state management for the web.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 19:45
True, but there is a programming model behind React/Redux that is quite well documented, so I believe that we are commenting on that aspect.
Small differences in the programming model can lead to big inefficiencies when coding
devin ivy
@devinivy
Feb 16 2018 19:48
have you used mobx-state-tree @jdubray ? i think it might make for a very multi-purpose state representation that would work across UI libraries. would be interesting to implement the same app e.g. with polymer on the web and react-native for mobile using a single state representation. maybe a little academic but everyone is looking to reuse code across web and mobile :D
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:08
@devinivy from what I understand Michel assembled actions/model as class/methods with the actions responsible for the mutation. So I cannot support that kind of model.
So far Vuex is the only state management programming model that is aligned with SAM, all the way down to the TLA: S-tate, M-utation, A-ction.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:18

@VaseJS

Drama is good for tv not software development

yes, we should be comparing code not statements :-)

Fred Daoud
@foxdonut
Feb 16 2018 20:19
↑ ↑ oh yes, I'm down for that anytime.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:20
well, that's Redux 101, straight from their web site
function todoApp(state = initialState, action) {
  switch (action.type) {
    case SET_VISIBILITY_FILTER:
      return Object.assign({}, state, {
        visibilityFilter: action.filter
      })
    default:
      return state
  }
}
no decoupling between action/mutation
All samples I see that describe redux as just like that.
VaseJS
@VaseJS
Feb 16 2018 20:22
One of the best things that have been overlooked about SAM is that its can be vanilla JS. There is a body of people who don’t like frameworks due to the inverse control, again, I being one of them. Anything that keeps other people out of my code the better. Code reuse is cool, but people talk about like if its not done, you’re stupid. Thats a perspective. Code reuse also comes with security hole reuse, bug reuse, etc. The fact that SAM can do with Re* can do without a library is amazing. Adding a library to help only amplifies thats.
the negativity comparing SAM to anything has clearly run many people off. If we’re just saying here’s how Re*/Angular/Vues does it and compares, thats fine, but the bashing has to stop if SAM is to get anywhere beyond a cult following
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:24
@VaseJS understanding the difference is fundamental, again back to basics: STAR + TL (State, Type, Action, Relationship + Temporal Logic). We will never make progress if we speak at the level of practices.
VaseJS
@VaseJS
Feb 16 2018 20:25

@jdubray i don’t understand what you mean by

We will never make progress if we speak at the level of practices.

Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:26
We cannot even agree on what an action is!! can you imagine as an industry, seven decades on, we cannot agree on a definition. How pathetic is that? Negativity is not the problem, the problem is the unwillingness to have a discussion at the level of the programming model below languages, libraries and frameworks.
The discussion above is based on "I can do that with Redux". Yes, I can do anything with a function too. The question is what is the chosen programming model of Redux, is there one? or is it only practices, a guy sat down one day and coded a few things and everyone imitated him without questioning the "practices". You see a guy like Ben Lesh, hard to argue he is not super smart, yet he can only talk at the level of practices. We cannot have a discussion at that level, it's pointless.
Decoupling action/mutation is a programming model question, how I do it (pathetically) with if proposal.foo !== undefined is a practice, it does not interfere one bit with the programming model.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:31
I never try to emphasize what I do, I try to emphasize the programming model behind SAM so that people then can choose how the implement it. I am sure one day someone will find a much better way.
VaseJS
@VaseJS
Feb 16 2018 20:33
@jdubray yes, i’ve seen that a lot. definitions can cause problems, but thats not unique to software industry. Nonetheless, negativity is an issue. Not between the big guys like you and the React team, but it turns the smaller people off in dealing with things. But my question is why is the discussion needed with any particular people? if you want to talk above/below the code, start talking and stay focused on that level. the rules/laws of marketing don’t change and are not effected by anyone in the software world. The product in this case is merely an idea called SAM. The same steps must be taken to open people up to the conversation. Its not about hype, its about understand human beings. If this person was imitated without question its because he has clout. its he marketing advantage. because of this, people are pushing his idea forward. We may not have that clout but can be equaliy affective in getting people to push/evolve SAM and fix the issues for everyone using it.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:33
For instance I have argued that meiosis couples action with mutation since an action's implementation mutates the state. All samples I have seen are like that. @foxdonut and @devinivy argued that it was not true, it was just because of the samples I looked at. I'd be happy to be proven wrong, but the best way to argue this point is "show me the code"
VaseJS
@VaseJS
Feb 16 2018 20:33
@jdubray you’ve been coding longer than some of us have been alive. you have respect from many. You just don’t have a large brand behind you like Facebook or Google
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:34
I am not at coding per se. I need crutches like SAM to write good code :-)
So far, it's pretty much defect free, that has impressed me, but not completely surprised.
VaseJS
@VaseJS
Feb 16 2018 20:34
that doesn’t take away from the respect you have. I’ve seen people write articles about you and praise your efforts.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:36
Look, I am just frustrated that we cannot discuss at a level that is as simple as STAR + TL, 4 concepts and 3 operators (TL).
VaseJS
@VaseJS
Feb 16 2018 20:36
As I’ve said before, if you want to talk above or below the code, only talk there and don’t worry if others are unwilling to talk. those poeple are not the entire industry. No matter how big their company they work for is, they can’t move everyone in a direction.
We can discuss it at that level…start talking
Fred Daoud
@foxdonut
Feb 16 2018 20:36
@jdubray when you take a simple example like that and dismiss it, I could do the same with the canonical intro SAM example (the rocket launcher) and call out its flaws: global variables, lack of modularity, entanglement of code..
VaseJS
@VaseJS
Feb 16 2018 20:37
you have the attention of more people than you realize, but that conversation gets derailed by talking about Re*
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:37
@foxdonut I don't dispute it, I am just illustrating that often the discussion goes "ah XXX, yes we do XXX". Oh, you want to see some code too?
VaseJS
@VaseJS
Feb 16 2018 20:37
So let us digress and start the above/below the code conversation
if that will make me a better dev, then that’s all i care about. i don’t use or plan to use Re*
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:38

I don't have much more time today, but happy to continue. If you want to start from the beginning, it's starts here:

S1 = f12(S2)
...

We have to define what is S and how fxy is structured.
All programming languages have an opinion on that question even if it's not apparent
VaseJS
@VaseJS
Feb 16 2018 20:40
i did do some reading on state machines and have a better understanding after our discussion this morning. with that said, a comment you made now needs clarification to me. You said people don’t need to write like a FSM. But it seems that all sites are FSMs so what do you mean? Are you referring to something formal when writing the code? or something else
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:41
The programming model between FSM couples Actions with State. An FSM is a graph of states (nodes) and actions (edges).
The problem with FSM is that once you take an action you have already decided what state the system will be in
VaseJS
@VaseJS
Feb 16 2018 20:41
@VaseJS This is the original/first example. One of the goals was to show that SAM is well aligned with Finite State Machine, but I emphasize that it is an anti-pattern to try to fit FSMs in SAM. There is no need to. The structure of the pattern allows you to "code" state machines (the TLA+ kind), there is no need to create a separate set of semantics like FSM.
there it is. the anti-patttern to try to fit FSM in SAM
what do you mean by that if right above you say its well aligned?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:42
It works for small systems like a light switch, though now you have intelligent light switches that could adapt the light intensity based on the ambient light, so when you take the action of turning on the light, you don't have full control on the mutation.
SAM can degrade into an FSM
but an FSM cannot be aligned with SAM capabilities
It's very important that SAM does not conflict with FSMs.
It is as important to not fit FSMs within SAM. otherwise you get no benefit from using SAM.
VaseJS
@VaseJS
Feb 16 2018 20:45
we have to take a step back right there. so a FSM can be its own thing. so if it aligns with SAM but can’t fit within it, how is it implemented in SAM to cover many states?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:45
The problem is that FSMs is yet another commonly known paradigm, and yet again the React community seems to have seized the opportunity to trip over it.
VaseJS
@VaseJS
Feb 16 2018 20:46
so FSM as a thought model, not implementation?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:46
It has been both, but it's not even a thought model.
FSMs are not a good way to think about SAM.
VaseJS
@VaseJS
Feb 16 2018 20:47
if SAM is based on TLA, then is the state machine in TLA different than a FSM?
and is that a better way to thing about SAM?
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:47
I hate to throw more reading, but this post can provide some clarity: https://www.ebpml.org/blog15/2015/04/star-based-component-model-with-tla-semantics/
@VaseJS yes exactly a state machine is just a set of Sy = Fxy(Sx)
VaseJS
@VaseJS
Feb 16 2018 20:48
reading is good. keeps one from repeating themselves and enables us to be on the same page to have better conversations
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:48
FSM is just a subset of this general definition of a state machine, which in itself is not very practical.
But we have to agree that the purpose of any code we write aligns with Sy = Fxy(Sx) (and not FSM for instance)
VaseJS
@VaseJS
Feb 16 2018 20:49
because TLA was the first state machine formally introduced to me i don’t know enough to compare and contrast a FSM just yet
I think to have a better conversation, a discussion about the difference is needed between a FSM and a TLA state machine. I’m going to look into it and maybe after understanding FSM can add an article to keep others from being equally confused as right now, they seem very similar
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:51
I really need to go, sorry cannot continue the conversation today, but that's really interesting. At least that's the level I like to talk about. At that level we can compare and contrast all concepts without talking about practices, languages, libraries and frameworks.
VaseJS
@VaseJS
Feb 16 2018 20:51
no problem. we’ll talk soon. you’ve given me rabbit hole to go down.
Jean-Jacques Dubray
@jdubray
Feb 16 2018 20:51
Dr. Lamport never talks about FSM, never uses them.
devin ivy
@devinivy
Feb 16 2018 20:54
i missed a lot of the above, but i want to add— the simplest examples often aren't useful to exhibit a healthy factoring. the minimal redux example to show how to both use the library and how to factor your application in an ideal way would be rather extensive.
VaseJS
@VaseJS
Feb 16 2018 20:56
@devinivy I don’t believe comparing the two is even necessary. Only presenting a common problem and how SAM solves it is relevant. Re* should not even be in the conversation
devin ivy
@devinivy
Feb 16 2018 20:57
for me it's not about comparison, exactly. one is library and one is a pattern. i'm interested in how those two things interact. on a near-daily basis i use redux while applying ideas from SAM.
when you implement SAM you have to write code, and libraries may or may not be involved. from my perspective redux is definitely a library with which you could implement SAM.
VaseJS
@VaseJS
Feb 16 2018 21:03
but you have to know Redux enough to even apply SAM. Speaking about SAM alone and how SAM solves many problems is the only important aspect. Patterns seem to be an advanced topic in the dev world (i feel they should be basic, but thats me). Many people who use popular frameworks/libs (regardless of their effectiveness), rely on the FW/Libs to mask their lack of skills. @devinivy , you must be a better dev to use Redux and implement SAM. But in the content of a SAM environment, SAM must be king and Re* has no place. A good dev will be able to figure out how to use the pattern if enough examples are given of solving particular modern problems