An idea on multithreading implementation

Geoff Canyon Rev gcanyon+rev at gmail.com
Fri Jan 28 09:59:17 EST 2011


On Fri, Jan 28, 2011 at 1:16 AM, Jeffrey Massung <massung at gmail.com> wrote:

>
> Coroutines have absolutely no advantage over what's already provided by LC.
> There's zero difference between saying "yield()" and "wait 0 ticks with
> messages".
>

I realized that, apart from the fact that this isn't true, it's also kind of
my point: from a developer standpoint, coroutines work fairly similarly to
what many already do when they want to have two or three things going at
once. Hence they would be a significant improvement (because they maintain
state automatically) with very little effort required on the part of
livecode developers.

>
> The purpose of mutli-threading is to take advantage of one or more of the
> following: a completely separate hardware thread (program/code runs 100% in
> parallel with another program/set of code - the only bottlenecks being
> memory and I/O) or preemptive threading, typically by way of hyper-threading
> on a single hardware thread (basically letting the hardware or OS decide
> when to context switch for you).
>

This is true, but it's not a fair description of the current limitations of
livecode. Currently it is very difficult simply to program any sort of
background task whatsoever: processing a log file, making aliens attack,
etc. "wait 0 ticks" simply isn't a good answer for those sorts of issues.
Ask Malte what he could do for animationEngine (and how much more simply)
with coroutines.

Yes, threads are filled with awesome powah, but they're also a lot of work
to get right, and filled with pitfalls. Coroutines, by comparison, are easy,
and would make a lot of things easy to do that are currently hard or
impossible.

One other thing, just in case -- anyone who thinks threads will make
livecode a powerhouse for developing videogames is mistaken. That would
require an overhaul of the graphics engine. You can devote 100% of
livecode's attention to moving stuff around on the screen and come up short
on performance by a couple orders of magnitude. I don't say that to
criticize livecode, it's just that graphics performance isn't their focus,
never has been, and doesn't seem as though it will be any time soon.

Flight Control is well within livecode's capabilities now. Angry Birds might
be a stretch. Fruit Ninja would be a real achievement, and forget about Real
Racing.

I'd be happy to be proven wrong.

Ooo -- I just had an idea for a flight-control-like game. Guess I need to
get that iOS license after all...

gc



More information about the use-livecode mailing list