Jump to content
  • Advertisement
Sign in to follow this  
Sagar_Indurkhya

Having trouble with OOP speed!

This topic is 5408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I am developing a chess engine in C++, and the program is completely object-oriented. I have noticed that many others have written their programs in C. How much does my oop design slow down my program?

Share this post


Link to post
Share on other sites
Advertisement
Very little. Don't worry about it at all.
For every function call, you have the overhead of one extra parameter (this). Virtual functions give you an additional pointer dereference (or 2, I can't quite remember).

But the whole point in OOP is not about speed, its about making your code readable, and easy to maintain.

Just don't worry about the speed unless it becomes a major issue (and if thats the case then your design is probably flawed)

Share this post


Link to post
Share on other sites
Quote:
Original post by Sagar_Indurkhya
Hi. I am developing a chess engine in C++, and the program is completely object-oriented. I have noticed that many others have written their programs in C. How much does my oop design slow down my program?

You should worry about it, just not yet.
Just try to design for speed, consider using bitboards for example, but don't switch languages because of it.
Sooner later you're gonna end up with a dozen functions or so that really needs optimization while other 95% is completely irrelevant. Spend your time on these and write the rest for readability.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You might actually benefit from using OOP (speedwise) if it helps you organizing your general problem solving algorithm.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!