These are chat archives for jdubray/sam

1st
Jun 2016
Tiago
@tiagocpontesp
Jun 01 2016 15:08
isnt MobX just an "f"? I think of it as a polyfill for Object.observe -- which is a function. It doesn't specify the action that triggers the function, does it?
V = observe(M)
Don't you believe it to be valid on many usecases?
Tiago
@tiagocpontesp
Jun 01 2016 15:21

Maybe the action, for all these intents and purposes, is the beggining of the observation.
Do you think that's problematic?

I reckon it's not ideal to think about a(f()) as one sole function, when trying to conceptually decomposing the state machine, but in a higher level paradigm I can't see how it can bring issues.
I believe one should think on a lower level only if it is required.

why can't i edit these messages :S sorry if my english isn't perfect.
I'm using mobx.action within my M.present()
Tiago
@tiagocpontesp
Jun 01 2016 15:43
V = S( vm(M.present(A(data))), nap(Model) )
in my current app and mental model:
PathnameAndViewPort = ReactComponent( adaptations_within_the_component_module( M.present( mobx.action(data) )), actions_that_may_change_pathname(Model) )
I think of the pathname as an inevitable part of both model and state.
I'd love for you to tell me whatever may bother you in this setup @jdubray .
Jean-Jacques Dubray
@jdubray
Jun 01 2016 19:12
@tiagocpontesp V = observe(M) is very different (IMHO) because it brings a stronger coupling between the view and the Model. V = obs(M) requires that the model conform to the view and that's (IMHO) an anti-pattern. That's also the part I don't like about React/Redux, it forces you to make all the changes to the store at once.
Now, I am not saying you cannot implement SAM with React or SAM, but you feel extremely constrained by this kind of "reaction". You basically have to create a "container" that implements the whole pattern, it's not very modular.
var SAMContainer = React.createClass({

            // Model -------------------------------------------------------
            getInitialState: function() {
                return this.props.model 
            },

            present: function(data) {
                data.incrementBy = data.incrementBy || 1 
                this.setState( {count: this.state.count + data.incrementBy} )
            },  


            // Actions -----------------------------------------------------
            click: function() { this.present({incrementBy:1}) },


            // State -------------------------------------------------------
            nap: function() {
                // there are no automatic action in this example  
            }, 

            render: function() {
                this.nap() 
                return theme.counter(this.state.count, this.click) 
            }

        })
Jean-Jacques Dubray
@jdubray
Jun 01 2016 19:19
What SAM brings is:
  • 100% decoupling between the View and the Model (S() being the reason why this is possible)
  • as a corollary, decoupling between APIs and the View (Actions and Model)
Jean-Jacques Dubray
@jdubray
Jun 01 2016 19:30

We have to distinguish between:

  • programming model
  • wiring
  • architecture

"wiring" is not a programming model, no matter how much people want it to be.

devin ivy
@devinivy
Jun 01 2016 19:31
i think that would make for a great article.
even a short article that distinguishes those three things would be very pertinent right now. though i understand what you're getting at, i can't say i could easily summarize the differences between the three.
Tiago
@tiagocpontesp
Jun 01 2016 20:20
But I'm quite sure my model isn't conforming to any of the views
stronger coupling in my case means less boilerplate, which translates into less work
Jean-Jacques Dubray
@jdubray
Jun 01 2016 20:25
@devinivy I am preparing a presentation for NodePDX on this very topic
devin ivy
@devinivy
Jun 01 2016 20:26
:)
Tiago
@tiagocpontesp
Jun 01 2016 20:26
Thank you for your time. When I have this a little more composed maybe I could share a screenshot of the project structure. The folders are even named according to this architecture :)
Jean-Jacques Dubray
@jdubray
Jun 01 2016 20:27
@tiagocpontesp well, I would argue otherwise, but at some point it will have to be an opinion. I see the simplicity of an "observer", from experience, I just know that does not scale. It looks pretty with a counter, in the real world, even React falls apart.
And react has one of the best decoupling between View and Model, yet it has a terrible wiring and architecture.
Tiago
@tiagocpontesp
Jun 01 2016 20:28
Lets hope I get this to that point (or not :))
Ofc the one-size-fits-all solution would have to be as less abstracted as possible
Jean-Jacques Dubray
@jdubray
Jun 01 2016 20:30
Happy to continue the discussion, as I say, I don't care to be right, I just don't want to be wrong.
Tiago
@tiagocpontesp
Jun 01 2016 20:30
I don't think you are. This has all been very useful. I just won't go head first and ditch all the tools :)
It's just*
Jean-Jacques Dubray
@jdubray
Jun 01 2016 21:32
I understand, I am a first principle guy -> that involves throwing everything away :-)
Jean-Jacques Dubray
@jdubray
Jun 01 2016 21:42
But again, happy to be proven wrong, I just don't want to say wrong things.

For instance, what I like about TLA+ is that, Dr Lamport says (page 1):
1/ State machines provide a framework for much of computer science.
2/ I found a way to ... to describe and manipulate them with ordinary, everyday mathematics—
that is, with sets, functions, and simple logic.

That's first principle for me. You can find higher order semantics, but I bet you won't go below

devin ivy
@devinivy
Jun 01 2016 21:45
hahaha, i like that challenge
Jean-Jacques Dubray
@jdubray
Jun 01 2016 21:45
and ultimately, I am happy if there is a better programming model that SAM/TLA+, but that programming model would have to somehow align with TLA+
@devinivy Again, I am happy if that's the case, then we would have a super strong foundation to move forward, I don't care about being right, I just don't want to be wrong.
Functional Reactive Programming is not at first principle level, things like RxJs can't be further than first principles. It does not mean they are wrong or useless, it just means you have to be careful when you use them.
@devinivy so let's start with the following statement:
1/ FRP provides a framework for much of computer science
2/ I found a way to ... [you fill the blanks]
devin ivy
@devinivy
Jun 01 2016 21:53
yes, i mean the challenge to go below sets and functions semantically to describe state machines :P
Jean-Jacques Dubray
@jdubray
Jun 01 2016 21:53
good luck with that...
devin ivy
@devinivy
Jun 01 2016 21:55
yeah, i'll just start writing my programs in assembly too
Jean-Jacques Dubray
@jdubray
Jun 01 2016 21:56
we might not be speaking the same language