Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C and C++ --- NPS

Author: David Rasmussen

Date: 03:32:57 12/25/02

Go up one level in this thread


On December 24, 2002 at 11:11:38, Vincent Diepeveen wrote:

>On December 24, 2002 at 05:29:47, David Rasmussen wrote:
>
>It's very trivial that when you use high level language
>constructions in c++ that it is way slower than C.
>

No...

>on the other hand it is possible to write a kind of C a look
>like c++ which is trivially having the same speed like C.
>
>I do not understand why people argue about that.
>

Argue about what?

>No C++ isn't faster. No C++ doesn't need to be slower. It's
>basically the same language with c++ having a few constructions
>that enable OO programming which are high level and very dead
>slow to use.
>

Now you're showing your enourmous ignorance again. Don't embarrass yourself
again.

>The average student for example doesn't realize that object
>allocation is very expensive and that things like overloading
>inheritance and all kind of cool c++ constructions are dead slow.
>

Mmm. Too late to stop the embarrassment I guess...
Object allocation on the heap doesn't cost more than malloc in C. If you have a
constructor doing things you would do anyway after mallocing, they will of
course cost the same. Object "allocation" on the stack (local variables) costs
nothing more than local variables in C. It is done the same way. Stack frames
etc. Again if you have a constructor doing things you would do anyway, it costs
the same.
Overloading costs nothing, it's a compile time construct and is resolved at
compile/link time.
Inheritance costs nothing, it too is a compile/link time issue.
You know nothing about C++, do you? I didn't think so.

>The more you use of them the slower it gets. A factor 3 will be
>not exceptional.
>

LOL!!

>But the average neat written code is by definition a lot slower
>than code written for speed.
>

By definition?! LOL!!
Your ignorance isn't embarrasing anymore, now it's just funny.

>I was now looking to some other products, nothing to do with chess
>at the source code of some code which, written in C, and in total
>around 2.5MB of source code for that part of the functionality.
>
>Very neatly written C code. Very good readable.
>
>Written for speed. Indeed it is using a lot of clever tables.
>
>But a good C hacker will replace so many stuff with pointers
>and it'll get at least 50% faster.
>
>Same is true for C++. An excellent C program written for speed
>is of course times faster than C++ code that uses typical C++
>constructions and is not written for speed.
>
>I do not see the problem here. This is a logical thing.
>

OK, now it's not funny anymore. Now it's tragic.

>I had to chose between writing my GUI functionality (database and such)
>in C or C++ before i started. Initially i wanted to start it in C++
>but in the end i figured out that speed for a chess database is not
>unimportant so i wrote it in C.
>

If there was a speed difference for that kind of application, it just goes to
show how bad you are at C++ programming, or at programming in general.

>But i could of course have done it in C++ as well. In fact if i change
>the extension of the code from *.c to *.cpp then it pretty quickly
>is c++ code already, the nearly same code being both C and C++. Says
>enough to me about speed differences.
>

C++ has nothing to do with extensions, Vincent...

Please don't post more of this nonsense, Vincent.

/David



This page took 0.14 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

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