comp.lang.ada
 help / color / mirror / Atom feed
* Ada to C++ Translators
@ 1998-02-13  0:00 David Kusuda
  1998-02-14  0:00 ` Larry Kilgallen
  0 siblings, 1 reply; 26+ messages in thread
From: David Kusuda @ 1998-02-13  0:00 UTC (permalink / raw)



I'm pretty sure that this has been discussed before, but can anyone
direct me towards an Ada to C++ translator?  Any information would be
greatly appreciated.




Dave




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-13  0:00 Ada to C++ Translators David Kusuda
@ 1998-02-14  0:00 ` Larry Kilgallen
  1998-02-16  0:00   ` David  Weller
  0 siblings, 1 reply; 26+ messages in thread
From: Larry Kilgallen @ 1998-02-14  0:00 UTC (permalink / raw)



In article <34E47622.15EB@atc-1s.hac.com>, David Kusuda <dkusu@atc-1s.hac.com> writes:
> I'm pretty sure that this has been discussed before, but can anyone
> direct me towards an Ada to C++ translator?  Any information would be
> greatly appreciated.

The World Wide Web site DejaNews.com can direct you to many things
which have been discussed before in this newsgroup.  For the topic
you raise there are _many_ previous discussions going on at length
typically petering out with people arguing about what constitutes
usable translation.

Larry Kilgallen




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-14  0:00 ` Larry Kilgallen
@ 1998-02-16  0:00   ` David  Weller
  1998-02-18  0:00     ` Jean D. Ichbiah
  0 siblings, 1 reply; 26+ messages in thread
From: David  Weller @ 1998-02-16  0:00 UTC (permalink / raw)



In article <1998Feb13.213046.1@eisner>,
Larry Kilgallen <Kilgallen@eisner.decus.org.nospam> wrote:
>In article <34E47622.15EB@atc-1s.hac.com>, David Kusuda <dkusu@atc-1s.hac.com> writes:
>> I'm pretty sure that this has been discussed before, but can anyone
>> direct me towards an Ada to C++ translator?  Any information would be
>> greatly appreciated.
>
>The World Wide Web site DejaNews.com can direct you to many things
>which have been discussed before in this newsgroup.  For the topic
>you raise there are _many_ previous discussions going on at length
>typically petering out with people arguing about what constitutes
>usable translation.
>

Or something about an infinite number of monkeys working for a finite
amount of time and pounding out some pretty good C code :-)

Let's save Mr. Kusuda a bag of time:

	1) It can be done
	2) Over a lot of time
	3) With a lot of money
	4) Starting from scratch is MUCH cheaper
	5) It's a pretty dumb thing to do anyway
	    (It takes less code to do a project in Ada95 than in C++)


-- 
   ******   NEW!!  DoD Ada Hotline Number:  1-800-PARIAH    ******
Tired of "junk" e-mail?  Write to your congressman and tell them you support
H.R. 1748, "The Netizens Protection Act of 1997".  Make those SPAM-roaches run!             http://www.cauce.org          TAKE BACK THE INTERNET!




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-16  0:00   ` David  Weller
@ 1998-02-18  0:00     ` Jean D. Ichbiah
  1998-02-18  0:00       ` David  Weller
  1998-02-19  0:00       ` Delphi & Ada; Ada to C++ Nick Roberts
  0 siblings, 2 replies; 26+ messages in thread
From: Jean D. Ichbiah @ 1998-02-18  0:00 UTC (permalink / raw)



On 16 Feb 1998 12:38:52 -0500, dweller@universe.digex.net (David
Weller) wrote:

> In article <1998Feb13.213046.1@eisner>,
> Larry Kilgallen <Kilgallen@eisner.decus.org.nospam> wrote:
> >In article <34E47622.15EB@atc-1s.hac.com>, David Kusuda <dkusu@atc-1s.hac.com> writes:
> >> I'm pretty sure that this has been discussed before, but can anyone
> >> direct me towards an Ada to C++ translator?  Any information would be
> >> greatly appreciated.

[...]

> Let's save Mr. Kusuda a bag of time:
> 
> 	1) It can be done
> 	2) Over a lot of time
> 	3) With a lot of money
> 	4) Starting from scratch is MUCH cheaper
> 	5) It's a pretty dumb thing to do anyway
> 	    (It takes less code to do a project in Ada95 than in C++)

Why so intolerant?  Perhaps if you are asking about an automatic 
translator.   But hand translation is possible.  A well-designed Ada
program will translate into a well-designed C++ program.  (And a messy
Ada program - I have seen some horrifying examples too - will convert
into another mess.)  In this context of hand translation:

1) is certainly true.
2) is incorrect.  For a well designed program, it can be done in
linear time.

3) is wrong.
4) is wrong also: why repeat the careful analysis done in the first
place

5) is an academic assertion.  

Let me give an example:  I am doing most of my development using 
Delphi.  (More precisely, I program in Ada and use the Delphi compiler
to compile them.  :)

Recently, however, I have been porting one of our applications to 
Windows CE for the Palm PC.  While I wish a Delphi or Ada compiler
had been available for this environment, there is none and I had to
convert the program to C++.   While there are certain irritating 
things with the arcane C syntax, I was able to produce something
that was line per line (almost) parallel to the original.

The namespace concept helped a lot.  My impression of C++ is that
it is a huge language and that you can easily get lost.  But if you
start from a clean model, it is easier to restrict yourself to a
manageable subset.




Jean Ichbiah
Textware Solutions
ichbiah@twsolutions.com
http://www.twsolutions.com




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-18  0:00     ` Jean D. Ichbiah
@ 1998-02-18  0:00       ` David  Weller
  1998-02-18  0:00         ` Brian Rogoff
                           ` (2 more replies)
  1998-02-19  0:00       ` Delphi & Ada; Ada to C++ Nick Roberts
  1 sibling, 3 replies; 26+ messages in thread
From: David  Weller @ 1998-02-18  0:00 UTC (permalink / raw)



In article <34eb5d36.20077308@news.tiac.net>,
Jean D. Ichbiah <ichbiah@twsolutions.com> wrote:
>
>[Deletia related to somebody asking for an Ada to C++ Translator]
>
>> Let's save Mr. Kusuda a bag of time:
>> 
>> 	1) It can be done
>> 	2) Over a lot of time
>> 	3) With a lot of money
>> 	4) Starting from scratch is MUCH cheaper
>> 	5) It's a pretty dumb thing to do anyway
>> 	    (It takes less code to do a project in Ada95 than in C++)
>
>Why so intolerant?  Perhaps if you are asking about an automatic 
>translator.   But hand translation is possible.  A well-designed Ada
>program will translate into a well-designed C++ program.  (And a messy
>Ada program - I have seen some horrifying examples too - will convert
>into another mess.)  In this context of hand translation:
>
>1) is certainly true.
>2) is incorrect.  For a well designed program, it can be done in
>linear time.
>
>3) is wrong.
>4) is wrong also: why repeat the careful analysis done in the first
>place
>

Your four rebuttals are indeed correct for hand-translation.  Of
course, one could say it's a red herring, since the question was in
response to _automated_ translation.

>5) is an academic assertion.  
>

Wrong.  It's an unpublished _fact_.  Big difference.  My work with the
C++ Booch Components (_hand_ translating them into Ada95) yielded
around a 10% _reduction_ in overall code.  It would be fair to qualify
where that reduction came from: The template syntax in C++, IMHO,
stands as one of computer science's most outstanding examples of
abominal syntax.  The necessity to repeat the signature syntax in all
but the most confined circumstances stands as an eternal monument to
C++'s convoluted "I'm Object-Oriented But I MUST Act Like C" motto.
(Also IMHO, given what Bjarne had to work with, I don't think it could
have been done with any more elegance, so this isn't a slam on his
design effort).  Imperative code, namespaces, exceptions, etc.
generally pan out to a 1:1 basis.  Ada shines in generics and usage of
those generics.  I'm personally starting to pine for something that
combines what I feel are the best features of Ada and C++, and it
AIN'T called Java!

>The namespace concept helped a lot.  My impression of C++ is that
>it is a huge language and that you can easily get lost.  But if you
>start from a clean model, it is easier to restrict yourself to a
>manageable subset.
>

I, too, work in C++ every day.  Unfortunately, finding developers that
can exercise "feature restraint" is a rare occurrence :-)

Namespaces are nice, but most compilers still don't handle the
combination of namespaces and templates very well (as well as numerous
other things :-( )

-- 
   ******   NEW!!  DoD Ada Hotline Number:  1-800-PARIAH    ******
Tired of "junk" e-mail?  Write to your congressman and tell them you support
H.R. 1748, "The Netizens Protection Act of 1997".  Make those SPAM-roaches run!             http://www.cauce.org          TAKE BACK THE INTERNET!




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-18  0:00       ` David  Weller
@ 1998-02-18  0:00         ` Brian Rogoff
  1998-02-21  0:00           ` Esa Pulkkinen
  1998-02-19  0:00         ` Jean D. Ichbiah
  1998-02-25  0:00         ` Scott Leschke
  2 siblings, 1 reply; 26+ messages in thread
From: Brian Rogoff @ 1998-02-18  0:00 UTC (permalink / raw)



On 18 Feb 1998, David  Weller wrote:
> Jean D. Ichbiah <ichbiah@twsolutions.com> wrote:
> >
> >[Deletia related to somebody asking for an Ada to C++ Translator]
> >
> >> Let's save Mr. Kusuda a bag of time:
> >> 
... snip ...
> >> 	5) It's a pretty dumb thing to do anyway
> >> 	    (It takes less code to do a project in Ada95 than in C++)
> >
> 
> >5) is an academic assertion.  
> >
> 
> Wrong.  It's an unpublished _fact_.  Big difference.  My work with the
> C++ Booch Components (_hand_ translating them into Ada95) yielded
> around a 10% _reduction_ in overall code.  It would be fair to qualify
> where that reduction came from: The template syntax in C++, IMHO,
> stands as one of computer science's most outstanding examples of
> abominal syntax.

Hey, aren't you the guy that likes Perl? ;-)

I'd be interested in hearing how a well designed Ada program that makes
use of constrained genericity gets translated to a well designed C++
program. I haven't been following the C++ standard for a while, but I
thought that there was no constrained genericity in C++, and that the 
work-arounds would not really be considered "well-designed".

> those generics.  I'm personally starting to pine for something that
> combines what I feel are the best features of Ada and C++, and it
> AIN'T called Java!

Out of curiosity, which are the features of C++ that you would like that 
Ada doesn't have?
 
-- Brian






^ permalink raw reply	[flat|nested] 26+ messages in thread

* Delphi & Ada; Ada to C++
  1998-02-18  0:00     ` Jean D. Ichbiah
  1998-02-18  0:00       ` David  Weller
@ 1998-02-19  0:00       ` Nick Roberts
  1998-02-19  0:00         ` David  Weller
  1 sibling, 1 reply; 26+ messages in thread
From: Nick Roberts @ 1998-02-19  0:00 UTC (permalink / raw)



Jean:

   procedure Just_Like_Ada_Really (A, B: {in} Integer; var Result: {out}
String) ;{is}
   begin
      ...
   end {Just_Like_Ada_Really};

I have been where you now tread!

On the subject of translation from one high level language to another
(significantly different one).  I think the consensus of opinion is that,
if you need the result to be readable (by humans), manual translation is
likely to be the only workable option.

Machine translation is certainly possible.  Since GNAT produces C code (and
C++ is pretty well a superset of C), this suggests a possibility (doubtless
not entirely wrinkle-free).  Also, automated translation, or partial
translation, could well be a good way to get a 'jump start' for a manual
translation (and it may even be practical for you to program this yourself,
since you need only be rough).

== Nick Roberts ================================================
== Croydon, UK                       ===========================
==                                              ================
== Proprietor, ThoughtWing Software                   ==========
== Independent Software Development Consultant            ======
== Nick.Roberts@dial.pipex.com                              ====
== Voicemail & Fax +44 181-405 1124                          ===
==                                                            ==
==           I live not in myself, but I become               ==
===          Portion of that around me; and to me             ==
====         High mountains are a feeling, but the hum        ==
=======      Of human cities torture.
===========                             -- Byron [Childe Harold]

Jean D. Ichbiah <ichbiah@twsolutions.com> wrote in article
<34eb5d36.20077308@news.tiac.net>...
> [...] I am doing most of my development using 
> Delphi.  (More precisely, I program in Ada and use the Delphi compiler
> to compile them.  :)





^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-18  0:00       ` David  Weller
  1998-02-18  0:00         ` Brian Rogoff
@ 1998-02-19  0:00         ` Jean D. Ichbiah
  1998-02-19  0:00           ` Larry Kilgallen
  1998-02-25  0:00         ` Scott Leschke
  2 siblings, 1 reply; 26+ messages in thread
From: Jean D. Ichbiah @ 1998-02-19  0:00 UTC (permalink / raw)



On 18 Feb 1998 09:12:06 -0500, dweller@universe.digex.net (David
Weller) wrote:


> >The namespace concept helped a lot.  My impression of C++ is that
> >it is a huge language and that you can easily get lost.  But if you
> >start from a clean model, it is easier to restrict yourself to a
> >manageable subset.
> >
> 
> I, too, work in C++ every day.  Unfortunately, finding developers that
> can exercise "feature restraint" is a rare occurrence :-)

Right.  But my point is precisely that if you start with
a feature restrained original, you end up with a 
feature restrained conversion

> Namespaces are nice, but most compilers still don't handle the
> combination of namespaces and templates very well (as well as numerous
> other things :-( )

Yes this is the C culture.  In five years of work with the Delphi
compiler (and predecessors) I found one obscure bug in the RichEdit
implementation for MT.

In two weeks with the MS Visual C++ 5.0, I had already stumbled over
several major bugs, one of which required partial recoding.






Jean Ichbiah
Textware Solutions
ichbiah@twsolutions.com
http://www.twsolutions.com




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-19  0:00         ` Jean D. Ichbiah
@ 1998-02-19  0:00           ` Larry Kilgallen
  0 siblings, 0 replies; 26+ messages in thread
From: Larry Kilgallen @ 1998-02-19  0:00 UTC (permalink / raw)



In article <34eb9e0d.45543971@news.tiac.net>, ichbiah@twsolutions.com (Jean D. Ichbiah) writes:

> Yes this is the C culture.  In five years of work with the Delphi
> compiler (and predecessors) I found one obscure bug in the RichEdit
> implementation for MT.
> 
> In two weeks with the MS Visual C++ 5.0, I had already stumbled over
> several major bugs, one of which required partial recoding.

I sense another variable here besides the programming language.

Has anyone done such an informal comparison for defects between
Delphi and MS Visual Basic ?

Larry Kilgallen




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-19  0:00       ` Delphi & Ada; Ada to C++ Nick Roberts
@ 1998-02-19  0:00         ` David  Weller
  1998-02-19  0:00           ` Nick Roberts
  1998-02-21  0:00           ` Simon Wright
  0 siblings, 2 replies; 26+ messages in thread
From: David  Weller @ 1998-02-19  0:00 UTC (permalink / raw)



In article <01bd3cc5$a74ff160$LocalHost@xhv46.dial.pipex.com>,
Nick Roberts <Nick.Roberts@dial.pipex.com> wrote:
>Machine translation is certainly possible.  Since GNAT produces C code (and
>C++ is pretty well a superset of C), this suggests a possibility (doubtless


NO NO NO NO!!!

Repeat after me:  GNAT does NOT produce C code.  GNAT does NOT produce
C code.  GNAT does NOT produce C code.  GNAT does NOT produce C code.
GNAT does NOT produce C code.  GNAT does NOT produce C code.  GNAT
does NOT produce C code.  GNAT does NOT produce C code.  GNAT does NOT
produce C code.  GNAT does NOT produce C code.  GNAT does NOT produce
C code.  GNAT does NOT produce C code.  GNAT does NOT produce C code.

There.  Feel better now? :-)

-- 
	What is DIVX?  Find out at http://www.riva.com/dvd_divx.html
Tired of "junk" e-mail?  Write to your congressman and tell them you support
H.R. 1748, "The Netizens Protection Act of 1997".  Make those SPAM-roaches run!             http://www.cauce.org          TAKE BACK THE INTERNET!




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-19  0:00         ` David  Weller
@ 1998-02-19  0:00           ` Nick Roberts
  1998-02-19  0:00             ` Jon S Anthony
  1998-02-21  0:00           ` Simon Wright
  1 sibling, 1 reply; 26+ messages in thread
From: Nick Roberts @ 1998-02-19  0:00 UTC (permalink / raw)



Sorry! I got the impression that was how GNAT worked (translate Ada to C,
and then compile to executable).  Looking at the documentation for GNAT
3.10 (R1.30), I see no mention of intermediate C.  Is this how GNAT worked
once upon a time, or did I simply get totally the wrong end of the stick? 
What is GNAT's relationship to GCC?


== Nick Roberts ================================================
== Croydon, UK                       ===========================
==                                              ================
== Proprietor, ThoughtWing Software                   ==========
== Independent Software Development Consultant            ======
== Nick.Roberts@dial.pipex.com                              ====
== Voicemail & Fax +44 181-405 1124                          ===
==                                                            ==
==           I live not in myself, but I become               ==
===          Portion of that around me; and to me             ==
====         High mountains are a feeling, but the hum        ==
=======      Of human cities torture.
===========                             -- Byron [Childe Harold]


David  Weller <dweller@universe.digex.net> wrote in article
<6chg3h$4qf@universe.digex.net>...
> In article <01bd3cc5$a74ff160$LocalHost@xhv46.dial.pipex.com>,
> Nick Roberts <Nick.Roberts@dial.pipex.com> wrote:
> >Machine translation is certainly possible.  Since GNAT produces C code
(and
> >C++ is pretty well a superset of C), this suggests a possibility
(doubtless
> 
> 
> NO NO NO NO!!!
> 
> Repeat after me:  GNAT does NOT produce C code.  GNAT does NOT produce
> C code.  GNAT does NOT produce C code.  GNAT does NOT produce C code.
> GNAT does NOT produce C code.  GNAT does NOT produce C code.  GNAT
> does NOT produce C code.  GNAT does NOT produce C code.  GNAT does NOT
> produce C code.  GNAT does NOT produce C code.  GNAT does NOT produce
> C code.  GNAT does NOT produce C code.  GNAT does NOT produce C code.
> 
> There.  Feel better now? :-)
> 
> -- 
> 	What is DIVX?  Find out at http://www.riva.com/dvd_divx.html
> Tired of "junk" e-mail?  Write to your congressman and tell them you
support
> H.R. 1748, "The Netizens Protection Act of 1997".  Make those
SPAM-roaches run!             http://www.cauce.org          TAKE BACK THE
INTERNET!
> 




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-19  0:00           ` Nick Roberts
@ 1998-02-19  0:00             ` Jon S Anthony
  1998-02-20  0:00               ` Nick Roberts
  0 siblings, 1 reply; 26+ messages in thread
From: Jon S Anthony @ 1998-02-19  0:00 UTC (permalink / raw)




"Nick Roberts" <Nick.Roberts@dial.pipex.com> writes:

> Sorry! I got the impression that was how GNAT worked (translate Ada to C,
> and then compile to executable).  Looking at the documentation for GNAT
> 3.10 (R1.30), I see no mention of intermediate C.  Is this how GNAT worked
> once upon a time, or did I simply get totally the wrong end of the stick? 

You got it totally wrong.

> What is GNAT's relationship to GCC?

GNAT uses the gcc backend (just like g77, g++, and the good ol' c
compiler among others...) by producing an intermediate tree that it
eats.  The output is machine code for the given platform.

/Jon

-- 
Jon Anthony
Synquiry Technologies, Ltd., Belmont, MA 02178, 617.484.3383
"Nightmares - Ha!  The way my life's been going lately,
 Who'd notice?"  -- Londo Mollari




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-19  0:00             ` Jon S Anthony
@ 1998-02-20  0:00               ` Nick Roberts
  1998-02-21  0:00                 ` Richard Kenner
  0 siblings, 1 reply; 26+ messages in thread
From: Nick Roberts @ 1998-02-20  0:00 UTC (permalink / raw)



Many thanks.  I think I read somewhere that "GNAT uses the FSF's[?]
renowned gcc technology", or something like that, and I had simply assumed
the rest.  Funny how the old brain fills in the cracks (wrongly in this
case :-) innit?

Now to throw the cat among the pigeons: how difficult would it be to
retro-compile the tree into C (or even C++)?

While we're on the subject: is or was gcc a product of the FSF?  Was it
(originally) written by Richard Stallman?  I'm beginning to distrust my
memory now!


== Nick Roberts ================================================
== Croydon, UK                       ===========================


Jon S Anthony <jsa@synquiry.com> wrote in article
<ufvhubywi3.fsf@synquiry.com>...
[...]
> GNAT uses the gcc backend (just like g77, g++, and the good ol' c
> compiler among others...) by producing an intermediate tree that it
> eats.  The output is machine code for the given platform.





^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-19  0:00         ` David  Weller
  1998-02-19  0:00           ` Nick Roberts
@ 1998-02-21  0:00           ` Simon Wright
  1998-02-21  0:00             ` Richard Kenner
  1 sibling, 1 reply; 26+ messages in thread
From: Simon Wright @ 1998-02-21  0:00 UTC (permalink / raw)



dweller@universe.digex.net (David  Weller) writes:

> In article <01bd3cc5$a74ff160$LocalHost@xhv46.dial.pipex.com>,
> Nick Roberts <Nick.Roberts@dial.pipex.com> wrote:
> >Machine translation is certainly possible.  Since GNAT produces C code (and
> >C++ is pretty well a superset of C), this suggests a possibility (doubtless
> 
> 
> NO NO NO NO!!!

And even if it did, it's unlikely that you would be able to make a lot
of sense of it. Names would be mangled, strange and wonderful
constructs would appear, ... (just think about exceptions, generics,
...) you would not want to maintain the result!




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-20  0:00               ` Nick Roberts
@ 1998-02-21  0:00                 ` Richard Kenner
  1998-02-21  0:00                   ` Robert Dewar
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Kenner @ 1998-02-21  0:00 UTC (permalink / raw)



In article <01bd3e24$280e1c00$a8fc82c1@xhv46.dial.pipex.com> "Nick Roberts" <Nick.Roberts@dial.pipex.com> writes:
>Now to throw the cat among the pigeons: how difficult would it be to
>retro-compile the tree into C (or even C++)?

Extremely difficult.  First of all, the interface isn't totally a
tree, but is mostly procedural, using trees just for expressions and
objects.  So you'd have to catch all of the procedure calls as well.
But many of the trees (for example those involving variant records)
have no C equivalent anyway.

>While we're on the subject: is or was gcc a product of the FSF? 

Yes.

>Was it (originally) written by Richard Stallman?  

Yes, and he maintained it until sometime in the early 90's at which point
I took over maintenance of GCC.




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-21  0:00           ` Simon Wright
@ 1998-02-21  0:00             ` Richard Kenner
  1998-03-05  0:00               ` Robert I. Eachus
  0 siblings, 1 reply; 26+ messages in thread
From: Richard Kenner @ 1998-02-21  0:00 UTC (permalink / raw)



In article <x7v1zwxtkvz.fsf@pogner.demon.co.uk> Simon Wright <simon@pogner.demon.co.uk> writes:
>And even if it did, it's unlikely that you would be able to make a lot
>of sense of it. Names would be mangled, strange and wonderful
>constructs would appear, ... (just think about exceptions, generics,
>...) you would not want to maintain the result!

Actually, generics can be translated in a relatively straightforward
manner since it's just macro substitution.  Exceptions are trickier,
but still can be done reasonable well.  The real hard cases are
variant records and unconstrained arrays.




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-21  0:00                 ` Richard Kenner
@ 1998-02-21  0:00                   ` Robert Dewar
  0 siblings, 0 replies; 26+ messages in thread
From: Robert Dewar @ 1998-02-21  0:00 UTC (permalink / raw)



In article <01bd3e24$280e1c00$a8fc82c1@xhv46.dial.pipex.com> "Nick Roberts" <Ni
k.Roberts@dial.pipex.com> writes:
>Now to throw the cat among the pigeons: how difficult would it be to
>retro-compile the tree into C (or even C++)?


(tree here = GNAT tree)

It would conceivably be possible to compile it into VERY low level C, where
you had a few variables corresponding to registers, say called r0, r1, r2
and you generated C that for example, in unoptimized mode, might
compile

   A := B + C;

where A,B,C are all local variables, into something like

   r0 = *(fp+100);
   r1 = *(fp+104);
   r2 = r0 + r1;
   *(fp+108) = r2;

This is *really* using C as a low level assembler :-)

The way you could do this is to write a config file for gcc that treated
C in this way as a kind of pseudo-machine. We once thought about this as
a way to make a version of GNAT that could be ported in native mode, rather
than requiring cross-compilers, but it was never more than a passing
interesting idea.

You could try to reverse compile the tree at a much higher level into
C, but this would be a huge task, comparable to that of writing a
compiler, and in some ways much more difficult (it would be like trying
to do a complete house renovation, rather than building a new house --
as those who have gone through it know, the renovation can often be the
harder task).

Furthermore, some of the constructs would still generate rubbish, since
C just does not have the required semantic richness.
(e.g. what do you do with overflow checking, and what do you do with
 nested procedures ....)





^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-18  0:00         ` Brian Rogoff
@ 1998-02-21  0:00           ` Esa Pulkkinen
  1998-02-23  0:00             ` Brian Rogoff
  0 siblings, 1 reply; 26+ messages in thread
From: Esa Pulkkinen @ 1998-02-21  0:00 UTC (permalink / raw)



[Sorry this is a bit off-topic for comp.lang.ada, so I'll crosspost and
put followups to comp.lang.c++.moderated.]

Brian Rogoff <bpr@shell5.ba.best.com> writes at comp.lang.ada:
> I'd be interested in hearing how a well designed Ada program that makes
> use of constrained genericity gets translated to a well designed C++
> program. I haven't been following the C++ standard for a while, but I
> thought that there was no constrained genericity in C++, and that the 
> work-arounds would not really be considered "well-designed".

See http://www.cs.tut.fi/~esap/instructive/ for one method for
converting a program which uses constrained genericity to C++ using
class template partial specialization. It uses class template partial
specialization to implement different versions of the class for the case
where the class is derived from another class, and for the case where it
isn't. I think it's as well-designed as it ever will without explicit
language support, but I'd like to hear your opinions.
-- 
   Esa Pulkkinen                        | C++ programmers do it virtually
   E-Mail:  esap@cs.tut.fi              | everywhere with class, resulting
   WWW   :  http://www.cs.tut.fi/~esap/ | in multiple inheritance.

      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]





^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-21  0:00           ` Esa Pulkkinen
@ 1998-02-23  0:00             ` Brian Rogoff
  0 siblings, 0 replies; 26+ messages in thread
From: Brian Rogoff @ 1998-02-23  0:00 UTC (permalink / raw)



On 21 Feb 1998, Esa Pulkkinen wrote:
> [Sorry this is a bit off-topic for comp.lang.ada, so I'll crosspost
and
> put followups to comp.lang.c++.moderated.]

I think it is perfectly appropriate for comp.lang.ada, as long as
language
warriors restrain themselves.

> Brian Rogoff <bpr@shell5.ba.best.com> writes at comp.lang.ada:
> > I'd be interested in hearing how a well designed Ada program that
makes
> > use of constrained genericity gets translated to a well designed C++
> > program. I haven't been following the C++ standard for a while, but
I
> > thought that there was no constrained genericity in C++, and that
the 
> > work-arounds would not really be considered "well-designed".
> 
> See http://www.cs.tut.fi/~esap/instructive/ for one method for
> converting a program which uses constrained genericity to C++ using
> class template partial specialization. It uses class template partial
> specialization to implement different versions of the class for the
case
> where the class is derived from another class, and for the case where
it
> isn't. I think it's as well-designed as it ever will without explicit
> language support, but I'd like to hear your opinions.

Very interesting; the workaround I am familiar with is the one where you

do an assignment to the constraint type in some method. I'll certainly
try your method out next time I have a capable C++ compiler. Still, I
have
some issues, namely 

(1) What if the generic parameters being constrained are not 
    tagged types/classes? In the case of Ada, there are generic
    constraints to match all of the types in the language. This is 
    not such a big deal in C++, since you don't have ranges, but it 
    surely does make such a translation harder. 

(2) Function and procedure parameters. I assume you'd just wrap these up
    in classes, right? That's a bit tedious.

(3) Formal package parameters. This is my favorite "gee-whiz" feature of

    Ada 95. It's related to (1) and (2) in that I can (and do!) bundle 
    up non-tagged generic abstractions (like Stacks and Dictionaries
say)
    and then use instantiations of both with their actual parameters 
    constrained to be the same. Once again, it seems with your
translation
    I have to first make everything a class. 

That said, I think your translation is a very neat trick. In a "feature 
restrained" program, done in a very stylized way, it would work, but I
fear that a straightforward and idiomatic Ada 95 program would not
translate to a similarly straightforward (Draft) ISO C++ program.
Almost all of my Ada code uses constrained genericity somewhere. 

-- Brian


      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
@ 1998-02-23  0:00 Marin David Condic, 561.796.8997, M/S 731-96
  1998-02-24  0:00 ` Dale Stanbrough
  1998-02-24  0:00 ` Robert Dewar
  0 siblings, 2 replies; 26+ messages in thread
From: Marin David Condic, 561.796.8997, M/S 731-96 @ 1998-02-23  0:00 UTC (permalink / raw)



David Weller <dweller@UNIVERSE.DIGEX.NET> writes:
>NO NO NO NO!!!
>
>Repeat after me:  GNAT does NOT produce C code.  GNAT does NOT produce
>C code.  GNAT does NOT produce C code.  GNAT does NOT produce C code.
>GNAT does NOT produce C code.  GNAT does NOT produce C code.  GNAT
>does NOT produce C code.  GNAT does NOT produce C code.  GNAT does NOT
>produce C code.  GNAT does NOT produce C code.  GNAT does NOT produce
>C code.  GNAT does NOT produce C code.  GNAT does NOT produce C code.
>
>There.  Feel better now? :-)
>
    Where did this particular piece of Urban Lore get started? I seem
    to recall many years ago that somebody had an Ada83 compiler that
    generated C as "high level assembler" - Irvine seems to suggest
    itself, but I wouldn't swear to it.

    It seems lots of folks "know" this piece of lore and it must have
    had some basis in fact or legend which has served to keep it
    going.

    MDC

Marin David Condic, Senior Computer Engineer     Voice:     561.796.8997
Pratt & Whitney GESP, M/S 731-95, P.O.B. 109600  Fax:       561.796.4669
West Palm Beach, FL, 33410-9600                  Internet:  CONDICMA@PWFL.COM
=============================================================================
    "Because that's where they keep the money."
        --  Willie Sutton when asked why he robbed banks.
=============================================================================




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-23  0:00 Marin David Condic, 561.796.8997, M/S 731-96
  1998-02-24  0:00 ` Dale Stanbrough
@ 1998-02-24  0:00 ` Robert Dewar
  1998-02-25  0:00   ` Jean-Pierre Rosen
  1 sibling, 1 reply; 26+ messages in thread
From: Robert Dewar @ 1998-02-24  0:00 UTC (permalink / raw)



Marin said

<<    Where did this particular piece of Urban Lore get started? I seem
    to recall many years ago that somebody had an Ada83 compiler that
    generated C as "high level assembler" - Irvine seems to suggest
    itself, but I wouldn't swear to it.

    It seems lots of folks "know" this piece of lore and it must have
    had some basis in fact or legend which has served to keep it
    going.

    MDC
>>

The lore in question is the completely wrong assumptionj that GNAT generates
C. In fact I think this comes from three things:

1. The fact that GCC stands for GNU C compiler, and people know GNAT somehow
	uses GCC. These days, GCC is much more than a C compiler, but the
	confusion persists.

2. The fact that the T in GNAT used to stand for translator, that was our
	mistake. We have retained the name, but now take the position that
	GNAT is not an acronym and stands for nothing.

3. The fact that GNAT has in the past always generated its main program
	from the binder in C, and you see this C code if you do a list
	from GDB before doing anything else. The current version of GNAT
	can also generate the main program in Ada, and we will make this
	the default at some point.

Still, the legend is indeed completely wrong. In no sense does GNAT
translate your Ada code into C code.

Robert Dewar
Ada COre Technologies





^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-23  0:00 Marin David Condic, 561.796.8997, M/S 731-96
@ 1998-02-24  0:00 ` Dale Stanbrough
  1998-02-24  0:00 ` Robert Dewar
  1 sibling, 0 replies; 26+ messages in thread
From: Dale Stanbrough @ 1998-02-24  0:00 UTC (permalink / raw)



Marin David Condic writes:
"    Where did this particular piece of Urban Lore get started? I seem
     to recall many years ago that somebody had an Ada83 compiler that
     generated C as "high level assembler" - Irvine seems to suggest
     itself, but I wouldn't swear to it.

     It seems lots of folks "know" this piece of lore and it must have
     had some basis in fact or legend which has served to keep it
     going."


I've seen many students make this mistake, and it seems to stem from...

	gcc is a compiler that compiles C programs.
	i use gcc to compile Ada programs
	ergo the compile translates Ada to C, and then compiles it.


Another reason for this confusion was the original name of Gnat - the
GNu Ada Translator (an acronym which Robert Dewar has since disowned)
- people are used to using the word Translator and compiler to mean
very different things.


Dale




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-18  0:00       ` David  Weller
  1998-02-18  0:00         ` Brian Rogoff
  1998-02-19  0:00         ` Jean D. Ichbiah
@ 1998-02-25  0:00         ` Scott Leschke
  1998-02-25  0:00           ` David  Weller
  2 siblings, 1 reply; 26+ messages in thread
From: Scott Leschke @ 1998-02-25  0:00 UTC (permalink / raw)



dweller@universe.digex.net (David  Weller) writes:

>Wrong.  It's an unpublished _fact_.  Big difference.  My work with the
>C++ Booch Components (_hand_ translating them into Ada95) yielded
>around a 10% _reduction_ in overall code.  It would be fair to qualify
>where that reduction came from: The template syntax in C++, IMHO,
>stands as one of computer science's most outstanding examples of
>abominal syntax.  The necessity to repeat the signature syntax in all
>but the most confined circumstances stands as an eternal monument to
>C++'s convoluted "I'm Object-Oriented But I MUST Act Like C" motto.
>(Also IMHO, given what Bjarne had to work with, I don't think it could
>have been done with any more elegance, so this isn't a slam on his
>design effort).  Imperative code, namespaces, exceptions, etc.
>generally pan out to a 1:1 basis.  Ada shines in generics and usage of
>those generics.  I'm personally starting to pine for something that
>combines what I feel are the best features of Ada and C++, and it
>AIN'T called Java!

Was the Booch Components work ever completed?  I've seen you use this
comparison a number of times but to my knowledge the work was left in
a beta state.  The date on the web page I'm looking at says it was last
updated June 17th (I'm assuming that's 1997).
-- 
Scott Leschke.........................email: leschkes@cig.mot.com
Motorola, Inc............................ph: 847-632-2786
1501 W Shure Drive......................fax: 847-632-6519
Arlington Heights, IL   60004......mailstop: 1-J21




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Ada to C++ Translators
  1998-02-25  0:00         ` Scott Leschke
@ 1998-02-25  0:00           ` David  Weller
  0 siblings, 0 replies; 26+ messages in thread
From: David  Weller @ 1998-02-25  0:00 UTC (permalink / raw)



In article <leschkes.888427291@ferret>,
Scott Leschke <leschkes@ferret.cig.mot.com> wrote:
>dweller@universe.digex.net (David  Weller) writes:
>
>>Wrong.  It's an unpublished _fact_.  Big difference.  My work with the
>>C++ Booch Components (_hand_ translating them into Ada95) yielded
>>around a 10% _reduction_ in overall code.  It would be fair to qualify
>>where that reduction came from: The template syntax in C++, IMHO,
>>stands as one of computer science's most outstanding examples of
>Was the Booch Components work ever completed?  I've seen you use this
>
>comparison a number of times but to my knowledge the work was left in
>a beta state.  The date on the web page I'm looking at says it was last
>updated June 17th (I'm assuming that's 1997).
>-- 

You're correct, Scott.  Work on the components has halted :-(
That doesn't invalidate the claim, and the metrics would still stand
if they were completed.

The anouncement was published on Christmas Eve last year on Team Ada.
I was hoping somebody else would pick them up, but no offers seemed to
pan out.  Here is the announcement in its entirety:

==========================
For each of us, the New Year represents a time of reflection and
rededication.  Many of us will make New Year's resolutions, swearing
to avoid a vice, help others, and otherwise do something generally
redeeming to ourselves and those around us.

For almost three years now, I've tried to pursue a "spare time love"
that was important to both myself and the Ada community: The Ada95
Booch Components.  It is time to admit I am doing a severe injustice
to the Ada community at large by attempting to complete these
components.  In a nutshell, I need a volunteer to take over.

I have realized that it is next to impossible to expect my workload to
change appreciably in this coming year.  I'm a senior member of a
small and growing company, and my "spare time" is absorbed with
performing many software development tasks (some in Ada) to help the
company grow.  To let the components gather dust is, IMHO, criminal.
And thus I am guilty.  It is with a sad heart that I must hand the
responsibility over to somebody that can affort more time to it.

I discussed this briefly with Jack Beidler, who has expressed a
willingness to take the task over, but I think he and I both would be
more comfortable with a person (or persons) who would be able to make
the time and commitment to getting these things done by the
springtime.  This posting is deliberately limited to Team-Ada.  If you
think a non-Team-Ada person is interested in tackling this task, by
all means forward it.  Please note that you should be fluent in both
C++ and Ada95 to have any reasonable timetable for success :-)

While I am unable to give the time necessary to develop the
components, I'm more than willing to provide "historical guidance" to
whoever picks up the baton.  Further, I have a large set of notes that
I can also provide to help out.

I hope each of you can appreciate the sheer willpower it takes for me
to even write this note.  To admit that I cannot find the time to
complete this task is heartbreaking.  However, I cannot bear
disappointing the Ada community further.  

I hope you will all forgive me.


David G. Weller
December 24, 1997
-- 
  DVD vs. DIVX: The Truth Is Out There => http://www.riva.com/dvd_divx.html

	Dear Spammers: Your crap gets autoforwarded to uce@ftc.gov




^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-24  0:00 ` Robert Dewar
@ 1998-02-25  0:00   ` Jean-Pierre Rosen
  0 siblings, 0 replies; 26+ messages in thread
From: Jean-Pierre Rosen @ 1998-02-25  0:00 UTC (permalink / raw)



Robert Dewar a �crit dans le message ...
>2. The fact that the T in GNAT used to stand for translator, that was our
> mistake. We have retained the name, but now take the position that
> GNAT is not an acronym and stands for nothing.
>

It could stand for "GNu Ada Toolset"...
--
----------------------------------------------------------------------------
                  J-P. Rosen (Rosen.Adalog@wanadoo.fr)
      Visit Adalog's web site at http://perso.wanadoo.fr/adalog






^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Delphi & Ada; Ada to C++
  1998-02-21  0:00             ` Richard Kenner
@ 1998-03-05  0:00               ` Robert I. Eachus
  0 siblings, 0 replies; 26+ messages in thread
From: Robert I. Eachus @ 1998-03-05  0:00 UTC (permalink / raw)



In article <6cms2p$7pv$1@news.nyu.edu> kenner@lab.ultra.nyu.edu (Richard Kenner) writes:

 > Actually, generics can be translated in a relatively straightforward
 > manner since it's just macro substitution.  Exceptions are trickier,
 > but still can be done reasonable well.  The real hard cases are
 > variant records and unconstrained arrays.

   Most Ada generics are translatable as macro substitution, but the
devil is in the details. There are many instances where thunks or some
other mechanism is required to deal with freezing at the point (during
execution) of instantiation.  In most cases, all that changes at
run-time are ranges or array bounds, but it is also possible for the
binding of names to subprograms to change...

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~1998-03-05  0:00 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-13  0:00 Ada to C++ Translators David Kusuda
1998-02-14  0:00 ` Larry Kilgallen
1998-02-16  0:00   ` David  Weller
1998-02-18  0:00     ` Jean D. Ichbiah
1998-02-18  0:00       ` David  Weller
1998-02-18  0:00         ` Brian Rogoff
1998-02-21  0:00           ` Esa Pulkkinen
1998-02-23  0:00             ` Brian Rogoff
1998-02-19  0:00         ` Jean D. Ichbiah
1998-02-19  0:00           ` Larry Kilgallen
1998-02-25  0:00         ` Scott Leschke
1998-02-25  0:00           ` David  Weller
1998-02-19  0:00       ` Delphi & Ada; Ada to C++ Nick Roberts
1998-02-19  0:00         ` David  Weller
1998-02-19  0:00           ` Nick Roberts
1998-02-19  0:00             ` Jon S Anthony
1998-02-20  0:00               ` Nick Roberts
1998-02-21  0:00                 ` Richard Kenner
1998-02-21  0:00                   ` Robert Dewar
1998-02-21  0:00           ` Simon Wright
1998-02-21  0:00             ` Richard Kenner
1998-03-05  0:00               ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
1998-02-23  0:00 Marin David Condic, 561.796.8997, M/S 731-96
1998-02-24  0:00 ` Dale Stanbrough
1998-02-24  0:00 ` Robert Dewar
1998-02-25  0:00   ` Jean-Pierre Rosen

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