←back to thread

1371 points yett | 7 comments | | HN request time: 1.06s | source | bottom
Show context
amenghra ◴[] No.43774928[source]
IMHO, if something isn’t part of the contract, it should be randomized. Eg if iteration order of maps isn’t guaranteed in your language, then your language should go out of its way to randomize it. Otherwise, you end up with brittle code: code that works fine until it doesn’t.
replies(11): >>43774993 #>>43775199 #>>43775210 #>>43775344 #>>43775361 #>>43775510 #>>43775759 #>>43776084 #>>43776311 #>>43776598 #>>43778608 #
1. tantalor ◴[] No.43776598[source]
Nope. You have to remember https://www.hyrumslaw.com/

  With a sufficient number of users of an API,
  it does not matter what you promise in the contract:
  all observable behaviors of your system
  will be depended on by somebody.
If you promise randomization, then somebody will depend on that :)

And then you can never remove it!

replies(2): >>43778253 #>>43780617 #
2. timewizard ◴[] No.43778253[source]
> If you promise randomization

You don't. You say the order is undefined.

replies(2): >>43778894 #>>43778928 #
3. dwattttt ◴[] No.43778894[source]
You can randomly not randomise it :)
4. __float ◴[] No.43778928[source]
That isn't the point. In practice, if you provide randomness, it will be depended upon.
replies(1): >>43779002 #
5. psnehanshu ◴[] No.43779002{3}[source]
Why is that? Is that just bad coding habits?
replies(1): >>43779871 #
6. simonask ◴[] No.43779871{4}[source]
All of this is bad coding habits. That's why we're here.
7. scott_w ◴[] No.43780617[source]
Semi-related: this type of thing is actually covered in the Site Reliability Engineering book by Google. They highlighted a case of a system that outperformed its SLO, so people depended on it having 100% uptime. They "fixed" this by injecting errors to go closer to their SLA, forcing downstream engineers to deal with the fact that the dependent services would sometimes fail for no reason.

I know it's easier said than done everywhere, just found it to be an interesting parallel.