Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!mailrus!tut.cis.ohio-state.edu!rutgers!mcnc!thorin!tlab1!leech From: leech@tlab1.cs.unc.edu (Jonathan Leech) Newsgroups: comp.lang.c++ Subject: Re: Objective-C vs C++ Message-ID: <4988@thorin.cs.unc.edu> Date: 1 Nov 88 17:46:31 GMT References: <8335@nlm-mcs.arpa> <3438@jpl-devvax.JPL.NASA.GOV> <8375@alice.UUCP> <913@taux01.UUCP> Sender: news@thorin.cs.unc.edu Reply-To: leech@tlab1.UUCP (Jonathan Leech) Organization: University Of North Carolina, Chapel Hill Lines: 50 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <913@taux01.UUCP> cjosta@taux01.UUCP (Jonathan Sweedler) writes: >In article <8375@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: >> A good C++ programmer can convert about 1,000 lines of >> old C an hour to C++. Converting ANSI C should be faster. >Yeah, right. An then how about debugging? The whole point about >*compatability* is that you don't have to do this conversion that >is NEVER as easy as it seems. And what do you mean by "good" C++ >programmer? Certainly not the same programmer that learned C++ >"in a day or less." Everything looks good in the best-case light. >I don't think things are as easy in real life. Just as a point of reference: I recently converted a screen editor which I maintain to be compilable under both C++ and C. It was ~25000 lines of C code, not very well designed, but highly portable. It took about 2 days. The major problems I encountered were: - lack of function prototypes. I modified lint to generate prototypes (these modifications should be on comp.sources.unix soon). - Old-C style declarations of formal arguments which cfront handled incorrectly. There were a few dozen of these and they were annoying to fix, but it is a cfront problem, not C++. - Functions that use unportable argument-passing conventions e.g. the old classic (written before varargs existed): int error(str, a1, a2, a3, a4, a5) char *str; { fprintf(stderr, str, a1, a2, a3, a4, a5); } the problem here was a clash between the C++ prototype required for such functions to be used as desired: extern int error(char * ...) and the actual declaration. Debugging time for the C++ version (after making it compile) was 0. It worked right off the bat. C++ uncovered some potential portability problems I had not seen with lint. True, I'd never encountered these problems on machines ranging from PCs to DG Eclipse to VAX/VMS etc... but I appreciated finding them anyway. I would be happier if AT&T fixed the annoying little cfront bugs and provided some way to not need prototypes so large, complex C programs could be more easily converted, but the amount of effort involved in this conversion was not unreasonable. -- Jon Leech (leech@cs.unc.edu) __@/ ``The law of gravitation is different from many of the others... there are many places where gravity has its practical applications as far as the Universe is concerned.'' - R. P. Feynman, _The Character of Physical Law_