Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 21 04:28
    dependabot[bot] labeled #36
  • Jan 21 04:28
    dependabot[bot] opened #36
  • Jan 21 04:28

    dependabot[bot] on npm_and_yarn

    Bump immer from 2.1.5 to 8.0.1 … (compare)

  • Jan 05 15:01
    jdubray closed #35
  • Jan 05 15:00
    jdubray commented #35
  • Jan 04 22:45
    TimoteusRuotsalainen opened #35
  • Dec 11 2020 07:36
    dependabot[bot] opened #34
  • Dec 11 2020 07:36
    dependabot[bot] labeled #34
  • Dec 11 2020 07:36

    dependabot[bot] on npm_and_yarn

    Bump ini from 1.3.5 to 1.3.7 in… (compare)

  • Dec 11 2020 05:16
    dependabot[bot] labeled #33
  • Dec 11 2020 05:16
    dependabot[bot] opened #33
  • Dec 11 2020 05:16

    dependabot[bot] on npm_and_yarn

    Bump ini from 1.3.5 to 1.3.7 in… (compare)

  • Dec 10 2020 17:29
    dependabot[bot] labeled #32
  • Dec 10 2020 17:29
    dependabot[bot] opened #32
  • Dec 10 2020 17:29

    dependabot[bot] on npm_and_yarn

    Bump ini from 1.3.4 to 1.3.7 in… (compare)

  • Nov 26 2020 02:46
    samirm closed #31
  • Nov 23 2020 01:25
    jdubray commented #31
  • Nov 23 2020 01:24

    jdubray on master

    adds star-java library (compare)

  • Nov 22 2020 18:55
    samirm commented #31
  • Nov 22 2020 18:52
    jdubray commented #31
Steve Pritchard
@srp7474
@jdubray I wrote about SAMCAS in this forum last July. I have recently dropped a Dart/Flutter implementation of SAMCAS at https://gael-home.appspot.com/docs/samcas/api/index.html . please check your gmail for more information.
Jean-Jacques Dubray
@jdubray
@srp7474 thank you Steve
davidhq
@davidhq
Hi ! I'm happy to be introduced to this community by one of the members. Hope to explore the SAM approach. I have a very basic, perhaps naive question to help me orient better.. I hope it's not too simplistic... I've read the "the three approximations you should never use" article and so my question would be: does SAM pattern replace or complement statecharts? More concretely the question is: if I want to use some state management library in my project and I know about xstate and SAM libraries, would you say that both can be used at the same time or rather not and from this perspective only SAM is enough and there is usually no need for constructs provided by xstate library if I want to make a successful reactive GUI? THANK YOU
Jean-Jacques Dubray
@jdubray
@davidhq, welcome!
1/ I would say it complements/augments them. It is strictly compatible but supports a more practical management of the application state, especially when the application state is complex, subject to many different actions.
2/ I am not sure how they can be used at the same time, for sure SAM supports a child/parent relationship and one of the children would be a child (or the parent) as long as XState would enable calling an intent (a wrapped action in SAM). An intent is a simple function so I don't see any difficulty. XState should be able to weave these functions in its programming model. I would not try integrating XState and SAM directly though it might be possible (say XState as an acceptor updating the currentState of the model). I am not sure how the View would react to that kind of integration. I would think that SAM is enough and better than XState but I am biased. XState has enjoyed some success, I suspect because of the graphical tool. My main issue with State Charts is that they do not scale in scope, at some point the State Chart becomes too big to maintain.
3/ What framework do you plan to use for the GUI?
davidhq
@davidhq
Thank you for a clear answer. Will explore more regarding all of this. A bit time constrained at the moment. 3/ Svelte
zevenbergm
@zevenbergm
@jdubray : Do you still have a copy of this article: "Business Object Modeling: an XML-based approach"?
Jean-Jacques Dubray
@metapgmr_twitter
Do you have more context? Are you talking about that paper? http://jeffsutherland.org/oopsla99/Dubray/dubray.html
@davidhq I tried to write a sample with svelte but I could not get it to work. Feel free to share some code sample, I am interested in getting it part of the SAM samples.
zevenbergm
@zevenbergm
@jdubray: yes, there’s an reference in that paper to “Business approach ...”. We’re facing similar challenges, that’s why I’m interested. Maybe a bit out of topic for this group but ... 😉
Jean-Jacques Dubray
@metapgmr_twitter
@zevenbergm oh my, that is quite old, it must be somewhere in an old hard disk. My views probably have changed a lot. At the time people where trying to align business objects with classes, an n-tier architectures where not even uttered. I'll see what I can find.
zevenbergm
@zevenbergm
@jdubray : Thanks! Don’t put too much effort into it. 😉
Radu
@raduab_gitlab
I'm trying to implement a todo app in Svelte. Are there any API docs for the sam-lib? (https://github.com/jdubray/sam-lib). I saw the README, but I may need more detailed information. For example for the setRender function, it says setRender : sets the render method and that's it, no parameter defintion. In the change log it says other things 1.4.1 Changes setRender to accept only one function (or two). This has to be consistent. Which are the setRender accepted parameters? And what do they do exactly? For example for the 'retry' function there are more details for parameters retry { delay, max } when specified, it will retry invoking an intent in case of an unhandled exception up to max times and after delay ms.. Also a more comprehensive explanation of the lib's functions will be very welcome. I think I'm not the only one who struggled. Thank you.
Jean-Jacques Dubray
@jdubray
@raduab_gitlab The best is to look at the unit tests. I put a bit of effort to cover all the use cases, if you have further questions I can try to answer them.
Radu
@raduab_gitlab
@jdubray this should be still documented, it will be easier for new adopters to jump the SAM bandwagon. Looking at the tests is an option, but not very straightforward. A book would be better of course, but for starters, a little bit more documentation would suffice. I did answer my question by looking into the sam-actions.js file from the lib directory and not into the sam.test.js file (more of this later below). There I could see starting from line 23 that the setRender function is transforming its render parameter, if it's an array, into a function of the state which returns the result of the function represented by the first item of the array which in turn it takes a parameter (the state) or the result of the function represented by the second parameter which is another function of the state parameter. If the setRender parameter is not an array, it simply returns the result of SAM({ render: F(render) }) which I don't know ATM what it does... Oh boy, that took me some time to figure... Here is the whole code I'm talking about:
  setRender: (render) => {
    if (Array.isArray(render)) {
      const [display, representation] = render
      render = state => display(typeof representation === 'function' ? representation(state) : state)
    }
    SAM({ render: F(render) })
  },
Radu
@raduab_gitlab
To continue, I don't know what the F function is doing or what it's used for. Just looking into the sam-utils.js file I can tell that it takes one or two parameters, with the second defaulting to a null function, and it returns the output of the function from its first parameter (render in the case of setRender function) or the output of a second function if it is received as its second parameter. At this point, I don't know where to dig more for an answer regarding the F function. Maybe I can understand this after investing more time into deciphering the code, but this also should be documented somewhere or at least you should add some JSDocs. Another problem is naming things in your lib. I know that naming things is one of the most difficult problems in computer programming, but still, just F is making me remember javascript obfuscators... Speaking of this, diving into the sam-utils.js file I see a lot of other similar examples. I struggled to understand what E function is doing, after finding it used in the sam.test.js file where you first instructed me to look for answers to my questions. I could understand the code - probably - but still, can't understand its usefulness (not that I think it is not useful, but don't know what it's used for and in what situations exactly..)
Radu
@raduab_gitlab
Please understand that I do think the SAM pattern concept is the way to go for state management and programming in general and I want to use it in a project ATM, but I'm struggling with the library you proposed. I maybe not a very good coder myself, but I still think that the library should be more documented if we want to spread the pattern and bring more enthusiasts to our small community. The pattern itself is quite simple but like many simple things, it can bear many interpretations.
Jean-Jacques Dubray
@jdubray
@raduab_gitlab sam-utils contains an implementation of my view of optional chaining. The series of functions A,O,S,N,F make sure that the type of the argument is an A)rray, O)bject, S)tring, N)number, F)function.
The code does say // Optional chaining implementation
@raduab_gitlab thank you, please do not get stuck for a long time, feel free to ask as many questions as you want, I monitor this list (especially if people use it often) and will answer your questions.
It's difficult to invest in a book, I wrote/contributed to 3 and will never do one again.
Jean-Jacques Dubray
@metapgmr_twitter
Happy and safe holidays to everyone!
Radu
@raduab_gitlab
Thank you! Best wishes to all here!
david kaye
@dfkaye_twitter

Et à vous aussi, JJ!

(Hope I got that right ;)

Jean-Jacques Dubray
@jdubray
thank you! (oui)
Jean-Jacques Dubray
@metapgmr_twitter
Look what I found! https://youtu.be/D_sh1nnX3zY
A TLA+ plugin for VSCode
Timoteus Ruotsalainen
@TimoteusRuotsalainen

I'm trying to use the SAM pattern in a project I'm working on. I have been trying to figure out what would be the best balance between the client and server.

I have other clients in addition to browsers and I would like to provide one API that all clients will use. Usually I would expose a REST api that could be used to fetch the initial information and a websocket that would send updates to the information in real time to all clients.

Do you have any examples of this kind of use case with SAM? Should I render multiple versions in the stateRepresentation for different clients?

Timoteus Ruotsalainen
@TimoteusRuotsalainen

For example let's say the app was a book reading app that also allows people to read together.

Each client should be able to read their own book at their own pace. The model needs to keep track of each clients book and which page they are own.

Clients could also read together. Their book and page is synced. Any client can change the page and all other clients who are reading together will also get the page change.

There are also ebook readers which need to get the book in their own format instead of html.

Jean-Jacques Dubray
@jdubray
@TimoteusRuotsalainen I would say that this would be a great application for the SAM pattern. A priori, I would run actions, model and state representation on the server, and the state-representation to view rendering on the client. Each user would have their own session. I have given an example of that in the SAM-SAFE library using DynamoDB. I would also create "group sessions" with their own actions. The group actions would then send a proposal to each user model (nothing says you can't do that) and each user's state representation would be computed as usual. WebSockets should be no problem for SAM. I played a bit with them but in general, I kind of prefer either a straight request (action ) / response or polling. I am uncomfortable using WebSockets at scale, but it might be because i am not familiar with the technology.
to answer specifically this: There are also ebook readers which need to get the book in their own format instead of html. nothing prevents you render the state representation on the server, for HTML I would rather do it in the browser, for others the rendering can also be done server-side, it's just more difficult to have a fluid UX (perhaps).
Let me know if you have more specific questions. Here is the link to the SAM-SAFE library: https://github.com/jdubray/sam-safe
Please note that the latest SAM library should work better (https://www.npmjs.com/package/sam-pattern), I would only take a look at SAM-SAFE for the session management.
Timoteus Ruotsalainen
@TimoteusRuotsalainen
Thank you for your answer! I will look into the things you mentioned. The SAM pattern seemed very interesting because we are already working in a similar way and with some small changes it would allow us to organize our work in a better way and maybe even take advantage of the TLA+ background in some ways.
Jean-Jacques Dubray
@jdubray
You are welcome, yes I truly believe there is merit to think along the lines of TLA+ semantics, though I still don't believe that it's practical to model a lot of code with TLA+. Hopefully can reach the best of both worlds, easy coding and enough structure that you can gain confidence that your code is correct.
It seems to me that the proof/simulation that TLA+ offers cannot scale to a large code base (at a minimum without some automatic translation between code and formal specification). It was my hope at some point that the TLA+ folks would explore that path, but I guess, it's not yet prioritized.
Timoteus Ruotsalainen
@TimoteusRuotsalainen

In this "Book reading app" there is always only one copy of each book. As the books are precious artifacts there is a librarian who does the actual physical page change. This "Librarian" exposes an API for changing the pages. Internally the librarian could be implemented in other languages than javascript.

I have been trying to figure out how to link together the user session model, group model and the Librarian API.

Would it be ok to call the librarians from the model as you mention CRUD operations should be in the model? The model would then either update the page number or mutate to an error state depending on the response. Then the nap could be used to sync this to other models by sending them actions.

For group sessions there would be a similar nap sync and some kind of join/leave actions that would determine which user models should be updated.

I know this is not really about SAM and more about how to organize the program in general. But I'm just trying to rough out where different things fit in the SAM pattern.

For some reason it feels a bit crowded to have multiple loops that are updating each other. Kind of like looking at this kind of watch mechanism. Each part has a specific purpose and reason for being there. But it looks scary when you aren't familiar with it yet. https://www.realmenrealstyle.com/wp-content/uploads/mechanical-watch.jpg

Jean-Jacques Dubray
@jdubray
@TimoteusRuotsalainen The theory says that the calls should be in a next-action, but as an approximation, it's (I think) ok to call them from the model as a synchronous call and yes, I would send the notifications to user instances via next actions. There is nothing that says you cannot find/use optimizations as long as they are equivalent from a temporal perspective. If it makes sense you could have just a single SAM instance that keeps track of registering users (action add user/leave group/...) as well as the book state. It really depends on what the remainder of the application looks like. It would not me appropriate to do that if the user state is very different from the book state.
Pete Barnett
@petebarnett

It seems to me that the proof/simulation that TLA+ offers cannot scale to a large code base (at a minimum without some automatic translation between code and formal specification). It was my hope at some point that the TLA+ folks would explore that path, but I guess, it's not yet prioritized.

@jdubray as an aside, that's something I heard discussed in this podcast episode https://signalsandthreads.com/compiler-optimization/ - the guest on here has an academic background in software verification, but makes the point that the burden of writing software + specification is still too much for most programmers, especially as the software changes

Pete Barnett
@petebarnett
The problem with writing software appears to be the same as wishing to a genie- you might get what you ask for, but not what you expect :D
Timoteus Ruotsalainen
@TimoteusRuotsalainen
@petebarnett do you use the SAM pattern?
Pete Barnett
@petebarnett
@TimoteusRuotsalainen yes
Timoteus Ruotsalainen
@TimoteusRuotsalainen
What kind of projects are you working with?
Jean-Jacques Dubray
@jdubray
Thank you for sharing @petebarnett, some people have definitely interesting jobs. At a minimum, SAM (and TLA+) allow you to detect safety conditions more effectively, even if/when verification is out of reach.
Pete Barnett
@petebarnett
@TimoteusRuotsalainen I was a product architect on something that could best be described as a "customer journey orchestration" platform... applied some of the thinking there as it was particularly suited. SAM seems to be a useful framework for reasoning about some systems also - in that it becomes easier to see where things are fragile
Re customer journey orchestration - that platform was often picked up by customers who expected it to be a BPM tool. It wasn't
Timoteus Ruotsalainen
@TimoteusRuotsalainen
interesting :)
Daniel Neveux
@dagatsoin

Hello everybody and happy new year !
@TimoteusRuotsalainen here are my 2cts for modeling the book app with SAM components.
The model :
I would modelise a room with:

  • a book state (id, current page...),
  • hasFinishedThePage[] an array for storing the state of each reader

The librarian could be a NAP (a service with its own rules reacting to a new model state). If the NAP condition is triggered (for exemple, all the reader of the room has finished the page), then it will trigger turnPageAction.

The state representation could be :

  • the raw text
  • page id
    and what ever data not bound to the various client (reader, browser, voice synthetizer, etc.)
Timoteus Ruotsalainen
@TimoteusRuotsalainen
nice video Leslie Lamport: Thinking Above the Code