Path: chuka.playstation.co.uk!news From: gil@snsys.com (Gil Jaysmith) Newsgroups: scea.yaroze.freetalk Subject: Re: C versus C++ Date: Fri, 09 Jan 1998 11:47:12 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 94 Message-ID: <34b60720.835391@www-s.playstation.co.uk> References: <34b54e3d.9156136@news.scea.sony.com> NNTP-Posting-Host: trish.snsys.com X-Newsreader: Forte Free Agent 1.11/32.235 On Thu, 08 Jan 1998 23:34:09 GMT, matth@bellatlantic.net (Matthew Hulett) wrote: > I suppose what really gets me curious for your opinions is that Gil >was defending the language up above, and then he said later on in a >little reply to me, ".And it's still the GNU compiler, but you can use >C++. If you're mad." Now, c'mon, you can't have it both ways!!! LOL! Okay, I'll clarify what I mean. First you have to bear in mind that I amn't a Yaroze or PSX programmer myself. My perspective is from the SN support and tool-development desk, and so I tend to get feedback from the pro developers about the various languages and tools, and try to do something helpful about it. We write our PC-hosted dev tools in C++, because it aids team development and compartmentalised design. We have an IDE coming out shortly which is being worked on by eight people. I strongly doubt this would be as straightforward as it's proving were it not for C++ - or rather, for the concept of classes and interfaces. We could do it in Java for that matter. The important thing is that C doesn't have any formal mechanisms for making sure your project remains reasonably streamlined and cohesive while several programmers are working on different modules. You have to work at it. It's possible, and most games programmers are familiar enough with C to make it work adequately. But C++ simply makes it easier. On the PSX I know of perhaps a dozen companies using C++. The reason for much of this use is that PC games are being ported to PSX and the language of choice for PC games developed under Windows is C++. Microsoft has worked hard making its implementation of C++ fairly rigorous, extending it and ignoring the delays of the ANSI committee, perhaps causing trouble for itself later on, but nonetheless supplying all its customers with a solid C++ compiler now, as opposed to some years in the future. However, the GNU compiler everyone uses for C++ on PSX is neither as stable nor as powerful as VC++. I know it works because there are people using it. I also know that there are people using it who don't like being made to use it, and who feel there are speed problems which are unacceptable in an embedded system. This point of view isn't restricted to console programming; there's now something called Embedded C++ which attempts to strip out the unimportant bulk of C++ to make it more efficient for embedded systems of any kind. The argument on here a while ago about C++ boiled down to: is C++ *always* inefficient and thus simply the wrong choice, or is the slight loss of efficiency worth the gain to developers in making projects run smoothly, and in some cases run at all? There are plenty of cases of games, applications, whatever, on many chips, being designed and half-implemented in C, and then abandoned because the program's complexity was running out of control. My view is that C++ will help you control this problem, but you need to display due care and attention when designing and writing a game in C++, so as not to fall prey to the inefficiencies which the compiler will insert for you if you let it. If you don't let the compiler make assumptions which involve extra temporary variables, lots of class member calls, and horrible convolved operations to call virtual functions, then you can get C++ code which runs *almost* as fast as C - and will be more easily tweaked at points where the C code would become "something we don't mess with in case it breaks". (I don't believe in having code which "works, but no-one really understands how". It's an offence against design and more seriously an offence against common sense; if you don't know how it works, how can you be *sure* it works? A million examples aren't enough.) Some years ago the argument was about the tradeoff between C and assembly language. To put it bluntly, assembly language lost: C compilers which had been poor were suddenly capable of out-optimising human beings. The issue is now whether good C code is ruined when rewritten as good C++ code. And I think it'd be difficult at first, and perhaps impossible for some people, but that C++ is certainly a viable option, and probably the one I'd choose. All of which might seem like a longwinded way to explain what is probably now obvious, that my comment "if you're mad" was somewhat flippant... but I thought you ought to know the background... > So please, if you could, why should the aspiring developer learn >or ignore C++? You should always learn everything, is my opinion. Or at least you should learn meta-programming: learning a language in terms of its concepts, without stressing yourself out too much about the fact that it's specifically 'C++' or 'Java', will mean that other languages can be understood that much more readily. The context of a new language may help you to see how to implement more efficiently in an old one, or make you suddenly understand why a particular language feature is regarded as evil by other programmers. (For example, Java is the logical conclusion of the argument to remove the C preprocessor.) So now you know... - Gil