On Friday, July 30, 2010 at 8:17, Frank Heckenbach wrote:
Since most of these languages are not widely used, I wouldn't consider them attractive targets for a converter. Ada may be an exception, but it's still less widely used than C++, and at least I know C++ much better than Ada....
This raises a point of interest to me. When GPC development stalled, I had to decide whether to continue with GPC as it was, switch to another Pascal compiler, or switch languages. I have programmed in Pascal for thirty years; it was my fifth language, after BASIC, Algol 60, FORTRAN IV, and SNOBOL, and of those, it is the only one in which I have continued to develop new programs. This was due primarily to the existance of GPC, and especially its good support for ISO 10206.
For a number of reasons, I elected to switch to Ada, as implemented by the GNU Ada compiler (GNAT). I had studied the language shortly after it was introduced in 1983 but did not use it seriously until a GCC version became available. I found the transition from Pascal to Ada to be quite easy, because many of the implementation concepts are similar. For several years, I've done all of my new work in Ada instead of Pascal.
I would think that translating from Pascal to Ada would have some advantages over C++. For example, Ada inherently supports scalar subrange types and range checking. I'm not that familiar with C++, but I don't believe that subranges are supported. So a Pascal to C++ translator would have to emit explicit code for range checks, whereas a Pascal to Ada translator could emit an Ada subrange type and let the Ada compiler handle range checking. The same consideration would pertain to array index checking and NIL-pointer dereferencing.
Other examples would be nested procedures, packed arrays and records, and string slice access, all of which are inherently supported by Ada. In short, I would expect that the closer mapping of Pascal to Ada constructs would result in a simpler translator than if the target language differed more significantly from Pascal. In many cases, the emitted Ada code could be nearly identical to the Pascal code.
GNAT is well supported by AdaCore Technologies, whose large customers (e.g., Boeing, Lockheed) drive compiler improvements and bug fixes back into the GCC code base. So the compiler is in good shape, and it maintains compatibility with the current GCC release. (One metric that I considered when switching from GPC to GNAT was that a packed array access that generated about 175 instructions in GPC generated only 15 for the equivalent code in GNAT.) GNAT is also well-supported by GDB.
Finally, I would think that a user base of Pascal programmers could more easily help to examine the Ada output of the translator for correctness than if the output were in C++.
On the other hand, as you say, if you know C++ much better than Ada, then you're likely to be more productive initially if the translator targets C++. Whether that would be offset by the additional work required, as noted above, is unknown.
Another point is that GNAT is pretty much the only freely-available Ada compiler, although it runs on a large variety of platforms. There appear to be several C++ compilers available, so perhaps targeting C++ would allow broader host-platform coverage.
Overall, I've been happy with the switch. I've used GPC for about 12 years, both for in-house programming and for embedded-microprocessor (M68K) work, and it's been very useful for both. Regardless of GPC's future, I appreciate the work that you, Waldek, Jan-Jaap, Peter, and Jukka have done, as well as that of the rest of the GPC contributors.
-- Dave