These are chat archives for jdubray/sam

27th
Mar 2017
Jean-Jacques Dubray
@jdubray
Mar 27 2017 19:45

Interesting way to isolate assignments from mutation (still primitive, but people are slowly waking up at the idea that assignment is not mutation): http://jrsinclair.com/articles/2017/javascript-but-less-iffy/

let foo = (function(returnForTrue, returnForFalse, condition) {
        if (condition) {
            return returnForTrue;
        }
        else {
            return returnForFalse;
        }
    })(baz, qux, (bar === 'some value'));

as opposed to:

let foo;
if (bar === 'some value') {
    foo = baz;
}
else {
    foo = bar;
}
If you are interested, this is a major departure from TLA+, in SAM. If you look at TLA+ examples you will notice that Dr. Lamport uses: "if then else" statements, mostly to deal with "state/next-action". The concept of State is not part of TLA+, well because mathematics is missing that concept. Mathematics don't have if-then-else either.
Jean-Jacques Dubray
@jdubray
Mar 27 2017 19:51
It's interesting that from Douglas Crockford to other people, conditionals are starting to be rethought for something more declarative. You'll notice that replacing switch with an array notation is not really different from the role of the state function establishing the current state of the model and routing a next-action from it.
My concern is that people, including Doug with whom I exchanged a few emails recently, are doing this as part of their gut feeling rather than with a strong conceptual foundation behind it.
I know I am biased, but I do thing that foundation is SAM/TLA+ and worth considering.
devin ivy
@devinivy
Mar 27 2017 20:01
where is crockford doing that?
i first saw it in cerebral
Jean-Jacques Dubray
@jdubray
Mar 27 2017 20:04
I saw recently a talk where he discusses everything he no longer uses in Javascript
devin ivy
@devinivy
Mar 27 2017 20:05
one of them is if ?
Jean-Jacques Dubray
@jdubray
Mar 27 2017 20:08
yes, I remember him talk about it.
devin ivy
@devinivy
Mar 27 2017 20:09
haha interesting!
Jean-Jacques Dubray
@jdubray
Mar 27 2017 20:09
I am pretty sure it was that one: https://www.youtube.com/watch?v=W1Lmxg_g_no&t=3376s
Zach Dahl
@schtauffen
Mar 27 2017 23:37
I didn't hear him mention not using if blocks, but it was a great watch. thanks!
(I'm currently in the QnA section, so its possible he mentions it still)