I evidently need to learn asynchronous coding. I've been held back by a very strong preference for orderly linear languages, but this asynchronous style seems to have some big advantages.AndrewAPrice wrote:You could write your code very asynchronosly. e.g. JavaScript style where everything is async/await. You would still get crashes in true infinite loops, but at least your code blocks would be fairly granular.
Oh that takes me back! When my only tool was QBasic, I thought of implementing multitasking in that way too. These days, I'd describe it as overloading termination to function as yielding to the OS. Not necessary if you have control of the language, but it could keep code granular.AndrewAPrice wrote:I also recall an "OS" named GIMI written in QBasic that would achieve multitasking by round-robin interpreting each script.
I've long been planning to use a single compiler for everything, not least because it has some interesting possibilities including inserting passes (or yielding, as I tend to call it). Deciding when to yield still seems to me to be a complex issue, but evidently solvable -- Oberon was very responsive when I tried it.Schol-R-LEA wrote:Niklaus Wirth got a bee in his bonnet about interrupts and determinism in the mid-1980s, so the Oberon OS and language was designed entirely around cooperative multitasking. The language and the OS are tightly interwoven, with the compiler designed to automatically insert passes into the program at regular intervals - specifically, any loop would end by passing to the scheduler, or at least do so after a certain number of iterations. Needless to say, this method is highly dependent on that specific compiler being used for everything.