Newsgroups: comp.lang.c++ Path: utzoo!utgpu!cunews!csi.uottawa.ca!news From: hitz@sim5.csi.uottawa.ca (Martin Hitz) Subject: Re: C++ learning curve (Was: Re: Seeking critique(s) of C++) Message-ID: <1991Mar28.191513.6137@csi.uottawa.ca> Summary: That's right. Keywords: C++ learning curve Sender: hitz@csi.UOttawa.CA Nntp-Posting-Host: sim5 Organization: University of Ottawa References: <18979@milton.u.washington.edu> <1950@news.tcs.com> <19114@milton.u.washington.edu> Date: Thu, 28 Mar 91 19:15:13 GMT In article <19114@milton.u.washington.edu> jjb@hardy.u.washington.edu (Jim Black) explains why he feels C++ is hard to learn. He asks: >I'd be interested in hearing whether other participants in this group feel >that C++ has a steep learning curve, too. I must admit: Yes, at least myself. Maybe it's because my personal history seems to similar to Jim's :-), meaybe it's because of some of the following reasons: I: C++ is nice to read, but at the same time much more cryptic than C. People said that while (*s++ = *t++); was TOO complex to understand, but x = a + b; may be even more complex (especially, if something goes wrong...), because there are so many hidden things going on. Depending on the case at hand, conversion functions may be called for a or b, followed by ancall to operator+(), eventually using consrtructors for value parameters, then comes operator=() etc. Yes, it looks nice, but do see the impact at the first glance? I admit that (from a puristic point of view) it might be desireable to hide the impact, but as long as I am not the client but the producer of the classes involved, I would rather have a more explicit idea of what's going on. II: There are A LOT of semantic rules/exceptions in C++, many more than I encountered in other languages, like IF a member function is not specified THEN it will be inherited from the base class EXCEPT it is the constructor IN WHICH CASE a default constructor will be generated ... or consider the rules concerning overloaded function call resolution etc. or (that will lead me to III) the rule: IF no operator= is specified THEN memberwise assignment will take place. Now, consider struct X { int x[3]; } a, b; a[0].x = a[1].x = a[2].x = 1; b = a; What does memberwise assignment mean in this case? b.x = a.x ??? Is there such a thing as array assignment? Let's check... III (may be most important): There are still SO many bugs in the compilers... I have programmed in Pascal between 1978 and 1985 and have encountered 1 (!) compiler bug; I have been using C between 1985 and 1990 and have NOT encountered a bug, but I am able to produce an arbitrary number of bugs in C++ (at least in g++ and Zortech). For instance, after the above assignment b has the (correct) value <1,1,1> in g++, while it is still undefined with Zortech! Or: struct X { X& operator & (X &); }; main() { X x; X *y = &x; } For g++, it's okay; Zortech says something like "Line 6: 1 actual argument needed for operator &". Not funny when porting things to the PC. Even less funny, if you don't have the ARM ready to check who is right... So: I like C++ very much, but it is hard to learn. Martin Hitz (hitz@csi.UOttawa.CA)