Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!hsdndev!cmcl2!acf5!sabbagh From: sabbagh@acf5.NYU.EDU (sabbagh) Newsgroups: comp.object Subject: Re: whining about C++ (was Re: Documenting OO Systems) Keywords: operators Message-ID: <1563@acf5.NYU.EDU> Date: 28 Mar 91 15:42:07 GMT References: <299@orbit.gtephx.UUCP> <1991Mar25.145441.1@happy.colorado.edu> <20106@alice.att.com> <3481@engadm3.csd.mot.com> <1991Mar26.191259.14470@i88.isc.com> <4693@osc.COM> <21 Organization: New York University Lines: 71 reinhard@samsung.com (Steven Reinhardt) writes: >In article <4693@osc.COM> jgk@osc.COM (Joe Keane) writes: >>One thing i like about C is that when you type something you know what it's >>going to do. There are some catches, like operator precedence isn't what it >>should be in some cases. But in general when you say `a = b', you're pretty >>sure what the compiler's going to do with this. >> >>I wish i could say the same thing about C++, but i'm afraid this is one of the >>big differences between the two languages. There are a number of causes, >>including inline functions, virtual inheritance, invisible copy constructors, >>and i'm sure there are more. The end result is that when you say `a = b', you >>have no idea what the compiler is actually going to put there. >> >A hearty "amen" to that. Having just completed a serious project >in C++, and having been fortunate enough to learn object-oriented >programming before learning C++, I found the language frustrating >for exactly this reason. In C, if you can conceive it, you can >do it, with few exceptions. It can get ugly, but C is so close to >machine language that when you type something, you know exactly >what it's going to do. Really? Aren't we confusing complexity with experience? I bet both Mr. Reihardt and Mr. Keane have several _years_ experience with C; I have about 10 and I'm below average in this respect. That amount of experience means that I can "think" in C. I know the computer model by heart. OTOH, I bet that most people have less than 5 years experience with C++. Learning a computer language is similar to learning a human language. There comes a time when you stop thinking about all the underlying semantics becuase you understand it well. This will happen with C++ as well. In a way, it was a mistake to make C++ look so much like C because 1) it is nothing like C and 2) this will steepen the learning curve. Also, I like to imagine the mind-set of the creators of any language. I envision Dr. Stroustrup sitting in his office saying: "gee whiz, to really create nice, maintainable code in C, I write lots and lots of lines that look like THIS ..." -- and that's how C++ is born. Sure, a lot is going on, but YOU WOULD HAVE TO WRITE ALL THAT STUFF IN C ANYWAY TO ACHIEVE THE SAME EFFECT. Well, maybe not all but that's the price of using compiled languages in general. Let me elaborate. A line-by-line comparison between C and C++ is moot; C++ is at a higher stage of evolution than C, just as C is at a higher stage than assembler. It is best to make program by program comparisons, i.e., "I have to write a program to do so-and-so" then comparing line counts in C and C++. Other things should be compared as well: implementation time (from analysis to executing code), ease of explanation to other programmers, maintainability, and so on. Learning object-oriented programming principles in any language does not really help learn the nitty-gritty details of another language. Each has its quirks, idioms, and model of the underlying computer. This part of learning a language is extremely frustrating, as there is only one way to learn it, namely, by writing lots of code. Finally, I advocate knowing several languages and picking the best one for the task. I have greatest experience with C, FORTRAN, Forth and C++ (in that order). For my thesis, I am using the last three, each for different parts. Yes, Virginia, there is a time when one prefers FORTRAN to C++. Hadil G. Sabbagh E-mail: sabbagh@cs.nyu.edu Voice: (212) 998-3125 Snail: Courant Institute of Math. Sci. 251 Mercer St. New York,NY 10012 "Injustice anywhere is a threat to justice everywhere." - Martin Luther King, Jr. Disclaimer: This is not a disclaimer.