comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Ada -> C or C++ translator
Date: Wed, 03 Jul 2002 15:16:19 GMT
Date: 2002-07-03T15:16:19+00:00	[thread overview]
Message-ID: <3D2315CA.7050807@attbi.com> (raw)
In-Reply-To: afiajc$sf4$2@news.btv.ibm.com

pontius@btv.mbi.com.invalid wrote:


> Picture an area where C/C++ are the normal and supported tools, and
> indeed there is an aversion to "weird" stuff like Ada. Even within a
> company or area things like this can vary from one department to
> another.
> 
> So at the moment, while I may prefer to do some development in Ada, I
> am being told to "just use normal stuff that someone else can pick up
> from you, instead of something weird that will make us write it over."
> Keep in mind that software development is also not our main job, rather
> something that sometimes needs to be done so we can do our main job.
> 
> So I'd like to develop in Ada, and be prepared as needed to move the
> code to C/C++, or perhaps Java, if it needs to be given to someone
> else. Since there is no support, and hence no budget for this idea, I
> need to use free tools. Interface to existing C/C++ libraries is also
> necessary. (former easy, latter may need workarounds)
> 
> So far since the code hasn't been terribly performance sensitive, I've
> been using scripting languages so far. I may be able to keep it there,
> but I don't know.


There was a project many years ago that had us all laughing when we 
found out what was going on.  You could probably use the same technique...

The project manager and all of his team wanted to use Ada, but alas 
upper management would not let them.  The code had to be in C so it 
would be portable.  What did they do?  Well they defined a number of C 
macros, then wrote all their code in (a subset of) Ada.  Add an emacs 
macro which added the #defines and changed withs into includes, and they 
were all set.  The project code was all written in Ada, but the check-in 
process compiled the C code as well, and the CM suite also checked 
overnight that the C and Ada versions produced identical output on the 
regression suite.

Sounds like a lot of work, but it took less than a week to get the first 
version of the toolset up and running.  In fact it took some of the 
programmers longer to understand that if the Ada compile failed, there 
really was a bug in their code.  The biggest complaints of course were 
about things that were valid in K&R C and some current C compilers "let 
you get away with."  For example, returning -1 from a function defined 
to return a pointer...

In general the programming team felt that the "up front" cost through 
unit test balanced out.  Getting clean initial clean compiles from both 
Ada and C took longer, but that was more than cancelled out by the 
strong typing benefits when interfaces needed to be modified.

Of course, integration and test was scheduled for 8 months, and took 
three weeks. ;-)

I know it sounds hard, but once they got started, the #defines were easy:

#define begin {
#define end } \/\/
(Did I get that right?  It has been so long since I did "clever" things 
in cpp.  The intent of course is to make everything following the end 
keyword a comment.)

And of course, there were areas of Ada that they had no intention of 
using such as tasking and exceptions, so those were not supported by the 
translation too.





  parent reply	other threads:[~2002-07-03 15:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17 12:26 Ada -> C or C++ translator David Rasmussen
2002-06-17 12:51 ` Martin Dowie
2002-06-17 12:59   ` David Rasmussen
2002-06-17 14:21     ` Larry Kilgallen
2002-06-17 14:19       ` David Rasmussen
2002-06-28 18:40       ` pontius
2002-06-29  1:47         ` tmoran
2002-07-01 14:30           ` pontius
2002-07-03 15:16         ` Robert I. Eachus [this message]
2002-07-13 22:55           ` David Thompson
2002-06-18 23:41 ` Robert A Duff
2002-06-19  0:21   ` exceptions and C functions (was Re: Ada -> C or C++ translator) Dale Stanbrough
2002-06-19  1:44     ` Robert A Duff
2002-06-19 14:32       ` Wes Groleau
2002-06-19 17:33         ` Robert A Duff
2002-06-19 17:58           ` Wes Groleau
2002-06-19 19:17             ` Robert A Duff
replies disabled

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