cm0002 ( cm0002@lemmy.zip ) to Programmer Humor@programming.dev · 1 year agoMore code = more betterlemmy.zipimagemessage-square23linkfedilinkarrow-up1385
arrow-up1385imageMore code = more betterlemmy.zipcm0002 ( cm0002@lemmy.zip ) to Programmer Humor@programming.dev · 1 year agomessage-square23linkfedilink
minus-squareHirom ( Hirom@beehaw.org ) linkfedilinkarrow-up29·1 year agoThe compiler will optimize it anyway. /s
minus-squareDumhuvud ( Dumhuvud@programming.dev ) linkfedilinkEnglisharrow-up18·1 year agoYou jest, but you aren’t wrong. At least if we are talking about C, C++ or Rust. https://godbolt.org/z/oPPfdfcf5 .NET compiler is weak when it comes to optimizing your code; I assume Go’s is as bad.
minus-squareyetAnotherUser ( yetAnotherUser@discuss.tchncs.de ) linkfedilinkarrow-up5·1 year agoNot sure about the last one though. The other two are trivial to optimize away.
minus-squareHirom ( Hirom@beehaw.org ) linkfedilinkarrow-up3·1 year agoAn infinite loop canot be ruled out in the last case, so a compiler couldn’t optimize this away without potentially changing the program behavior.
minus-squareyetAnotherUser ( yetAnotherUser@discuss.tchncs.de ) linkfedilinkarrow-up1·1 year agoInfinite loops are often weird though. They could be seen as undefined behavior and the compiler may do whatever it feels like.
The compiler will optimize it anyway. /s
You jest, but you aren’t wrong. At least if we are talking about C, C++ or Rust. https://godbolt.org/z/oPPfdfcf5
.NET compiler is weak when it comes to optimizing your code; I assume Go’s is as bad.
Not sure about the last one though. The other two are trivial to optimize away.
An infinite loop canot be ruled out in the last case, so a compiler couldn’t optimize this away without potentially changing the program behavior.
Infinite loops are often weird though. They could be seen as undefined behavior and the compiler may do whatever it feels like.