Jump to content
  • Advertisement


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

Functional vs OOP principals in game development

This topic is 5974 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 All: I''m looking for any information/comparisions/raw data you might have with regards to using functional vs object oriented design methodologies with respect to game programming (and more specifically c vs c++). ie: The standard response I seem to hear when someone suggests C++ for game development is "Too Slow!". Id love to have some hard data to refute this (seemingly nieve) point (or prove it :-) ). Along with this goes code size, ease of implementation, etc. I realize this is a very broad question - I dont see there being a definte answer. Im sure looking for general information. I''m sure this has been debated here before, although I checked old threads and didnt have much luck finding anything (Im always wary of posting a "X vs Y" thread, as they are the bane of other ng''s i frequent :-P ). If there are other resources, feel free to point me to them . I did find a few papers in the "Articles and Resources" section - anything similar to that would be much appreciated. Thanks :-)

Share this post

Link to post
Share on other sites
The answer to your question is extremely simple. There is no implicit difference between c and c++. Functional does not mean something is not object oriented. As far as speed goes, when you are doing...

normalize( vector* v)

they are the same thing, except in the first v is passed on the stack, and in the second v is passed in ecx. This has very little speed difference. Benchmark it if you like. If you are concerned about speed, declare the function as fastcall and it will have its arguments in registers too.

As far as virtual methods go, there is no inherent difference between those and functions. If you need virtual functionality, chance are you would need to use a function pointer or array of function pointers anyhow.

is the same as

Please stop arguing over the differences between functional and object oriented, and c and c++ approaches. It all depends on how you design your project, the language or syntax makes no difference.

Share this post

Link to post
Share on other sites
What Dog_Food said.

A quick note though... when you say "functional" languages (I assume you''re talking about languages like C, given the context), you probably mean to say "procedural" instead. Functional languages (like Lisp, Scheme, Haskell, etc) are ones that perform operations purely in terms of raw expression-based functions, and are very different from "imperative" languages (like C, C++, Pascal, etc) which are based on control flow over a series of statements. The term "procedural" is a better counterpoint to "object-oriented" when discussing C and C++.

This is not intended as a jab, BTW. I was making the same mistake in terminology myself until only a couple years ago (some of my old articles still say "functional" in them... oops

Also, C++ is still not entirely object-oriented; it''s still statically typed and largely procedural in nature, but with some object-oriented support thrown in. If you want a different flavor of object-oriented for contrast, look at Smalltalk (and I''m not saying we should be programming games in Smalltalk anytime soon, I''m just pointing the language out for reference).

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!