comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Composing tasks and protected objects
Date: 08 Aug 2005 18:14:19 -0400
Date: 2005-08-08T18:14:19-04:00	[thread overview]
Message-ID: <wcc4qa0nkjo.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: R-2dnUR8r_FCWWrfRVn-3Q@megapath.net

"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Florian Weimer" <fw@deneb.enyo.de> wrote in message
> news:87oe88bvse.fsf@mid.deneb.enyo.de...
> ....
> > This introduces overhead in terms of an additional task, and the
> > Forwarder and Server are strongly coupled (unless you manually write
> > wrappers, because access-to-entry types are missing).
> 
> Yes, but an implementation of the proposed feature probably would have to
> introduce that task anyway.

Are we still talking about multi-way calls?  I certainly don't believe
that their implementation requires the implicit introduction of hidden
tasks, or anything near that cost!

>... It would end up costing about the same, yet it
> would look cheap. That's generally bad language design.

Well, I disagree about the cost, but I also disagree with that language
design principle -- the principle that says inefficient things should
*look* inefficient in the source code.  That principle is exactly the
*opposite* of what high level languages ought to be about.

In most cases, Ada does *not* follow that principle, and that's a Good
Thing.  In the few cases where Ada does follow it, it's a Bad Thing.

Consider:

    X := Y;

If the type is Integer, it takes approximately 1 machine instruction.
If the type is array-of-a-million-integers, it takes millions of
instructions.  If the type is controlled, it invokes Adjust, which could
do all kinds of user-defined task locking and heap management.

We don't use a different syntax for fast and slow assignments!
Surely that's good.  (Contrast with C, where the array case uses
"memcpy" instead of "=", and the Adjust case requires calling Adjust
explicitly.)

Another example: array indexing uses the same syntax whether the thing
is bit-packed or not.  Contrast with C, where the bit-packed case
requires explicit shifting and masking.  The extra cost of bit-packed
array indexing is more apparent from the source code in C, which is
certainly an advantage, but it's outweighed by the loss in abstraction.
For example, in Ada, you can easily experiment to determine whether bit
packing is an efficiency win.

An example where Ada *does* follow this misguided principle: unbounded
strings are a huge pain to use in Ada.  It would be much nicer if they
supported array-indexing syntax, slicing, literals, etc.  That would
hide the inefficiency of these strings.

I say, if you want to see efficiency properties clearly in the source
code, you must program in assembly.  In higher level languages, you lose
that capability.  You must determine efficiency by measurement, and by
experience (knowing which features are efficient in typical
implementations).

- Bob



  reply	other threads:[~2005-08-08 22:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-05 17:26 Composing tasks and protected objects Florian Weimer
2005-08-05 17:49 ` Robert A Duff
2005-08-05 18:09   ` Florian Weimer
2005-08-05 18:26     ` Robert A Duff
2005-08-05 19:20       ` Florian Weimer
2005-08-07  1:27       ` Randy Brukardt
2005-08-08 21:55         ` Robert A Duff
2005-08-06  5:52 ` Jeffrey Carter
2005-08-08  9:52   ` Florian Weimer
2005-08-08 20:50     ` Randy Brukardt
2005-08-08 22:14       ` Robert A Duff [this message]
2005-08-06  9:01 ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox