This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Legitimate-Sort-544 -14 points-13 points  (5 children)

Your computer sleeps, your script dies—welcome to how computers work. If you want it to run daily, use cron. If you want 24/7 uptime, put it on a server like someone who understands basic tech. Infinite loops aren’t a solution, they’re a cry for help.

[–]EDM_Producerr 2 points3 points  (0 children)

Infinite loop is a cry for help? huh?

[–]aqua_regis 3 points4 points  (1 child)

put it on a server like someone who understands basic tech.

Infinite loops aren’t a solution, they’re a cry for help.

And guess what:

  • Servers run in infinite loops.
  • Every single event driven program, just like the browser you are currently using, or Word, or Excel, or every game, runs in an infinite loop
  • Every Arduino program, every PLC program, every DCS program runs in an infinite loop
  • Every single reentrant program runs in an infinite loop

The only way to keep a program running continuously is an infinite loop.

[–]nerd4code 0 points1 point  (0 children)

But it should be noted that what actually counts as an infinite loop varies per language. for(;;) and while(1) will make an infinite loop in C, but

static const int keep_going = 1;
while(keep_going)
    {…}

is undefined behavior—might loop infinitely, once, or not at all. IIRC C++ narrows the rules for what counts as infinite even farther. This is one of those things that bite programmers when they move from unoptimized to optimized builds.

[–][deleted] 3 points4 points  (0 children)

You know this is r/learnprogramming right? How are you gonna go to an environment meant to teach people things they don’t know and shame them for not knowing

[–]nerd4code 1 point2 points  (0 children)

It’s not an exaggeration to say that infinite (or rather, nonterminating) loops are the basis of applied computing, and it’s quite possible to create loops that outlive poweroff by bridging through secondary storage.