Jump to content

Home

Non-Interferance & Multi-Duel (Enhanced Add)


Marker0077

Recommended Posts

Half-Life was not based on Quake 1 or Quake 2, it was inbetween the 2 actually. Quake 2 was around the time of being released when they started on Half-Life, so I'm not exactly sure why they chose that version of Quake to base it on but that's what I read, it's based on an inbetween version of the 2.

Link to comment
Share on other sites

Technically, it started on Quake, but they made many of the same changes to it that id did for Quake II.

 

razorace, which isn't what you've heard? The run-time polymorphism? It's simple. Polymorphism is overloading things like operators, functions, etc. It's slow because it has to figure out what to call or use at the run time, each time. For example (very simple), if you have:

 

void foo(int A, int B, int C)
{
   ...
}

void foo(string A, string B, string C)
{
   ...
}

for(int I = 0; I < 1000000; I++)
{
   static string A, B, C;
   foo(A, B, C);
}

 

Each time you have foo(A, B, C); it has to figure out which function to call, every time, for every iteration of that loop. It's not a big deal with that example, but when you start to have a ton of classes, virtual functions and all that, it starts to get slow, and it starts to matter in games, where everything is real-time.

 

GameDev.net has a good article on it here.

Link to comment
Share on other sites

Emon,

 

void foo(int A, int B, int C)

{

...

}

 

void foo(string A, string B, string C)

{

...

}

 

for(int I = 0; I < 1000000; I++)

{

static string A, B, C;

foo(A, B, C);

}

 

This example you've used above is an example of polymorphism, but it's not the kind that will cause run-time slowdown.

 

What you've shown is how functions can be differentiated not only by their name, but also by their parameter types. The compiler will effectively treat each function seperately - and compile them seperately. i.e. no run-time slowdown when compared with the C equivalent. (which would be just a function with a different name)

 

The example used in the tutorial, however, is valid. The tutorial shows polymorphism as it relates to functions being overloaded by inherated classes. THis does require vtables, and as such, this would require extra run-time to work out exactly which function needs to be called.

 

...but let's make it clear - a vtable is just a list - nothing more. And unless your class structure is hideously tall, the time taken to traverse the vtable each time COULD be considred negligable -although I accept this depends on how 'real-time' the task is.

 

I would say the example used in the tutorial - while valid - is a little extreme. It would be a VERY tricky task to ALWAYS single out loops which you can be sure will only EVER be passed one particular object type...

 

So yes - C++ .vs C is a balance between maintainable code and squeezing absolutely every single cycle you can out of the resulting compiled code... (exactly the same as C vs. assembler)

 

I would argue that - depending on what 'level' of the code your working on, the benifits of OOP would far outweigh any performance decreases (in fact, I'm not sure in many cases if you would even notice them) - but without knowing all the details of the specific tasks, you can only guess - so...

 

One thing for sure is that HL used C++ - at least for the moddable parts. And I don't know of HL being a notoriously slow engine because of it...

Link to comment
Share on other sites

Well, HL is an old game. It wouldn't be as noticable on today's computers.

 

So you would have to compare HL's performance to a similar game from the same time.

What I'm saying is - when HL first came out - were people saying 'Wow - this is slow as hell compared to the other © games around...?' - ermm - not that I'm aware of...

 

And even IF there was a performance issue, how could you be sure which areas of slowdown were being caused by C vs. C++, as opposed to any number of other factors...

 

...anyway - I guess this is off-topic now - so I won't labour the OOP vs. procedural debate. (Believe me - I've had this type of discussion a lot...!)

Link to comment
Share on other sites

  • 3 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...