Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C++ slow?

Author: James Swafford

Date: 12:28:43 07/02/99

Go up one level in this thread


On July 02, 1999 at 15:07:33, Sven Reichard wrote:

>In a recent thread it was stated that current Basic compilers produce code that
>is "slightly faster than C (and a lot faster than C++)".
>Could someone point out to me why C++ per se is slow? I had programmed in C for
>a while before learning C++, and I didn't detect any significant differences in
>performance. However, with C++ I spent more time designing and less time
>debugging (which makes it preferable to me :) ).
>I recently started implementing a generic engine for two person zero sum games
>(in C++). I would like to know if it is worth the effort, or if the language
>slows it down too much.
>
>Thanks,
>Sven.


I don't think C++ *has* to be any slower.  If you unwisely
create and destroy large objects in time critical places,
you'll get killed.

One of the really neat advantages to an object oriented language
is the ability to do more error checking (as you mentioned above).
Instead of saying " somestructure.i = j; "  you can do something like:
"SomeObject.SetI(j);" , where the 'SetI()' member function may have
extra code for boundary checking, etc.  This can also slow you
down in time critical places.  (Of course, this same code can be
called in C, but let's face it... )

I once asked the same question myself, though.  Then I learned
that Junior is a C++ program, and put all doubts aside. :-)

--
James




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.