4 ms·
Idempotency means f(x) = f(f(x)).* Here x is interpreted as state and f an action acting on the state. State is in practice always subjected to side effects a
by raffael_de 5mo ago
Idempotency means f(x) = f(f(x)).*
Here x is interpreted as state and f an action acting on the state.
State is in practice always subjected to side effects and concurrency. That's why if x is state then f can never be purely idempotent and the term has to be interpreted in a hand-wavy fashion which leads to confusions regarding attempts to handle that mismatch which again leads to rather meandering and confusing and way too long blog posts as the one we are seeing here.
*: I wonder how you can write such a lengthy text and not once even mention this. If you want to understand idempotency in a meaningful way then you have to reduce the scenario to a mathematical function. If you don't then you are left with a fuzzy concept and there isn't much point about philosophizing over just accepting how something is practically implemented; like this idempotency-key.
- deleted 5mo ago[deleted]
- Hendrikto 5mo ago> That's why if x is state then f can never be purely idempotent That is simply not true. f could be, for example, “set x.variable to 7”, which is definitely idempotent.
- conradludgate 5mo agoThere's no side effects in f here, so the statement does not apply
- Hendrikto 5mo agoParent said > State is in practice always subjected to side effects and concurrency. There was never any claim or assumption regarding f. Maybe the way you interpreted it is what they meant, but it is not what was stated.
- raffael_de 5mo agoyou are oversimplifying with your set variable example. the context is complex state management as with online purchases.
- toolslive 5mo ago> * I wondered about this too. Also, why was it framed in the context of JSON based RPC over HTTP ?
- harshitaneja 5mo agoIdempotence is a semantically overloaded term in computer science where in functional programming it refers to the same concept as mathematical idempotence it refers to any function leading to the same state in multiple calls as the first. And yes, in real machines we can't ever have true same states between multiple calls as system time, heat and other effects will differ but we define the state over the abstracted system model of whatever we are modelling and we define idempotency as the same state over multiple calls in that system.
- raffael_de 5mo agonot just heat and system time. the context is about state handled by databases. database content can never be assumed to be identical between to identical operations involving it. "delete record with id 123" is only idempotent if there is no chance that an operation like "create record with id 123" happened in between.
- asdfaoeu 5mo ago> State is in practice always subjected to side effects and concurrency. In that mathematical notation typically there is no side effects and those are meant to be pure functions.