Skip to content

Instantly share code, notes, and snippets.

@markerikson
Last active January 30, 2021 04:09
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markerikson/dc10ee3c6fcaee245ab02c2498ab53f4 to your computer and use it in GitHub Desktop.
Save markerikson/dc10ee3c6fcaee245ab02c2498ab53f4 to your computer and use it in GitHub Desktop.
jdubray statements on Redux

Jean-Jacques Dubray
@jdubray
Feb 06 23:05
@robwormald welcome! honored to speak to you. If you like Redux, well, SAM is the correct semantics that Redux should have had. It tried to speak to Dan about it, but he never replied to me. SAM's semantics are based on TLA+ so you can't find a more robust formalism.

Stardrive Engineering
@HighOnDrive
Feb 08 21:50
I'd say Redux definitely has its herd animal aspect 😄
Jean-Jacques Dubray
@jdubray
Feb 08 21:51
Yes, it looks like it. I found Dan's unwillingness to engage in a dialog part of this herd mentality, either you are in the herd or you are not.

Jean-Jacques Dubray
@jdubray
Feb 10 20:14
I added some thoughts on SAM and Redux in the sam-architecture room.
The gist of it is that the Redux semantics are fundamentally broken and people should stop using it right now, it will lead to the same spaghetti code that Flux lead to, just a different flavor.

Jean-Jacques Dubray
@jdubray
Feb 10 18:27
So I apologize to be that strong, but Redux is a piece of garbage, Dan came up with his own semantics, they are not stupid by far, but they are not representative of the proper factoring for what he set out to do. Indeed, it is very hard to reason about mutation and asynchrony, Dan being yet another proof.
There is someone how ever who spent his entire life thinking about this problem, Dr. Lamport. He came up with TLA+ and these semantics cannot be tweaked. SAM is based on TLA+ semantics. There are very easy to apply :

actions are pure fonctions: data' = A(data)  
model is responsible for every state mutation model.present(A(data))  
compute state from model S(model.present(A(data)))  
compute next-action-predicate and execute action if any S(model.present(A(data)), nap(M))  
Heck, he even got a Turing award for it.  
Who is Dan Abramov to come around and say, F#&$( that, I'll come up with my own, in a couple of days, publish a couple of cool videos on EggHead, speak to some hipster conferences, tell some stories about how "programming used to be", ... and throw away a lifetime worth of work?

Jean-Jacques Dubray
@jdubray
Feb 10 18:42
Well, I did try to engage in a conversation with Dan and so far he declined, so at this point I have no other words to use than "garbage"
I sent emails, tweets, whatever, looks like he is a busy man
I accept the challenge, will work on it over the week-end

Jean-Jacques Dubray
@jdubray
Feb 10 18:57
@robwormald let me however replay what Dan and you are saying:

there is a theory that describes precisely what Redux is trying to achieve  
that theory got a Turing award  
it's used at Amazon (and beyond) to solve some of the complex software engineering problem they have  
well, you know... we are not going to look at it for one second because,.. well because "there are thousands of real world applications in the wild using redux/flux like patterns"  
There are actually millions using MVC, so if I follow your rock-solid rationale, we should never look at Redux, correct?  

Rob Wormald
@robwormald
Feb 10 19:12
lets see in action. that's what i'm saying. you've made some pretty bold assertions about it. we'd like to see it in action. show, don't tell.

Jean-Jacques Dubray
@jdubray
Feb 14 13:04
You can think of it that way, but the reducer looks like a big ball of mud. Good luck in testing/debugging/maintaining that kind of code
decoupling is not just about reusing, there are concerns like cohesion and coupling that need to be taken into account and for me at least, actions should never be coupled to the model.

Mykola Bilokonsky
@mbilokonsky
Feb 15 18:15
Why are you sitting here insulting Dan, who is one of the kindest, most open, most thoughtful and most interesting programmers in the field today? He had a good idea, and he wrote it up. And a ton of people found it really helpful! And you're sitting here getting bitter about that, calling his innovation of a ball of mud and implying everyone else is just being fooled. Seems to me that you're just bitter at someone else's success.

Jean-Jacques Dubray
@jdubray
Feb 15 18:16
Dan has declined to answer any of my requests to talk for the last couple of months.
Mykola Bilokonsky
@mbilokonsky
Feb 15 18:17
Dan went from being a kid in a dorm room to one of the biggest rock stars in programming over night, you think he has time to answer every request?
If your writing and attitude here is any indication you probably sent him a really condescending message and he had better things to do, but that's just my inference.
And anyway it doesn't justify sitting here shitting on him

Jean-Jacques Dubray
@jdubray
Feb 19 16:32
well... it would be true if there was a second step in redux such as model.present, but from a React perspective, you are done, the new state then triggers a view refresh.
again, there is action logic (what are the proposed value for the model)
then there is model logic, knowing what I know about the state, should the model accept these values or not
you can say redux does it already, sure, why not, but philosophically, this is not at all how Redux is presented, it is truly presented as the actions and the model updates are both happening in the Reducer.
I know it's a small point, but actually essential. That's the problem with all these semantics they all look the same, but they are not, they yield a very different factoring of the code. They cannot arbitrarily be defined, such as the one Dan defined. What redux does is not "stupid", but it is very different from SAM.
I am not quite sure why Dan has not joined the conversation, the article has had 200k views, retweeted hundreds of times. Is he afraid of something? If it was such a slam dunk to show that SAM is in effect Redux, we'd be done.

Jean-Jacques Dubray
@jdubray
Feb 19 16:37
But it's not, again, two very different semantics, whith SAM:

  1. actions (proposed values) are fully decoupled from the model (accepting proposed values)
  2. there is a next-action-predicate (once the model has mutated, anything we still need to do?)
    Redux puts A+M+nap() in a nicely bundled reducer, and no reducer "composition" does not decouple them at all.
    For Dan event sourcing happens at the intake of the reducer, when for me event sourcing happens at the intake of the model, the code that computes the proposed value (A() and nap()) is irrelevant to state mutation. This is a fundamental, absolutely fondamental difference, it changes everything actually.
    Are we in agreement?
    As I explain in the article, the traditional State Machine semantics which Dan uses are what he found in CompSci 101 textbooks: a state machine is described by tuples of the form (S1,A,S2).
    That definition is unfortunately based on an approximation. I am sure Dan likes it because it yields a familiar graph :-)

Jean-Jacques Dubray
@jdubray
Feb 19 17:39
The only questions are:

how much will it cost?  
what part of the solution are reusable for other solutions?  
how maintainable is my code?  
how many defects / 1000 of LOC my factoring produces vs another  

Redux does not scale to real-world applications. Not much to add.

Jean-Jacques Dubray
@jdubray
Feb 19 18:07
yes, having at least one good sync point is enough for 80-90% of the problems otherwise you'll generate 10x the amount of bugs without it
Maas-Maarten Zeeman
@mmzeeman
Feb 19 18:07
And those bugs are hard bugs.
Jean-Jacques Dubray
@jdubray
Feb 19 18:08
very very hard, inextricable
this is why I am so critical of Redux
this is why I had set out to talk to Dan originally rather than writing a paper
Because Redux was close enough, and with enough traction that I would have preferred working with him to convince him to adopt TLA+ semantics
but, he chose not to respond, not just to me that apparently to anyone that asked him to comment on SAM

Jean-Jacques Dubray
@jdubray
Feb 19 18:12
Yes, I understand, these are very complex questions, that's why I get a bit irritated and condescending when people tell me it is all the same
it is not, it is very very hard questions to deal with, and I would have just been happy to have a chat with Dan, point him to TLA+ and say, look at these semantics, I think they can make Redux better
Now he has to align Redux with SAM and I can claim (and predict) that's what he is going to do.

Jean-Jacques Dubray
@jdubray
Feb 19 18:20
I am generally not, but I get "sensitive" when people come to me and say "it's all the same"
Note that Dan has started to adopt the language "nextNotification" and he talks also about "call APIs" from the reducer .... in his response to how to deal with async actions in Redux http://stackoverflow.com/questions/35411423/how-to-dispatch-a-redux-action-with-a-timeout
So.. I know he read the paper...
I'd be really surprised if he didn't

Dan Abramov
@gaearon
Feb 22 19:09
I'm happy to chat but my understanding of SAM is still very limited

Dan Abramov
@gaearon
Feb 22 19:12
But for starters I want to say that the way you take little jabs at React team or me here and there is immature, off-putting and counterproductive. You can totally explain your ideas without resorting to that, and I would argue that one of the reasons your ideas don't seem to catch on in the React community is that your attitude is unfriendly and highly defensive.

Jean-Jacques Dubray
@jdubray
Feb 22 19:12
All right, can we put that behind, I understand the criticism. I'll refrain.
As I mentioned, I tried to contact you in December to see if you would be interested in looking at aligning Redux with TLA+ semantics. You now have that email.

Dan Abramov
@gaearon
Feb 22 19:46

As I mentioned, I tried to contact you in December to see if you would be interested in looking at aligning Redux with TLA+ semantics. You now have that email.   

If you contact somebody and they don’t reply it doesn’t automatically mean writing mean things about them is cool ;-)

Dan Abramov
@gaearon
Feb 22 20:04
Finally, I am not as smart as you, and stuff like TLA+ melts my brains. If it is superior for using the set of problem Redux currently tries to solve, please port some Redux examples to use it, and show how this is the case. Redux examples are here: https://github.com/reactjs/redux/tree/master/examples. I would expect that you could reuse most of the UI and just tweak the model and side effects to match SAM. I’d be very happy to look at the result and compare it to Redux.
Is there anything else I can help you with?

Dan Abramov
@gaearon
Feb 22 22:56
Yeah, I’ve looked at http://www.loria.fr/~merz/talks/argentina2005/slides.pdf but this is too math heavy for me
I will assume SAM relies on some guarantees that TLA+ proves exist
Jean-Jacques Dubray
@jdubray
Feb 22 22:56
I understand, it took me 6 months to scratch the surface.

Jean-Jacques Dubray
@jdubray
Feb 22 23:30
Well being a BPEL/BPM expert, having built my a couple of commercial stateful process engines and worked with people like Mark Little and Eric Newcomer on WS-TX and WS-CAF...

Jean-Jacques Dubray
@jdubray
Feb 22 23:36
Sagas help but it is contrainted
Yes, but again not all semantics are equivalent, when you need semantics that are not supported by Sagas, then you are essentially dead.
All I can see is that you have been able to build a community around some important concepts that have been critically missing in Computer Science, now, how about carefully landing these semantics so that people end-up doing the right thing rather than continue doing hacks?
Sagas are a hack as far as I am concerned.
Not worthy of all the work you have done so far.

Jean-Jacques Dubray
@jdubray
Feb 23 08:19
@omnidan https://bitbucket.org/snippets/jdubray/ and many code samples provided by others as well https://gitter.im/jdubray/sam-examples
@idibidiart I don't dispute that, I also have 25 MDSD/MDE experience, with deep roots in that community, not to mention 10+ years working deep inside IT, so from all I know things SDO or GraphQL works well in well formed domains, not surprised it works well for Facebook. Now we have seen so many advances in Computer Science that seemed impossible before...
Heck I am even co-author of a patent that specifies a method for automating construction of the flow of data driven applications in an entity model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment