News for hackers. Stuff that matters.
Re:How a 20 year old bug in GTA San Andreas surfaced in Wind... by nayuki on Wednesday April 23, 2025 @03:42PM (#43775920)
Any sane language would design a list iterator to follow the order of the list. No, the difference is when you're iterating over orderless hash-based sets or maps/dictionaries. Many languages choose to leave the iteration order undefined. I think Python did that up to a point, but afterward they defined dictionaries (but not sets) to be iterated over in the order that keys were added. Also, some languages intentionally randomize the order per program run, to avoid things like users intentionally stuffing hash tables with colliding keys.
Re:How a 20 year old bug in GTA San Andreas surfaced in Wind... by mabster on Wednesday April 23, 2025 @06:21PM (#43777295)
Best change ever, that. Now it would also be nice if sets were ordered too.
Re:How a 20 year old bug in GTA San Andreas surfaced in Wind... by throwaway2037 on Wednesday April 23, 2025 @11:22PM (#43778982)
I am pretty sure there are trivial impls of sets with guaranteed iteration order in Python that use an underlying ordered map and a dummy value in each entry.
Re:How a 20 year old bug in GTA San Andreas surfaced in Wind... by masklinn on Thursday April 24, 2025 @03:55AM (#43780231)
> Also, some languages intentionally randomize the order per program run, to avoid things like users intentionally stuffing hash tables with colliding keys.

Most modern langages do that as part of hashdos mitigation, Python did that until it switched to a naturally ordered hashmap, then made insertion order part of the spec. Importantly iteration order remains consistent with a process (possibly on a per-hashmap basis).

Notably, Go will randomise the starting point of hashmap iteration on each iteration.