maybee@pogo.GPID.TEK.COM (Joe Maybee) (01/10/89)
In article <4471@tekgvs.GVS.TEK.COM> toma@tekgvs.GVS.TEK.COM (Tom Almy) writes: >Perhaps I don't know how much effort is involved in writing a C++ compiler, >but I can recognize schlocky distribution practices and poor documentation. >Just because a compiler is complex doesn't excuse: > >1) Distributing more than one version at a time (I received my version 1.05 > in Nlate October). >2) Distributing a compiler so buggy that it crashes even on small modules, > billing it as other than a "beta" version. There is no way I could > recommend this thing for other than toy use. >3) Inability to get one of the distribution files -- zero length on the > distribution media, and junk sent in the mail after two phone calls. >4) No notification of a fixed version (1.07, what makes this "baseline"?), > even after I called them (at my expense) giving them a detailed bug > report in November. > 'fraid Mr. Almy has some points. I had a go 'round with Zortech here a while back that included: 1. Rec'v'ng a compiler that didn't work. 2. No response to my initial phone call (for about a month+) Once I got through to the powers that care, they fell all over themselves getting me the current version. (I FAXed them a vulgar message outlining my problems in explicit terms.) >Is $100 for a compiler that doesn't work a good buy? Even if written by >a talented person? No, which was my point in my original message. Zortech has a may have a good product, and they may have enthusiastic people, but their distribution methods....well.... -- Joe Maybee | "In a way ...tektronix!pogo!maybee (503)-685-3572 | It was fun Tektronix, Inc., P.O. Box 1000, MS 63-356 | Not to see Mount Fuji _ Wilsonville, OR 97070 | In the foggy rain" --- Basho
grabhorn@marlin.NOSC.MIL (Steven W. Grabhorn) (01/10/89)
Excuse me, But what is the difference between "c" and "c++"??? Why would it be more difficult to write a compiler for C++? Sorry if someone asked this question before and I missed it. Steve Grabhorn Naval Ocean Systems Center San Diego, CA grabhorn@nosc.mil
jima@hplsla.HP.COM (Jim Adcock) (01/12/89)
> Excuse me, > But what is the difference between "c" and "c++"??? > Why would it be more difficult to write a compiler for C++? > > Sorry if someone asked this question before and I missed it. I think a lot of people have been saying that a c++ compiler is a lot more difficult beast than a c compiler, but I'm not sure that's true. For example, Tiemann is building g++ on gcc, and I believe the vast majority of the code is still in common, though Tiemann &| Stallman would be the right people to answer that. Things that a c++ compiler has to worry about that might be in addition to what you'd find in a c compiler includes inheritence, multiple inheritence, inlining, parameterized classes, how to map c++ naming conventions onto traditional linkers, how to unmap those names in order to allow debuggers to use c++ naming conventions.... Also optimization is probably a bigger deal in c++ compilers, but one would hope even c programmers are working with good optimizing compilers nowadays. Still, I bet you'd find that going from say gcc to g++ represents only modifying/adding 10-20% more code.
schmidt@siam.ics.uci.edu (Doug Schmidt) (01/12/89)
In article <6590084@hplsla.HP.COM> jima@hplsla.HP.COM (Jim Adcock) writes: >> Excuse me, >> But what is the difference between "c" and "c++"??? >> Why would it be more difficult to write a compiler for C++? >> >> Sorry if someone asked this question before and I missed it. > >I think a lot of people have been saying that a c++ compiler >is a lot more difficult beast than a c compiler, but I'm not >sure that's true. (Let me know when yours is finished, so I can test it! ;-) ;-) ) >For example, Tiemann is building g++ on gcc, and I believe the >vast majority of the code is still in common, though Tiemann &| >Stallman would be the right people to answer that. > After spending lots of time generating bug reports for GNU g++, I'd say that there are several areas where writing a fully-functional C++ compiler is *substantially* more difficult than writing a ``regular'' C compiler. Here are two examples that stand out in my mind: 1. The C++ grammar is inherently ambiguous (read the g++.texinfo description for detail about this). This means that traditional UNIX tools, like YACC (or in g++'s case, BISON, using bison.simple), are going to have problems with certain portions of C++ syntax. In order to properly parse the language, you are likely to need a recursive-descent parser with lookahead capabilities, and some heuristics. This approach is more tedious, error prone, and non-extensible. Even cfront doesn't always get it right. For example, try the following valid C program with cfront 1.2.1: ---------------------------------------- main ( ) { int A[10][10]; int (*B)[10] = A; } ---------------------------------------- I get: ---------------------------------------- CC test.c: "test.c", line 3: error: B is undefined 1 error ---------------------------------------- I suspect that cfront is parsing this as an indirect function call, with a return value cast as an int, through what it believes is a pointer to a function, i.e., B. Certain legal constructs in the C++ language are simply not included in GNU g++, for this reason (e.g., old-style C function definitions). If you want more information on this, read S.B. Lippman and B.E. Moo's excellent description in ``C++: From Research to Practice,'' from the 1988 USENIX C++ Workshop Proceedings. The following is a particularly apt quote from that article: Maintaining the old-style C syntax is likely to be the design choice for which Stroustrup's name will be most taken in vain by compiler writers to come! (page 128) 2. Certain areas of the C++ language definition are vaguely defined. As any software engineer will tell you, it is difficult, if not impossible, to write a ``correct'' implementation from an incomplete or inconsistent specification. As any regular reader of this newsgroup will attest, there are numerous questions posted here which do not appear to have simple and direct answers from immediately accessible language reference guides (for example, I've not seen a reply to the recent posting regarding inheritance of base constructors in derived classes). This is not really a criticism of C++, since it is still an experimental language and the designers are being careful not to prematurely overcommit to constructs that may return to haunt them. However, it is certainly a factor that greatly increases the complexity of writing a compiler for the language. Doug -- schmidt@ics.uci.edu (ARPA) | Per me si va nella citta' dolente. office: (714) 856-4043 | Per me si va nell'eterno dolore. | Per me si va tra la perduta gente. | Lasciate ogni speranza o voi ch'entrate.
mball@cod.NOSC.MIL (Michael S. Ball) (01/12/89)
In article <6590084@hplsla.HP.COM> jima@hplsla.HP.COM (Jim Adcock) writes: >> Excuse me, >I think a lot of people have been saying that a c++ compiler >is a lot more difficult beast than a c compiler, but I'm not >sure that's true. Having written a C++ compiler, without leaving out some of the hard parts like G++ does, I can say that the front end is considerably more complex than a C front end. The optimizer and code generator, of course, stay about the same. By actual object code measurements the front end is about 3 times the size of a C front end. By experience it is a lot harder to get right. There are many subtleties which are not at once apparent, especially if you want to generate good code. Adding multiple inheritance and some of the other 2.0 features increases the complexity still further. Michael S. Ball TauMetric Corporation 1094 Cudahy Pl. Ste 302 San Diego, CA 92110 (619)275-6381