logoalt Hacker News

BobbyTables2today at 3:15 PM5 repliesview on HN

TLDR: For almost 1/6 of a century, the C++ standards broke the simplest infinite loop and only just recently fixed it.

Idiots!

Don’t they really that people write real programs to solve real problems? This isn’t a theoretical academic exercise!


Replies

Sharlintoday at 3:25 PM

The argument is that an infinite loop without side effects isn't a real program. It's not useful for anything except wasting cycles.

show 3 replies
Panzerschrektoday at 6:38 PM

> the simplest infinite loop

An infinite loop which does nothing is practically useless. So, compilers optimize it out. That's the whole philosophy of modern compilers - to reduce execution time by preserving semantics. In case of an infinite loop elimination it's an optimization making code infinite times faster.

bryanlarsentoday at 3:20 PM

They also realized that people choose compilers based on performance benchmarks, and that insane optimizations let them win.

show 1 reply
bluGilltoday at 3:33 PM

You are an idiot if you write an infinite loop. An infinite loop is a waste of CPU cycles and energy when run.

If it wasn't so hard to detect (the trivial cases are easy, but it gets hard quickly) I'd say the program should fail to compile.

show 3 replies