Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!bs From: bs@alice.UucP (Bjarne Stroustrup) Newsgroups: net.lang Subject: C++ available (C++ and Modula-2) Message-ID: <4487@alice.UUCP> Date: Sat, 26-Oct-85 21:50:12 EST Article-I.D.: alice.4487 Posted: Sat Oct 26 21:50:12 1985 Date-Received: Sun, 27-Oct-85 02:26:38 EST Organization: Bell Labs, Murray Hill Lines: 64 > From: rmarti@sun.uucp (Bob Marti) > Subject: Re: C++ available > > In message <4478@alice.UUCP>, Bjarne Stroustrup (AT&T Bell Labs) writes: > C++ is C with a few problems fixed: > - function argument type checking and type conversion > - scoped & typed constants (alternative to #define) > - inline functions (alternative to #define) > - etc. > > This is really interesting! When talking to UNIX/C hackers I always got the > impression that the practically non-existent type checking in C was a > blessing rather than a problem ... Type checking becomes a disaster if it prevents you from writing resonable programs. For example, if you cannot pass a pointer to a vector of function pointers, or a zero terminated list of pointer arguments you are in trouble. Naturally, C++ has ways for you to specify this, and also ways of declaring old favorites like printf and fprintf. It is important to note that arguments are not only checked, but also coerced if necessary. For example, in a call sqrt(2) the int 2 will be implicitly converted into the required double 2.0 excatly as in an initialization. > With constants, enumerations (not in K&R!), function argument checking, etc., > C's "successor" C++ all of a sudden looks awfully similar to Modula-2, which > most UNIX/C hackers tell me is absolutely useless. Never mind that most of > these people have never bothered to look into a Modula-2 book, or have even > done some Modula-2 programming to the tune of several thousand lines of code. I can assure you that C++ does not look like Modula2. Until you start using the facilities for data abstraction and object oriented programming it looks like C. I personally do not like Modula2, had it appeared as Pascal2 in 1978, it would have been a much more interesting language, and would now be ready for a second major revison. One reason for not reading Modula2 books is that there is none of K&R quality (at least there wasn't one this spring when I last read one). C enumerators are simply integer constants, and does not behave like Pascal enumerated types. In my opinion, it was a mistake to call them enums in the first place. Re. "all of a sudden": The C++ argument typechecking rules were described in S-P&E Jan83, and in greater detail in the special UNIX issue of the BLTJ Oct84. > --Bob Marti, {decvax, ucbvax, seismo}!sun!rmarti > Disclaimer: > I have not looked much into C++, but I'd like to emphasize that from what I > have heard so far, it makes a lot of sense to me. I do know "vanilla" C > however, and -- having done some serious programming in both Modula-2 and C -- > I much prefer the former. You did not comment on the second part of the C++ "feature list": C++ provides a facility for user-defined types: - Simula-like single-inheritance class concept - data hiding - operator overloading - (optional) guaranteed user-defined initialization and cleanup - user-defined type conversion It does indeed support a form of dynamic typing (virtual functions). This is were 95% of the work in designing C++ went and where C++ differ significantly from languages like C and Modula2.