this post was submitted on 13 Dec 2025
283 points (98.0% liked)
Programmer Humor
42111 readers
1 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The compiler should be able to optimize all of them to the same machine code.
x==10, so as long as thenextInt()method doesn't have side effects, the loop should be eliminated. But, again, language semantics can affect this.~~Edit: Very wrong for 3 & 4, see replies.
I'd be shocked if 4 got optimised out
4 is used for non-deterministic delay - - - is Random.nextInt() also cryptographically secure?