0

I have recently learned to program Arduino and Processing, which are quite similar to one another. I naturally arrived at the conclusion that the most natural structure to an interactive main loop (which is named loop() in Arduino and draw() in Processing) would be something like:

void loop() // or draw, or run, or mainloop
{
    readInput();   // includes the passage of time
    calculateStuff();
    updateStuff();
}

So, while reading about the concept, I discovered the "Read-Eval-Print" loop, which seems identical in structure, but not quite appropriate for non-text-based processing (although it is perfect for the gameloops of those CLI-based games).

Specifically the "print" part seems inappropriate in Processing to describe drawing actions, and in Arduino (or any other microcontroller by the way) to describe IO pins output, like blinking or moving stuff.

So the question is: Is there a technical, more general, not-CLI-based term to describe a loop composed by the sequence of reading all input, then calculating updates, then acting on the outputs?

I suspect that most if not all GUI toolkits, and probably other interactive programs, have a similar structure, so perhaps there is a term for it.

heltonbiker
  • 26,657
  • 28
  • 137
  • 252
  • But `loop` is not looping. I haven't heard a widely accepted term for it, "main loop" or "event loop" depending on the context. – Selçuk Cihan Sep 08 '16 at 13:09
  • @SelçukCihan well, if I understand right, `loop` is actually looping, since `readInput()` is not a blocking function: either it reads that some input is present, or it reads that no input is present. Of course, either in Processing and Arduino, there is the concept of "interrupt", or "events" (whitch are similar in this case), but anyway the `loop` loops, I think. – heltonbiker Sep 08 '16 at 13:24

0 Answers0