Friday, January 7, 2011

Virtuals don't kill performance, people do.

This post is in response to Scott Graham's blog entry on a Data-Oriented C.

There are two areas where we come up short in regards to the use of data oriented programming, tools and (more importantly, IMO) education.

C++ gets a bad rap for enabling poor programming techniques but in the end the language isn't inserting virtuals on our behalf. Evangelism I think is the key here. People need to see the kind of code in action, beyond hand-wavey snippets included in blogs. Books need to be written. School curricula need to be updated to show these techniques to students. There is an entire industry centred around preaching the use of OO patterns and the result is that people finish university thinking that Cats are Animals are Objects and they all need Update methods.

To make the default decision be the correct one it would mean having to make incorrect choices either impossible (preferable) or extremely painful. I think, in that case, that perhaps C isn't the best choice of language as a base for this type of programming. Perhaps a shader-type language, something that is extremely restricted in terms of what the programmer can do outside of his own local task context and ideally removes the task of management of data (memory allocation, etc.) from the actual computation. A language that can be retargeted to asymmetric environments like SPUs or GPUs and operate well within the inherent restrictions that accompany them would be extremely beneficial with the new processors that are entering the market.

No comments:

Post a Comment