> As far as I know, most languages do the expected output, such as c++,
> Java, Python, and even Luau now.
> Is there a specific reason for choosing this behavior?
There is nothing stopping a C or C++ compiler from reordering assignments and many other operations, this is very explicitly allowed in the standards, and helps produce faster code by avoiding pipeline stalls.