Other than nerdsniping, what is the point of this expression?
If you wanted to show how different languages treat modulo, type conversions, division, etc., you could just show individual examples. That would be significantly clearer.
Was there some practical reason behind creating this expression, or is it just obfuscation?
Well, one of the points is that even if things work properly/as expected 99.8% of the time, when you add layer after layer of "works ok most of the time", you end up with a very unreliable system. And given that all computing revolves around manipulating numbers, the fact that there's so much wiggle room (even if there are often good reasons for most of the differences we are seeing here, which are fundamentally semantical differences anyway), should at least make you slightly uncomfortable when thinking about building complex systems. And that's without entering the realm of what happens with overflows, underflows, NaNs and everything else. The bases are solid, but we can still see quite a lot of holes.
Thank you for explaining your understand of the issue presented here with a wide view.
I was shocked when I got the results shown here and thought of times in the past were I copied and pasted formulas (and sometimes did some small changes to be accepted by the language I was using) without thinking that any language would interpret it differently without warning.
I believe that most of us are acting in good faith most of the time and we need some common examples/tests like basic math expressions that we could use to check/evaluate any/most implementations in programming languages to try prevent or minimize divergences like the ones shown here by a random generated expression that has no other meaning than a uncommon valid? test case to show an issue.
My point was that the expression could be one sixth the length and contain no more than two parentheses, from what I gather. Hence the question what the purpose of constructing this expression was - it just looks like somebody facerolled their numpad and then made random edits until the syntax was ok.
Yeah, sorry about that. I'm generally against obfuscation, but in this case, the "why" of the resulting differences in calculations is well known to most programmers; the big issue is not "why we get different results", but rather "are we ok this type of inconsistent behavior".
If you simply showed that modulo and implicit casting work differently in different languages, we wouldn't have had any discussion. With the obfuscation, we got some discussion about the main point... and the discussion about the obfuscation. Honestly, none of us managed to capture all the perspectives well enough. Yeah, the "Ask HN" could have used a less obfuscated expression and been better worded to clarify that the specific semantic differences weren't the main point here. Similarly, most commenters (myself included in my previous comment) failed to realize/clarify that there were two discussions going on here, but that one of them is settled with a technical footnote.
That’s my question too. I really hope this is contrived! Otherwise I’m going to go to sleep having nightmares about expressions like this in code running important things out there!
Imagine if all the bolts on bridges were just kind of thrown on randomly hoping they hold. That’s the equivalent to this expression.
If you wanted to show how different languages treat modulo, type conversions, division, etc., you could just show individual examples. That would be significantly clearer.
Was there some practical reason behind creating this expression, or is it just obfuscation?