Re: Nice article: "The Free Lunch is Over: A Fundamental Turn TowardConcurrencyin Software"

2005-01-09 06:22:10 AM
Eric Grange writes:
>Concurrent programming should be made easier by compiler technology.
>TThread is a big help, but maybe things could be easier still? Is
>multi-threaded programming easier in other languages?

The complexity of concurrency goes much further than compilation
technology, it takes roots in the very way we write code, which
is fundamentally sequential: code says do this, then do that, etc.
For the compiler to able to exploit concurrency efficiently,
you'll need a different description.

forgive me sometimes i think out loud. but let me see if i come come up with some examples where i
think a compiler could actually help. for instance, if there is a case where a calculation is
dealing solely with local vars; and const params...
function TSomeObject.GetResult(const AParam1, AParam2: Integer; var AParam3: Integer): Integer;
I: Integer;
// non threadable code...
AParam3 := 0;
// threadable code (dumb example i know)
Result := 0;
for Index := 1 to AParam1 do
Result := Result + AParam2;
now if the function is called...
FValue := MyObject.GetResult
...access to FValue would have to be synchronized automatically by the compiler.
of course you'd get better results by writing thread and synch code yourself, but 1) it wouldn't
look pretty and 2) you might make a mistake in writing all that extra code. (much like pros/cons of
writing ASM code)
could be a compiler option where the compiler wouldn't do any of this extra thread stuff, unless
{$THREADING ON} explicitly stated.