These are chat archives for jdubray/sam

4th
Apr 2016
weepy
@weepy
Apr 04 2016 07:18
just looking at a bit of REDUX for comparison
how would you compare presenters and reducers - they seem to have a similar purpose ?
this article has a good example of Reducer Composition. Does SAM fit into this ?
Jean-Jacques Dubray
@jdubray
Apr 04 2016 07:53
there is a comparison on Sam.Js.org. the factoring is different, nearly imperceptibly different, but IMHO leads to a very different outcome.
Redux offers no server side model, no articulation to call APIs (a great React tradition) anddies not scale at it requires you mutate 100%of the application state for every step.
weepy
@weepy
Apr 04 2016 11:17
Are you sure about the last statement ?
Jean-Jacques Dubray
@jdubray
Apr 04 2016 14:34
yes the reducer require s that you mutate 100 of the application state at every step.
devin ivy
@devinivy
Apr 04 2016 14:39
it does require that you replace the app state. but libraries like immutablejs sort of prove that it doesn't have to be a huge performance concern, right? large portions of the app-state do not necessarily need to be replaced. polymerjs takes an interesting approach, where the operations you perform on the state of a component are actually described to the framework by virtue of the fact that they're made using the framework's API.
Jean-Jacques Dubray
@jdubray
Apr 04 2016 14:52
I sure would be curious to see some numbers. the point is that this is a completely unnecessary approach.
Fred Daoud
@foxdonut
Apr 04 2016 15:28
what are you doing in sam instead @jdubray ?
Jean-Jacques Dubray
@jdubray
Apr 04 2016 15:32
the model is mutated in place. The actions which are pure functions lije the reducer have a much smaller footprint (in general).
devin ivy
@devinivy
Apr 04 2016 15:33
is the reducer more specific about what piece of state it works on?
Jean-Jacques Dubray
@jdubray
Apr 04 2016 15:33
for me the deal breaker with Redux is the problem of articulating API calls in relation to the model mutation:
1) validation and enrichment
2) persistence of the model
Fred Daoud
@foxdonut
Apr 04 2016 15:35
to me, mutating the model in place is a deal breaker. that makes functions impure, makes code harder to unit test, and introduces a ton of problems.
Jean-Jacques Dubray
@jdubray
Apr 04 2016 15:35
this is not true because you have a single state tree
you are never in the position where this causes any problem, otherwise I would not be able to time travel
the unit test is simply given a snapshot, I present some data, what is the new state? this is exactly what a reducer does.
Jean-Jacques Dubray
@jdubray
Apr 04 2016 15:43
I architect a system to meet some expected behavior then I design a test strategy.
Sorry guys it is nearly 2 am in Sydney. I need to drop.
devin ivy
@devinivy
Apr 04 2016 15:44
:) sleep well!
Jean-Jacques Dubray
@jdubray
Apr 04 2016 22:53
@foxdonut I am dispassionate about this argument, the concept of a reducer makes no sense at all because it does not represent how state mutates. Again state mutates following a simple cycle: propose, accept, learn. Redux's architecture's "accept" step is basically telling the store what to accept whatever has been proposed to it. That makes no sense. The accept step is fundamental to mutation: accept != assignment.
Fred Daoud
@foxdonut
Apr 04 2016 23:10
@jdubray that is incorrect. the reducer is not in any way forced to accept what has been proposed to it.
Jean-Jacques Dubray
@jdubray
Apr 04 2016 23:13
the store is, the store has to accept whatever the output of the reducer proposes
again with Redux (and any reducer based scheme) there is no delineation between propose and accept, that is fundamentally flawed
that is a pure instance of Reactive Cargo Cult
Fred Daoud
@foxdonut
Apr 04 2016 23:15
I think you misunderstand. When the reduce function gets invoked, that is propose. The function then decides whether to accept.
I had to look up cargo cult.. :)
Michael Terry
@formido
Apr 04 2016 23:18
A great phrase from the inimitable Feynman
very handy
Fred Daoud
@foxdonut
Apr 04 2016 23:19
Anyway I don't do well with grand statements, I need to see the code to be convinced. You've done a great job of making more code and examples available. I need some time to have a closer look, until then I'll stop arguing with you and give you the benefit of the doubt.
Jean-Jacques Dubray
@jdubray
Apr 04 2016 23:19
Unfortunately, again, the factoring in Redux is arbitrary. It uses "intents" to propose which is not right, intents trigger actions. Actions propose values.
You should look at the TODOMVC, I think that's the clearest.
Fred Daoud
@foxdonut
Apr 04 2016 23:19
link?
You can also compare with many other implementations
Fred Daoud
@foxdonut
Apr 04 2016 23:20
thank you :thumbsup:
Jean-Jacques Dubray
@jdubray
Apr 04 2016 23:21
You are welcome