These are chat archives for jdubray/sam

2nd
Nov 2017
devin ivy
@devinivy
Nov 02 2017 03:56
a must-share in case you haven't already crossed it, @foxdonut @jdubray https://github.com/PolymerLabs/lit-html
hope you all are well!
Jean-Jacques Dubray
@jdubray
Nov 02 2017 08:02
@devinivy thank you! this is really incredible, exactly what I was looking for. I'll produce a code sample.
Paolo Furini
@pfurini
Nov 02 2017 09:36
@jdubray @devinivy it's a really interesting project, but unfortunately it's not production ready yet.. I hope it will succeed and gain broader browser coverage
Jean-Jacques Dubray
@jdubray
Nov 02 2017 12:16
@pfurini Incidentally, you can see in an example as simple as the clock demo the problems of not using a proper step, such as the SAM step: action->model->state. The tick event triggers "setDate" which itself triggers rendering via "invalidate", that illustrates perfectly what is wrong with the way we code, scale that to hundreds of events, tens of thousands of lines of code, then try to debug and maintain that kind of code.
  get date() { return this._date; }
  set date(v) { this._date = v; this.invalidate(); }
Paolo Furini
@pfurini
Nov 02 2017 12:25
@jdubray this is from lit-html samples?
Paolo Furini
@pfurini
Nov 02 2017 12:31
I, myself, don't like this simplistic approach on "invalidating" a component's state to trigger rendering, but it's less dangerous when done inside a black-boxed UOW, like this simple component.. if that was a complex component, like a data table, with tens or more properties (and hence complex state) then it would've been unacceptable
Jean-Jacques Dubray
@jdubray
Nov 02 2017 12:41
yes this is from the demo code: clock.js
I am just trying to illustrate that on everage it's difficult to pay attention to these details, IMHO, it's better to stay within the structure of a Step
Paolo Furini
@pfurini
Nov 02 2017 12:49

I am just trying to illustrate that on everage it's difficult to pay attention to these details, IMHO, it's better to stay within the structure of a Step

You're absolutely right, and hence why I was insisting on creating a more "streamlined" culture around SAM.. I mean, trying to write down easy-to-follow "recipes" for common scenarios/technologies (e.g. one for writing Web Components with, say, Polymer or Stencil or lit-html, with an embedded SAM service)

Jean-Jacques Dubray
@jdubray
Nov 02 2017 12:49
:+1:
Paolo Furini
@pfurini
Nov 02 2017 12:51
In this case samples are just not enough.. what I mean is a reference implementation, with accompanying docs, and maybe some generator support (like plain old Yeoman), with a couple of samples (intermediate level + something complex enough)
Jean-Jacques Dubray
@jdubray
Nov 02 2017 14:37
yes, I understand, it's just me, I also need to make a living, I wish I could spend more time, but that's not possible right now.
Fred Daoud
@foxdonut
Nov 02 2017 14:39
cool, thanks for sharing @devinivy !
Paolo Furini
@pfurini
Nov 02 2017 14:52

yes, I understand, it's just me, I also need to make a living, I wish I could spend more time, but that's not possible right now.

I feel your pain, it's the same for me of course ;) I only wanted to point out what SHOULD be done (IMHO), hoping that someone with some spare time, and good will, could "adopt" that task.. :P

Paolo Furini
@pfurini
Nov 02 2017 15:03
well that's not exactly a map of frameworks, but it's really interesting for getting a "grasp" on the major stacks/tools
to do the same for JS frameworks, and be able to print it, you'd need an A0 paper size just for the actively maintained ones :P
Fred Daoud
@foxdonut
Nov 02 2017 20:01

@jdubray in a presentation I saw that RxJS "solves" a problem with one of its (way too many) operators: switchMap.
The problem being: say you issue a request to your server to get data filtered by criteria "X". The user gets impatient and issues another request to filter by criteria "Y".
Say the response to "Y" is faster than "X". So the view updates to show the data filtered by "Y", but later when the response to "X" finally arrives, it updates the view and the user is left looking at unexpected data.

It seems to me this is easily and elegantly solved by SAM with a "step counter" or other form of "proposal ID" where the model knows that the most up-to-date response it expects is the one with the ID that is associated to "Y". Then, later when the response to "X" arrives, the model knows that the ID is invalid/outdated, so it refuses the proposal and the view is left unchanged and still correct.

Would you concur?

I'm pretty certain you've already illustrated this in a similar use case, but I just wanted to make sure.
Jean-Jacques Dubray
@jdubray
Nov 02 2017 20:16
SAM-SAFE solves this generically (actually counting steps and tagging every action instance with the step number).
@foxdonut when two action instance compete to present a proposal to the same step number only one wins, though you are free to implement more complex behavior. The idea is simply to keep track of the relation action instance - step number, after that the sky is the limit.
Fred Daoud
@foxdonut
Nov 02 2017 20:20
@jdubray thanks! I much prefer this sort of solution instead of plethora of library-specific operators.
Jean-Jacques Dubray
@jdubray
Nov 02 2017 20:20
I don't want to look like I am fooling myself, but I never found yet a big hole in SAM (people can keep me honest, I don't look for praises), but I have been working with it for exactly two years now, and I never felt that there was something that was difficult to achieve with SAM. Again, I may not be working on complex enough projects. @dagatsoin seems to have touched on some limits.
@foxdonut :+1:
Fred Daoud
@foxdonut
Nov 02 2017 20:21
What were these limits?
Jean-Jacques Dubray
@jdubray
Nov 02 2017 20:22
not sure, his model is huge (it's a multiplayer game).
Comparison between lit-html and other popular rendering frameworks https://pbs.twimg.com/media/DNQu5uRU8AE_4wM.jpg
Paolo Furini
@pfurini
Nov 02 2017 21:00
@jdubray SAFE is the node.js implementation of SAM?
Jean-Jacques Dubray
@jdubray
Nov 02 2017 21:09
No, everything in SAM is isomorphic! it works in both cases!
UI Stack: A Chrome extension that lets you see a website's framework and libraries
Jean-Jacques Dubray
@jdubray
Nov 02 2017 21:15
I am not sure Stencil.js will be able to compete against lit-html
https://www.youtube.com/watch?time_continue=12&v=Io6JjgckHbg
Paolo Furini
@pfurini
Nov 02 2017 21:32

I am not sure Stencil.js will be able to compete against lit-html

in the long term, maybe.. today, if I have to choose, I'd go for stencil. Given the fact it MUST be stable enough to be the base of all Ionic platform components (that I personally use), makes me feel more confident using it for my own components