comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: FAQ and string functions
Date: Mon, 26 Aug 2002 17:53:36 GMT
Date: 2002-08-26T17:53:36+00:00	[thread overview]
Message-ID: <wccd6s5y09r.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: uofc518w0.fsf@gsfc.nasa.gov

Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:
> Robert A Duff <bobduff@shell01.TheWorld.com> writes:
> 
> > "Randy Brukardt" <randy@rrsoftware.com> writes:
> > 
> > > I think your missing the Ada philosophy that something expensive should
> > > look expensive. An unbounded array (as you put it) is going to be
> > > expensive, and that expensive shouldn't be covered up in glossy syntax.
> > 
> > IMHO, that philosophy is exactly the opposite of what high-level
> > languages are all about.  The parts of Ada that disobey this philosophy
> > are the better parts.
> > 
> > Here's an example: In Ada, one can write "A := B;".  If they are
> > integers, it's fast.  If they are gigantic arrays, it could be a million
> > times slower, or more.  That's good -- assignment uses a single notation
> > no matter how fast or slow.  Contrast with C, where copying arrays uses
> > a different syntax from copying ints.
> 
> That's not a fair example. For assignment, the cost is clearly
> proportional to the size of the data, which is easily visible in the
> source.

Not necessarily:

    procedure P(X: String) is
        Y: String_Ptr := new String'(1..X'Length);
    begin
        Y.all := X; -- How fast is this?

The amount of data copied is probably a run-time calculated value (not
"easily visible in the source"), and is different for each call to P.
In fact, one call to P might take a million times longer than another.

But anyway, what do you think is a fair example?  My claim is that the
philosophy Randy mentioned above is *not* a good language-design
philosophy, and that Ada doesn't follow it very much.  The cases where
Ada follows that philosophy tend to be ugly, and the cases where that
philosophy is disobeyed tend to be nice and clean.

In fact, the only languages that truly obey the philosophy are assembly
languages.  To get the benefits of a high level language, I claim that
you must give up the obvious correspondence between source code and
efficiency that comes with low level languages.

> Hidden memory allocation is not clearly visible (because it's hidden
> :), but is expensive.

I think the issue of memory allocation is not efficiency, but
predictability of efficiency -- heap allocation/deallocation tends to be
less predictable than stack allocation/deallocation.  So it does make
sense to avoid hidden memory allocation in a language for real-time
systems.

> A more valid example of hidden expense for assignment is a Controlled
> type; Finalize and Adjust could be expensive. But even there, the
> definition of the type clearly says "Controlled", so you are warned
> that it might be expensive.

I suppose, although you have to look into private parts to find that
information, and at all the component types.  And you have to know how
your compiler does it -- compilers differ wildly in the cost of
finalization.  That's unfortunate, but I don't see how to avoid that
problem in a high-level language.

- Bob



  reply	other threads:[~2002-08-26 17:53 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-30  6:32 FAQ and string functions Oleg Goodyckov
2002-07-30  8:52 ` Colin Paul Gloster
2002-07-30 13:48 ` Ted Dennison
2002-07-31  4:52   ` Brian May
2002-08-01 16:09     ` Ted Dennison
2002-08-02  0:21       ` Brian May
2002-08-02  1:56         ` tmoran
2002-08-02 13:59         ` Ted Dennison
2002-07-31  7:46   ` Oleg Goodyckov
2002-07-31  9:04     ` Lutz Donnerhacke
2002-07-31  9:39       ` Pascal Obry
2002-07-31 15:06         ` Oleg Goodyckov
2002-07-31 16:50       ` Oleg Goodyckov
2002-07-31 20:16     ` Simon Wright
2002-07-31 20:56       ` Robert A Duff
2002-08-01  0:11         ` Darren New
2002-08-01  1:08           ` tmoran
2002-08-01  9:25           ` Brian May
2002-08-01 11:20           ` Oleg Goodyckov
2002-08-01 15:43             ` Darren New
2002-08-01 21:37               ` Robert A Duff
2002-08-03  0:42                 ` Ted Dennison
2002-08-03 13:51                   ` Robert A Duff
2002-08-03 16:43                   ` Darren New
2002-08-05 13:37                   ` Stephen Leake
2002-08-02  8:01               ` Oleg Goodyckov
2002-08-02 16:09                 ` Darren New
2002-08-01 11:09         ` Oleg Goodyckov
2002-08-01 14:08           ` Frank J. Lhota
2002-08-01 15:06             ` Robert A Duff
2002-08-01 16:05             ` Oleg Goodyckov
2002-08-01 14:57         ` Georg Bauhaus
2002-07-31 22:04     ` Dmitry A.Kazakov
2002-07-31 15:23       ` Oleg Goodyckov
2002-08-01 21:57         ` Dmitry A.Kazakov
2002-08-01 13:10           ` Oleg Goodyckov
2002-08-02 23:29             ` Dmitry A.Kazakov
2002-08-02 16:35               ` Oleg Goodyckov
2002-08-05 11:50                 ` Dmitry A. Kazakov
2002-08-05 14:29                   ` Larry Kilgallen
2002-08-05 14:57                     ` Dmitry A. Kazakov
2002-08-05 15:12                   ` Oleg Goodyckov
2002-08-05 16:20                   ` Darren New
2002-08-05 17:01                     ` Georg Bauhaus
2002-08-05 17:48                       ` Darren New
2002-08-05 19:06                         ` tmoran
2002-08-05 20:08                           ` Darren New
     [not found]                     ` <slrnakv3q9.p2.lutz@taranis.iks-jena.de>
     [not found]                       ` <3D4FEFCB.3B74F5E5@san.rr.com>
2002-08-14  0:07                         ` Randy Brukardt
2002-08-01 14:29     ` Ted Dennison
2002-08-01 16:47       ` Oleg Goodyckov
2002-08-02 14:05         ` Ted Dennison
2002-08-02 16:11           ` Darren New
2002-08-03  0:30             ` Ted Dennison
2002-08-03  0:58               ` Darren New
2002-08-03  2:04                 ` Dale Stanbrough
2002-08-03  2:32                 ` Ted Dennison
2002-08-03  2:47                   ` Darren New
2002-08-03 12:41                     ` Ted Dennison
2002-08-03 16:53                       ` Darren New
2002-08-04  1:08                         ` Ted Dennison
2002-08-04 16:23                           ` Darren New
2002-08-05  2:16                             ` Robert Dewar
2002-08-05  3:45                               ` Darren New
2002-08-05  9:56                     ` Lutz Donnerhacke
2002-08-05 16:02                       ` Darren New
2002-08-14  0:42                         ` Randy Brukardt
2002-08-14  1:45                           ` Darren New
2002-08-14 19:37                             ` Randy Brukardt
2002-08-14 20:25                               ` Stephen Leake
2002-08-14 20:22                           ` Stephen Leake
2002-08-15 19:24                             ` Randy Brukardt
     [not found]                         ` <jb1vkustkugeutalhvrhv1n0k9hqn2fpip@4ax.com>
     [not found]                           ` <3D4FF351.8F4A6C0A@san.rr.com>
2002-08-14  1:03                             ` Randy Brukardt
2002-08-14  1:05                       ` Robert A Duff
     [not found]                       ` <3D4EA1AC.80D17170@s <wccofc6b66u.fsf@shell01.TheWorld.com>
2002-08-14 20:29                         ` Stephen Leake
2002-08-26 17:53                           ` Robert A Duff [this message]
2002-08-26 18:40                             ` Chad R. Meiners
2002-08-26 18:52                               ` Robert A Duff
2002-08-26 21:46                                 ` Chad R. Meiners
2002-08-05 13:29                     ` Stephen Leake
2002-08-03  5:07                   ` achrist
2002-08-03 12:52                     ` Ted Dennison
2002-08-05 15:34                       ` Ted Dennison
2002-08-05 13:24                 ` Stephen Leake
2002-08-05 16:02                   ` Darren New
2002-08-05  7:18           ` Oleg Goodyckov
2002-08-02  1:04     ` tmoran
replies disabled

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