logoalt Hacker News

xen0last Thursday at 6:34 PM1 replyview on HN

It's sometimes nice to be deterministic.

I don't often care about a specific order, only that I get the same order every time.


Replies

no_wizardlast Thursday at 6:56 PM

Thinking about this upfront for me, I am actually wondering why this is useful outside of equality comparisons.

Granted, I live and work in TypeScript, where I can't `===` two objects but I could see this deterministic behavior making it easier for a language to compare two objects, especially if equality comparison is dependent on a generated hash.

The other is guaranteed iteration order, if you are reliant on the index-contents relationship of an iterable, but we're talking about Dicts which are keyed, but extending this idea to List, I see this usefulness in some scenarios.

Beyond that, I'm not sure it matters, but I also realize I could simply not have enough imagination at the moment to think of other benefits

show 2 replies