Re: No call for Ada (was Re: Announcing new scripting/prototyping language)
From: Dmitry A. Kazakov (mailbox_at_dmitry-kazakov.de)
Date: 02/11/04
- Next message: hiwa: "Re: String replace()"
- Previous message: Tom N: "Re: Execute Java in a new window"
- In reply to: MSG: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Next in thread: Marin David Condic: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Reply: Marin David Condic: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Reply: Xenos: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 11 Feb 2004 10:22:37 +0100
On 10 Feb 2004 18:19:13 -0800, msg1825@yahoo.com (MSG) wrote:
>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<vjah20tahj48fftkpeghp29ugnojfdd4r4@4ax.com>...
>> On 9 Feb 2004 18:26:33 -0800, msg1825@yahoo.com (MSG) wrote:
>> >
>> >3. performance is highly important
>>
>> GNAT is a front end of GNU C...
>
>Can you write (*) a matrix multiplication routine in Ada, compile it
>with GNAT and measure the number CPU cycles per FLOP, compare to a
>similar routine in C?
There is a problem with that. C does not have arrays. Yet matrices,
you know, are two-dimensional ones. So any comparison here would be
suspicious. A program in C, supposed to multiply matrices would lack
ADT abstraction layer. It is well possible to write something similar
in Ada, using pointers instead of arrays etc. (After all true
programmer can write a FORTRAN program in Pascal, if I correctly quote
the famous sentence) Such a program with all checks surpressed will
take the same number of CPU cycles. But who might be interested in
such comparison?
Note that presence of an abstraction per se does not mean performance
penalty. The effect could be quite opposite. The difference between C
and Ada is that in C you almost cannot express intention. It is too
low-level language. You just order the compiler to do something and it
obeys. This may result in slower code, because the compiler should
deduce that:
char * t;
char * s;
while (*t++ = *s++);
is in fact to copy a string. If it would, it could then apply a
corresponding target CISC machine instruction. In Ada it is easier for
the compiler:
T : String (...);
S : String (...);
T := S;
Even if you work at the array abstraction level:
for I in S'Range loop
T (I) := S (I);
end loop;
there is a lot of useful information for the compiler here, much more
than in pointer increments and dereferencings. Note also, that by
using pointers you commit yourself to only the objects which can be
referenced by a pointer. This might be a heavy burden on some
machines. Compare this with Ada, where you have to *explicitly*
specify that an object is aliased (a subject of referencing). If you
don't, the compiler is free to move such objects to registers, cache,
an external matrix processing unit etc.
Even if GNAT might not use all that, it is at best a GNAT problem, not
one of Ada.
-- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de
- Next message: hiwa: "Re: String replace()"
- Previous message: Tom N: "Re: Execute Java in a new window"
- In reply to: MSG: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Next in thread: Marin David Condic: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Reply: Marin David Condic: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Reply: Xenos: "Re: No call for Ada (was Re: Announcing new scripting/prototyping language)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]