Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by pigbearpig on Saturday January 01, 2022 @12:28PM
(#29760537)
These should have been strings, end of story. You can sort a string. Amazing to see storing a non-number as as number being defended. Truly CS101.
[ Parent
| on HN ]
Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by DSMan195276 on Saturday January 01, 2022 @01:39PM
(#29761226)
You can certainly sort a string, but I think there are valid reasons to avoid it if possible. What they shouldn't be doing is trying to shove it into a single 32-bit integer - if they parsed it into separate integers for each of the individual parts (like a simple date representation would do) then the issue would go away. Whether it's worth that extra work to avoid the string comparison is debatable, but if they go on to mask out parts of the version number and look at them individually (Ex. Only the year, or only the revision number) than it would probably be worth it to just do all the parsing upfront and avoid any messing with strings after that.
Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by srj on Saturday January 01, 2022 @01:54PM
(#29761373)
I guess it depends on the language but using a string for this doesn't seem like a great choice except for user display / logging. Given this is a version number you'd want to support comparison operators, and a struct with those operators defined (and a string format method) would make more sense imo.
Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by mr_toad on Saturday January 01, 2022 @09:46PM
(#29765255)
Depends on the language and function. Some sorting algorithms happily rank ‘9’ > ‘10’.
Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by petee on Saturday January 01, 2022 @12:47PM
(#29760728)
I'm curious which languages you learned in CS101 (actual question, not snark)
Every non-number, as you put it, is just a number to a computer. Comparing binary is faster than sorting strings, and it makes zero sense to waste memory simply so a human could potentially read it.
Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by jraph on Saturday January 01, 2022 @01:22PM
(#29761050)
But versions are for human beings.
Otherwise, a timestamp, a date, a commit hash or an increment would do.
Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by petee on Saturday January 01, 2022 @01:33PM
(#29761161)
That's not true, they can be for either humans, computers, or both. Software still has to understand and do something with that version number, even if it came from a human. And if it has to store, sort, or process that number a lot, it will still be faster to store and compare binary than a string.
For comparison, I think some here would be shocked to learn their IPv4 address is stored as an unsigned 32-bit integer. Its not a number, and definitely not faster to use as a string.