Path: chuka.playstation.co.uk!news From: gil@snsys.com (Gil Jaysmith) Newsgroups: scea.yaroze.freetalk Subject: Re: object-oriented support? Date: Thu, 24 Jul 1997 10:53:28 GMT Organization: SN Systems Lines: 61 Message-ID: <5r7c25$5na47@chuka.playstation.co.uk> References: <33b69d9c.138132316@news.scea.sony.com> <5p81kr$fv57@chuka.playstation.co.uk> <33D702CE.22A9@hubcap.clemson.edu> Reply-To: gil@snsys.com NNTP-Posting-Host: gil.snsys.com X-Newsreader: Forte Free Agent 1.0.82 "Michael C. Lee, Jr." wrote: >DONT USE C++!! >Too much overhead. >Trust me. Trust me, squire, what you learnt in school doesn't cover half the interesting optimisations you can make in C++. Sometimes you need compiler support, sometimes you don't. To give one compiler-specific example, GNU C++ supports an extension declaring the return object to be a local variable. In other words, the compiler avoids creating a temporary for transferring back the result. More generally, the sensible use of references also avoids temporary object creation. (Which is of course why references exist :) Anyway, for efficiency's sake constructors should do the minimum amount of work, since they can't return a result code. (The only result code you'll get is from the 'new' operator, if that's how you created your object.) If you need a temporary object, use an empty constructor, and fill in the bits you need only when you need them. The 'real' data construction can be handled by an Init method or suchlike. Making your constructors and destructors inline will add to their speed; frequent function calls cause the problematic overhead. For an educational experience which amongst other things demonstrates how to second-guess the compiler (not that a few small tests won't show up how to take advantage of your particular compiler's ideas about code generation) you could take a look at Ellis/Stroustrup's "The Annotated C++ Reference Manual" (Addison Wesley, ISBN 0-201-51459-1). (This, like Stroustrup's other C++ book, is also a useful book to read if you're at all in need of humility concerning your programming ability, since Stroustrup is one of those people who talks of month-long programming projects as 'exercises for the reader' and 'useful scaffolding which can be implemented without difficulty'. ARGH!!!) Also, trust me (again!), the overhead of using C++ for your game manipulation is trivial compared to the overhead of using inefficient graphics routines and bulk data processing code - which you lucky Yaroze programmers are condemned to do because of the absence of documented GTE library support. Most gameswriters would rather have 95% of their code running 5% less efficiently than face inordinate hassles trying to organise 100% of their code without the structural advantages and improved clarity of expression which C++ offers. There are several games out there written in C++, and I'm certainly getting far more support calls for C++ compared to, say, six months back, and could name half a dozen C++ games due out in the next few months. It isn't just me bangin' away about C++ being handy! Incidentally, half of "Crash Bandicoot" is written in LISP. What did your school test say about LISP's efficiency? :=) Gil Jaysmith SN Systems Software Ltd, makers of Psy-Q... http://www.snsys.com Disclaimer: What I say when I post here represents me, not my employers.