Remix.run Logo
arn3n 6 hours ago

While not production ready, I’ve been happily surprised at this functionality when building with it. I love my interpreters to be deterministic, or when random to be explicitly seeded. It makes debugging much easier when I can rerun the same program multiple times and expect identical results.

frizlab 6 hours ago | parent [-]

Interestingly I think things that should not be deterministic should actually forced not to be.

Swift for instance will explicitly make iterating on a dictionary not deterministic (by randomizing the iteration), in order to catch weird bugs early if a client relies (knowingly or not) on the specific order the elements of the dictionary are ordered.

lilyball 6 hours ago | parent | next [-]

This claim sounds vaguely familiar to me (though the documentation on Dictionary does not state any reason for why the iteration order is unpredictable), though the more common reason for languages to have unstable hash table iteration orders is as a consequence of protection against hash flooding, malicious input causing all keys to hash to the same bucket (because iteration order is dependent on bucket order).

frizlab 2 hours ago | parent [-]

Oh yeah you’re right, apparently the main reason was to avoid hash-flooding attacks[1].

I do seem to remember there was a claim regarding the fact that it also prevented a certain class of errors (that I mentioned earlier), but I cannot find the source again, so it might just be my memory playing tricks on me.

[1] https://forums.swift.org/t/psa-the-stdlib-now-uses-randomly-...

saidinesh5 5 hours ago | parent | prev [-]

One more reason for randomizing hash table iteration was to prevent Denial of service attacks:

https://lukasmartinelli.ch/web/2014/11/17/php-dos-attack-rev...