What does OOP stand for?
When Object Oriented Programming(OOP) is taught so extensively, do computer programmers, specifically within games development, realise what it's possibly doing to productivity and performance? I explain my own view from experience in personal projects and professional work.
This talk was given to the Edinburgh meet of IGDA Scotland, on 2011/07/27.
26. More examples I retweeted a talk that Jonathan Blow of Braid fame gave to Berkeleys compsci group. He mentioned that he now does pretty much everything in simple flat arrays, no complicated data structures.
27.
28.
29. Need a system for handling the states of your things?
30. That does not mean you need a massive component system that is scalable and can handle any matter of things and things v2.0 and things v3.0
50. So what can OOP stand for? O OP O bliterates P erformance OOP (in high data throughput cases, which there are many in games) is basically
51.
52. struct Details { int numShots; int numDeaths; int numTargets; int lifetime; int state; int priority; int health; int ammo; int friendThings[4]; }; // 48 bytes class Thing { Vector3 mPosition; Quat mOrientation; Colour mColour; Vector3 mVelocity; float mDecay; Details mDetails; }; // 96 bytes
53. OOP ish class ThingSystem { String mName; std::vector<Thing> mThings; .... }; void Thing :: UpdatePosition () { mPosition += mVelocity; mVelocity *= mDecay; } void ThingSystem :: UpdateThingPositions () { for( vector <int>:: iterator iter = mThings. begin (); iter != mThings. end (); iter++) { *iter. UpdatePosition (); } }
ALTDEVBLOGADAY ROUTE 2 INDUSTRY – MODS, PERSONAL PROJECTS & GAMES HARDWARE BASED UNI PROJECT
METHODS SIMPLIFIED FOR EASE
Go to next slide
Go to next slide
Go to next slide
Go to next slide
Go to next slide
Go to next slide
It even has an IsSingleton()!
Go to next slide
Go to next slide
Go to next slide
Go to next slide
Go to next slide
Go to next slide
Jonathan: “Data Structures are Optimization”
Extra example: ProjectRaceway xna entity system Deleted it after a year Track cells now have a typed, flat list of entities within it So much simpler to debug and keep track of.
This is basically what is taught.
Code data transform
encapsulation
Old diagram Possibly seen before.
STACK THE DATA
SIMD
Perf difference
Ideal example; cache already fetching ‘next’ block of 512 bytes. Void is idle cpu.
Don’t over engineer your code. Know the problem areas. [Edit: I forgot to remove the swearing from this slide in the given talk!]
Profiling important
You can make an ‘OOP looking’ codebase but behind the scenes it uses nice flat data structures, if OOP is essential.
[Edit: completely failed at trying to start this, had more luck before the talk was given! Twitter being awesome still stands, though]