From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: speed of generic code in Ada (vs Java)
Date: Fri, 23 May 2008 18:55:25 -0400
Date: 2008-05-23T18:55:25-04:00 [thread overview]
Message-ID: <wcc1w3seile.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: g12deg$qdb$1@jacob-sparre.dk
"Randy Brukardt" <randy@rrsoftware.com> writes:
> "Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
> news:wccy7633br3.fsf@shell01.TheWorld.com...
>> Graham <graham.stark@virtual-worlds.biz> writes:
>>
>>> In any case, the 5x comparison sounds extreme and probably comes from
>>> comparing arrays of ints with something from the Java Collection
>>> classes, which is a bit like comparing Ada arrays with Ada Containers.
>>
>> I don't see why. Ada.Containers.Vectors, for example, does not
>> introduce an extra level of indirection for each component of the
>> vector. Ada is more like C++ in that regard.
>
> Sorry, but there is no language guarentee of this; ...
Sure. There's no language guarantee of anything related to efficiency.
So a programmer has to guess what typical implementations will do.
(Or measure.) The semantics of Java require unwanted levels of
indirection, unless the compiler goes to heroic/infeasible efforts to
eliminate them. The semantics of Ada do not.
>...it's more that an
> implementation of Ada.Containers.Vectors does not *have* to have a extra
> level of indirection. For Janus/Ada, for instance, there would be such an
> (implicit) indirection coming from the generic code sharing even if there
> isn't any explicit one.
Right, it's a trade-off -- code sharing introduces run-time inefficiency
for the benefit of compile-time speed. (And smaller code, which might
be more efficient in some cases.)
> And I'd still expect comparisons to be slower, because the "=" code probably
> is a loop doing element comparisons (it has to use the formal "=" operator
> and cannot assume that the actual is the predefined "="). It might be
> possible for a compiler to optimize that, but it would be pretty complex to
> do so.
I think that optimization is not too complex on a non-sharing
implementation. If "=" happens to be the predefined one,
it can be just a bit-wise compare in many cases.
>... (And even "=" for integers has to be done in a loop on some
> targets -- a bit comparison is not accurate for 1's complement machines, for
> instance.)
Well, those targets are pretty rare. More important is the fact that
floating point minus-zero and plus-zero must compare equal.
> The net effect is that generalizations about Ada performance are probably
> not well-founded. Usually, Ada performance is similar to that of C++, but
> implementation differences can be a big deal and more different than those
> between languages.
I disagree. Performance of Ada is pretty-close to C and C++ in most
cases. Performance of Ada is better than Java (and Smalltalk and ...)
in most cases. The implementation matters, but the language rules
matter more.
- Bob
next prev parent reply other threads:[~2008-05-23 22:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-16 17:31 speed of generic code in Ada (vs Java) jhc0033
2008-05-16 18:12 ` jimmaureenrogers
2008-05-16 18:54 ` Ludovic Brenta
2008-05-17 1:50 ` jhc0033
2008-05-17 2:04 ` Georg Bauhaus
2008-05-17 6:32 ` Niklas Holsti
2008-05-17 8:07 ` Ludovic Brenta
2008-05-17 21:37 ` Gautier
2008-05-17 23:31 ` Ivan Levashew
2008-05-22 22:01 ` Florian Weimer
2008-05-21 8:12 ` Graham
2008-05-21 15:41 ` Robert A Duff
2008-05-22 0:06 ` Randy Brukardt
2008-05-23 22:55 ` Robert A Duff [this message]
2008-05-24 0:16 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox