[MUD-Dev] Languages

Nathan Yospe yospe at hawaii.edu
Sat May 24 21:37:48 CEST 1997


On Fri, 23 May 1997, Chris Gray wrote:

:[Ben G:]
:
::I'm curious about some things.  What exactly makes c++ slower?  Is it
::more class calls because most ppl make accessing class data a function 
::call?	Perhaps inheritance mapping of some sort?  I head that a c++
::compiler basically just translates the code into c before compile anyway..

:The larger number of function calls (at the implementation level) is one
:of the biggest slow-downs, I think. Asside from the obvious effect of
:executing more instructions, that type of code slows modern CPUs down
:even more because it is hard on the instruction cache and on any branch
:prediction and look-ahead stuff. I don't know if there any CPUs yet that
:can successfully look-ahead through a C++ virtual function call, but I
:doubt it. That pretty well shuts off a lot of look-ahead and pipelining
:until that call has been resolved. Having lots of small functions (many
:of which don't don't actually do anything useful!) results in lots of
:instruction cache misses, resulting in execution closer to main memory
:speed rather than CPU clock speed.

A few points:

1) Unless the function has been keyworded "virtual" there is no such
question... and good coding style calls for minimization of virtuality.

2) Inlining often actually reduces the number of functions. Unfortunately,
it does on occasion (90% of the time) result in bigger executables.

3) C++ no longer benchmarks slower than C. Period. Not specialized case,
not certain machines... there are almost no venders producing C compilers
that generate code that is faster than that generated by the C++ compiler
for competant programmers on each. And I mean code generated out of C++,
not out of C in C++ clothing. Which makes the above arguments all mute.
Now... I think I've said enough. Someone scream at me if I post on the
subject again. (I really hate these sort of wars. Or something. Maybe I
just love to hate them. Please tell me I didn't just say that.)

4) C++ is a nice language to write a mud in. Muds model very well to
object oriented frameworks. At least, Physmud++ did...

   __    _   __  _   _   ,  ,  , ,  
  /_  / / ) /_  /_) / ) /| /| / /\            First Light of a Nova Dawn
 /   / / \ /_  /_) / \ /-|/ |/ /_/            Final Night of a World Gone
Nathan F. Yospe - University of Hawaii Dept of Physics - yospe at hawaii.edu

(I'm getting flashbacks on the Katrina McLelan(sp?) C/C++ flamewar on
rgma.)




More information about the mud-dev-archive mailing list