Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 Feb 2007
Offline Last Active Yesterday, 10:09 PM

#5290185 Is it C# Territory?

Posted by Ravyne on 04 May 2016 - 08:24 PM


Your good reason is "We have hundreds of thousands of man hours invested in our giant aging C++ code base, thus we'll be keeping that around. kthxbye."


Sunk cost fallacy...


A good reason would involve comparing the expected results of the new product against the quality of the existing product to see if the value of improvement exceeds the implementation cost and risks.



Disagree with this application -- at some point its been far too long since the train left the station, the train's designer died or retired years ago (no one really knows), the conductor and engineering staff have completely turned over 5 times, and no one remembers any of the bugs that were squashed into the tracks further than about a mile back.


Its almost never a good idea to go all green-field over your existing product when the product is large and complex, and when your user-base is entrenched -- and especially when they're entrenched in your product's quirks and bugs. You want to talk about a nightmare... reaching feature-parity with a large and complex product is a nightmare -- but reaching bug-parity with the kinds of bugs people come to rely on (which, by definition, stayed around long enough to be relied upon precisely because no one could ever figure them out) is more than a nightmare, that's some Hellraiser shit right there. You know that weird for-scope bug from Visual C++ 6? The one with the option to turn it back on in every version of Visual C++ since it was fixed? There's a small set of regression tests somewhere in Microsoft that make sure no parser change or bug fix messes with that, and there's an engineer who's job includes making sure those regressions never go red. 20 years later that's still earning someone their bread, because the cost to the business is less than the cost of losing clients who can't or won't fix their code, even though its a good idea. And that's a trivial example.


Generally you would only make that kind of leap when the market forces your hand -- In recent years there's been a good deal of effort to get off of old systems written in COBOL and Fortran that very possibly run on old hardware you can't buy any more (and even repairing is difficult and costly), but mostly because there aren't any new COBOL and Fortran engineers who understand the intersection of those languages, and machines, and operating systems, and they can't persuade enough old coders to come out of retirement and into consulting -- the ones they can convince are A) billing at rates somewhere between a-charity-date-with-the-queen-of-England and who-wants-to-hunt-the-last-African-rhino, and B) are not unlikely to drift away at any moment due to death or dementia.

#5289950 Is making game with c possible?

Posted by Ravyne on 03 May 2016 - 02:46 PM

The modern pseudo-argument in favor of C is that its "more transparent" -- namespaces, and classes, and templates, and operator overloading, and virtual member functions, and overload resolution taking all of those into account, and lambdas, and exceptions, and rules of 5 and 3 and 1, and on-and-on are all compiler voodoo that some believe is too opaque to be trusted -- or, at the very least, that it short-circuits critical thinking regarding platform-level details, and sometimes that this allows lesser-skilled programmers ("undesirables") to sneak in and wreak havoc in places they are not welcome. This is the basic position that Linus Torvalds takes with Linux kernel development (unapologetically, as is his custom) -- though, there are good reasons for not wanting a mix of C and C++ in the kernel, and C is already entrenched for historical reasons.


But I don't consider that a good reason, for or against, myself. Many patterns that C++ makes easy are useful (e.g. classes, virtual member functions) in C, and can be replicated to a reasonable degree with some work -- for example, a virtual member function in C++ is basically a function pointer with a convenient syntax for declaring, defining, and calling them. C code that does this sort of thing looks different, but you can find examples of it in the Linux kernel, in Quake, and in Halo's engine.


C++ is generally more convenient and productive than C, IMHO, but there is some truth to the argument that the compiler does things behind your back, and its true that this can in some cases cause trouble. But its not terribly difficult to learn where most of the dragons are, and to guide yourself to a comfortable subset of C++ and way of speaking it that avoids them.

#5289820 Is using the Factory or Builder pattern nessesary?

Posted by Ravyne on 02 May 2016 - 08:37 PM

Yeah, that ^^ :D


Patterns should never be a play-book for writing code. Patterns are, well, patterns in code that just so happen to have been repeatedly reinvented, at which point people recognised the pattern and assigned a name to them to make discussion easier. You should look at lists of patterns more like a traveller's dictionary, and less like a cookbook.


A software engineer should strive to be comparable to a chef who writes cookbooks -- not a machine that only knows how to follow them.


I don't want to be too contrarian to this point because I don't want to undermine the strength of the general sentiment, because I agree that its closer to "correct" practice than the recipe-book alternative.


That said, I think a better approximation is that patterns are useful pre and post-mortem, so long as you treat them as ideas rather than things. As usually comes up in these discussions, there is no "The" in the Grand Book of Software Patterns -- there is no "The Visitor Pattern", no "The Factory Pattern", no "The Builder Pattern". That word "The" (with a capital-T) implies singularity -- it implies that there is one implementation to rule them all and that everyone agrees it is the best implementation for all circumstances.


We all know that this is not and cannot be true, and we have mostly all experienced solving our own problems in our own way, and later coming to realize we've done it in a way that we can recognize as one of these patterns. In this way, we've participated in the emergent definitions of these patterns.


At the same time, what makes patterns useful in post-mortem analysis and discussion is that these patterns imply general properties of the solutions and of general properties of the problems themselves. We know what a Factory does, and can surmise the rough shape of it, what its responsibilities probably are, and to roughly what problem it proved naturally useful in solving. Once we know those things, it becomes possible to work forward from the other direction -- we can say that if we have a familiar kind of problem, and if the surrounding responsibilities are like those we face now, then there's a strong chance that a solution in the shape of, say, the Factory pattern will prove a good solution. Even if it proves not to fit as well as we thought, beginning there can be useful as you think through the implications that choice would have for the rest of the code systems, which you might also think about in terms of the pattern you expect them to be shaped like. Done well, this is an effective tool for working out potential design problems before writing lots of code.


But you probably shouldn't attempt to define your whole system up front in terms of patterns; this usually doesn't scale much past textbook exercises. Even still, thinking in these terms during the design phase can help abstract away details that might be irrelevant and distract from what's necessary -- and likewise, if applied too aggressively, can obscure details that are relevant and necessary, and will go overlooked. Be wary of this. The worst happens when you are both too aggressive and too rigid in your application of patterns as design tools, which can cause you to crystallize concrete details before you have really thought them through, and have consequently allowed your design to rely upon, spreading the tendrils of your gaff beyond a simplex refactoring (the term of art for this is "painting yourself into a corner") -- "simplex", by the way, is a word you should come to know and love; its meaning is the opposite of "complex", whose own definition has roots meaning something like "to braid or blend together" -- simplex is best plex.


Further, those code systems which aren't naturally a strong fit to a pattern usually represent the greatest unknowns in your code systems -- which can be a good indicator that you should consider whether they are candidates for early prototyping. Many times these code systems turn out to be complex sorts of black-boxes and that's fine if they simply are -- games and many applications just have this kind of code in them that you can't really design until you get there. But other times it turns out that these code systems are opaque to you because it turns out that you don't understand the problem, the responsibilities, or the interactions with surrounding systems well enough to recognize the patterns or algorithms hidden inside.


Patterns are useful both before and after writing code -- just don't let them become the tail that wags the dog.

#5289466 Should i learn Win32 or UWP?(C++, Directx)

Posted by Ravyne on 30 April 2016 - 03:15 PM

The decision mostly comes down to platform support. UWP lets you reach all Windows 10 based platforms -- PCs, Xbox One, SurfaceHub, even ARM-based devices like Windows Phone and Raspberry Pi (model 2 and 3, through the Windows IoT platform). Its a single, mostly-uniform API that fairly-smoothly lets you target different devices characteristics with a single application. Its also the preferred format for the Windows Store, and its the only way you can get your app on Xbox without a bigger company backing you (FYI, UWP on Xbox One is D3D11, at least for now).

Win32 works on all versions of Windows for PCs, but isn't otherwise relevent to any devices you're likely to care about or have access to. The main benefit from a platform perspective is that Windows 7 and even Windows XP are still relevant in some parts of the world, and also in some corporate environments (mostly mid-sized companies tied down for legacy reasons, or small companies who can't afford to upgrade so frequently, and lots of small mom-and-pops who don't replace anything until it breaks.)

Honestly, you probably should learn both to at least a reasonable degree. And you probably will, even if you don't want to. But you can use the information here to decide where to invest first.

#5289359 Is inheritance evil?

Posted by Ravyne on 29 April 2016 - 07:21 PM

A good rule of thumb is to solve any problem with the least-powerful tool it can be (reasonably) solved with. Try not to think of that in a negative light -- by using the least-powerful tool, what we really mean is the one with the least unnecessary dangers attached.


There are a few general power-progressions you should try to observe:

  • Prefer composition over inheritance -- that is, use inheritance only when it supports precisely the relationship semantics you want, not for reasons of convenience.
  • Prefer interfaces (interface/implements, pure-virtual classes) over inheriting concrete classes (extends, "plain" inheritance).
  • Prefer non-member, non-friend functions over member functions, prefer member functions over non-member friend functions, prefer friend functions over friend classes, in C++.
  • Know the differences between private, protected, and public inheritance in C++, and use the appropriate one.
  • Keep things in the smallest reasonable scope.


Those are just a few examples. Being a good engineer doesn't mean being the one who smuggly wields tools of great power, confident you'll not fuck up; Its great when one can do that when they have no other reasonable choice--and you'll still fuck up--but a trait of a good engineers is that they seek out the solutions which are exposed to the minimum set of potential hazards while meeting requirements of (in mungable order) safety, performance, maintainability, usability, and ease of engineering.


Language features are not inherently evil (not even goto), but they are sometimes misapplied and the more commonly misapplied they are, or the worse the repercussions are, the worse their reputation becomes. Sometimes this is exacerbated by the way that languages are taught, as is the case with how inheritance has come to have such a poor reputation. Sometimes its exacerbated by the mistranslation of programming skills from one language to another; in general, a Java programmer (or C# programmer to a somewhat lesser degree) will *way* abuse inheritance if tasked to write C++ (and they'll probably leak memory like a sieve too  :) ).


TL;DR; Know thy tools, and program.

#5289205 RPG item system: storing definitions

Posted by Ravyne on 29 April 2016 - 01:59 AM

It somewhat depends on how homogenous the set of properties is among objects of a certain category (where category means, say, shields/chestplates/blades) -- if the properties are homogenous then each category maps well to a database table or, more simply, a spreadsheet page.

If individual objects are non-homogenous but the range of options is well-defined, then something like XML can be a good fit because it allows variance within a well-structured and verifiable format.

If individual objects are non-homogenous and the range of options is more ad-hoc (in the sense that objects might have properties that are unique to itself), then something like JSON or YAML can be a good fit; these formats are semi-structured -- that is, the grammer and parsing rules are well-defined, but there's no formal data schema like XML. For good and for bad, there's nothing stopping you from putting any data you want anywhere, so long as your program's parsing logic can cope.

#5289135 Returning by value is inevitable?

Posted by Ravyne on 28 April 2016 - 02:01 PM

Also, some compilers can have a lot of trouble in the presence of references to the point that they fail to make seemingly simple optimizations. e.g. a math function that takes two parameters as a reference can't easily tell that those parameters don't alias each other without a more complex post-inlining alias analysis pass in the optimizer and so might generate poorer code than you'd get if the parameters were passed as value types (and then preferably in registers).


Just wanted to note that this is another point in favor of that more-or-less canonical function-call signature pattern (first parameter non-const by value and to be used as return value (and hopefully in a register), second parameter by const reference) -- its trivial for the compiler to know that the arguments don't alias. The same is true of passing both arguments by value (again, hopefully in registers) as well, but if you can't or don't want to (maybe the object is too large, or is non-POD requiring a deep copy) the pattern I showed sidesteps the aliasing issue while mitigating one of the copies at least (if you can afford to pay it more attention, other signatures or techniques might do better, but the canonical pattern is effortless and a good default).



I also want to say quickly that the 'inline' keyword doesn't actually do what most people think it does -- It doesn't force the function to be inlined, and it doesn't even directly "suggest" that that the compiler should inline it (which is what most people think it does). The 'inline' keyword only exists to tell the compiler that the function is being defined inline, and to basically not complain about finding multiple definitions as it will be potentially multiple times as a result of being in a header. Having been defined inline, the function becomes more-available for the compiler to perform inlining, so its a sort-of suggestion in a kind of heuristic sense, but the 'inline' keyword is not itself an expression of intent for something to be inlined by the compiler -- many programmers believe that's what they're saying, but that's not what the compiler understands from it. "forceinline" is closer to what people think they're saying, and depending on compiler settings forceinline is not really forced, but just a suggestion.

#5289129 what is meant by Gameplay?

Posted by Ravyne on 28 April 2016 - 01:31 PM

But in my defense I wasn't trying to say it beats c++ every time I was saying it is "POSSIBLE" for a scriptinglanguage to outperform c++.


But its not possible, not even once, in a fair fight -- with the deck stacked against it, with poor C++ programming, with improper or incomplete library use, sure you can come up with micro-benchmarks that show C++ at a disadvantage -- but there are lies, damn lies, and statistics, right?. Doing the same work in C or C++ will always be as fast or faster than essentially any language, "real" or script. You might, though, have to do some work that's not readily available in the language or in common libraries, and if a technique is readily available in another language that yields more performance per effort-unit, then that's a point in favor of that language -- however, that's a productivity argument, not a performance argument.


And productivity is a damn fine argument for a scripting language. A much better argument than performance, frankly -- which is the point I've been driving at the whole time.

#5288970 OOP and DOD

Posted by Ravyne on 27 April 2016 - 01:37 PM

That's somewhat untrue -- In general, the most broadly-applicable DOD-type data transformations will benefit other platforms even if it is not absolutely optimal. In part this is because details of e.g. cache-line sizes, number of cache levels, associations of said caches, and relative lateness of each cache level through to main memory don't, in practice, have a lot of variance. Cache lines on applications processors are 16-words everywhere I'm aware of. L1 data cache is 16 or 32 KB everywhere, latency of about 3 cycles, usually 4-way set-associative. L2 caches are 256k-512k per core, latency around 10-12 cycles, 4 or 8-way set associative, L3 caches are 2-4MB shared among 2-4 Cores on simpler/slower cores (like PS4/XBONE) or 6-8 MB shared among 4 fast, wide superscaler cores (e.g. Intel i3/i5/i7) 8 way associativity or sometimes full associativity, about 36 cylcle latency, memory latency about 90 cycles if its in the page table, more if not. The prefetcher acts like an infinite L4 cache if your access patterns are well-predicted (linear forwards/backwards is best, consistent non-contiguous strides next-best), with latency not much worse than L3. Real L4 caches, where you find them, are typically a victim-cache. So on and so forth.


But even if there were greater variance, the transformations you make to make good use of any kind of cache are similarly beneficial to any other kind of cache, simply because caches and memory hierarchies are universally more similar than they are different, whatever the fine details may be.


The PS3 is notable in particular for the SPUs in its cell processor, which provided essentially all of the PS3s computational power -- these were streaming-processors, like DSPs, with no real "caches" to speak of (each SPUs local store had similar access properties to a cache, but was all the memory that an SPU could see, DMA was the only way to speak to main memory, other SPUs, or the rest of the system) and as such they essentially required DOD practices to achieve reasonable computational throughput. But developers also found that these transformations benefited scalar/altivec code on the PPU, and in cross-platform titles even benefitted Xbox360 and PC targets. The changes that were necessary and crucial to make the PS3 work as well as it was designed were good for other platforms as well, even when they weren't strictly reliant on such transformations in the way that the PS3's SPUs were.

#5288956 what is meant by Gameplay?

Posted by Ravyne on 27 April 2016 - 12:24 PM

I dont know much about speed of programming languages and such but i know that the scripting language Skookumscript is on its own not faster than c++ but with some optimizations some certain tasks that are completed in "human time" basically meaning completed over a couple of frames, and dont have to be refreshed every tick can in theory perform 100 times better in skookumscript than c++.  http://forum.skookumscript.com/t/skookumscript-performance/500


so it is possible for scripting languages to outperform real languages, but apart from some certain parts of certain languages real languages should always perform better



From the thread you linked:

Fundamentally, well-written C++ will be of course faster than any executed scripting language, but in practice SkookumScript (which itself is written in C++) can beat naive C++ in performance due to its ability to easily time slice operations (meaning code doesn't run every frame but only every few frames).


You have to be careful how you define "outperform" -- One of the creators of SkookumScript, which I have no doubt is very performant for a scripting language, is saying right here (bold) that its a fundamental truth that well-written C++ will beat SkookumScript (he does not even say "highly optimized"), and (italics) goes on to explain that SkookumScript can beat naive C++ (I take that to mean neither architecturally, algorithmically, nor locally optimized C++) because it has built-in time-slicing such that it does less work. While that built-in time-slicing is a nice feature (its an example of those kinds of programming models beneficial for scripting that I mentioned before) and its great to have ready-at-hand, its not an apples-to-apples comparison; You can do time-slicing in C++, you just have to write it (C++ coroutines which unfortunately landed in a Technical Specification rather than C++17 proper, but is already shipping as a preview in VS2015 Update 2, make this almost trivial), and it sounds like he's not even ruling out that non-time-sliced, but optimized C++ could best them.


That you can write straight-forward SkookumScript that will beat naive C++ is certainly noteworthy, and a valuable feature -- but you shouldn't take from that that it "outperforms" even average C++ -- its creators are not boasting that claim.

#5288839 what is meant by Gameplay?

Posted by Ravyne on 26 April 2016 - 04:35 PM


thats actually what led me to asking this question on gameplay as i was wondering why I cant just do it in c++ and not a scripting language

You can but it costs you a 10 to 50 times more lines of code.


Not necessarily -- its true that many scripting languages are compact or have features (e.g. actor-model, prototypal inheritance model) that lend themselves to scripting game entities and game interactions, but that does not mean that writing gameplay code in C++ has to more difficult or more verbose for the people "scripting" the gameplay elements, albeit in C++.


If you were to use C++ for gameplay code, you might not take any special effort if yourself or the entire team is fluent in C++ (and the engine); if you have less-experienced people "scripting" gameplay through C++, then your goal as an engine programmer would be much like any other task -- provide an API, or indeed an embedded domain-specific language, that makes it easy for client code "scripts" to express high-level intent while encapsulating the low-level details away; In practice, this ends up being not much different than the work of integrating a scripting language with your engine, though you might be providing more of the cogs and widgets yourself. The payoff is that, done well, your "scripting" staff gets many of the productivity, expressivity, sandboxing, and hand-holding benefits that stand-alone scripting languages are known for.

#5288836 Is two people enough for a team?

Posted by Ravyne on 26 April 2016 - 04:25 PM


me and my friend are starting work on our game. The goal is to use this project on our resumes as well


When it comes to "experience" on a resume, it means paid professional work experience, not stuff you did on your own.  


If you have a section of your resume devoted to your hobby project where you and your friends built something, and that something did not end up being a commercial success, what you've got doesn't really count except to show interest in the field.


Now if your side project gets a million downloads and becomes a major success, then things are a little different. Then you are an entrepreneur who successfully started your own business, and the experience looks great.  Statistically that is unlikely to happen.



I don't know if its quite so harsh as that. Hiring for a junior or entry-level position, I would assume most companies would expect to find programs from college coursework or interesting hobby projects under the headline of experience. That's certainly what I'd done with my own resume years ago. I concede that one should aim to eject these "experiences" from one's resume with professional experiences as quickly as they are able after some time in the workforce, though. For myself, having taken some non-games job fresh out of school, it was a few jobs down the line before further expansion of strictly-professional experience was more prudent than to include some of my non-professional, but games-related experience.


In general, prefer professional experiences, but bubble up interesting, relevent non-professional experiences/achievements over uninteresting or irrelevant professional experiences. Within a few years or few jobs, you'll have enough varied professional experiences that you'll only be tempted to include non-professional experiences that are truly stand-out -- if you find that this is not the case after several years or jobs, then you probably have had a problem setting career goals and directing your career trajectory.

#5288831 what is meant by Gameplay?

Posted by Ravyne on 26 April 2016 - 04:05 PM

>> As a rule, scripting languages don't surpass "real" programming languages when doing the same work and with both languages free to elect their own optimized solutions;


theoretically, they can't - can they?


In theory, if compiled, its possible, but only in as much as its possible for one "real" language to be faster/slower than another "real" language. In practice, certain real languages have performance advantages over others by virtue of language design decisions, rather than, say, library implementation details.


In practice, even scripting languages that are compiled -- and lets ignore byte-code compiled scripting languages, because those cannot beat a highly-developed "real" language -- to native machine code either have not, or cannot, implement certain kinds of deep optimization techniques -- either because they are too difficult, too costly in terms of compile-time, or are essentially impossible to achieve in a scripting solution that supports hot-loading of code or are not practical/possible to achieve across the run-time/marshalling boundary. Marshaling itself is another speedbump where the scripting language's primitive types are not the host-language's primitive types, and especially where neither language's primitive types are the machine's primitive types (think CLR or JVM primitive ints, who's guaranteed behavior under shifts bigger than the machine word is one thing (IIRC), but the equivalent machine operation differs on each of ARM, x86, and x64). Still more, I'm not aware of any scripting language that exposes things like explicit memory layout of structs to the programmer, which is essential in optimization techniques such as Data-Oriented Design, but systems programming languages do.


In all, practically speaking, no scripting language will ever surpass a systems-programming language like C or C++ or Rust -- if one did, it would mean that they had achieved a breakthrough in compiler technology (and C and C++ compilers are already state-of-the-art, so no small feat). On the other hand, there are slower, natively-compiled languages, like say Swift, which at least currently is maybe half the speed of C or C++, and its possible that a highly-developed, compiled (maybe even bytecode) scripting language could best that. On the other, other hand, I'd say that Swift ought to be (and will become) faster than it is today, and even highly-developed scripting languages are likely to hit a performance ceiling before any "real" language will.

#5288827 Returning by value is inevitable?

Posted by Ravyne on 26 April 2016 - 03:36 PM

Let it also be said that in modern times, a vector class of 3 or 4 elements isn't actually a terribly useful thing -- You have access to some kind of vector instruction set that's at least 4-wide on any modern application processor and so you should most of the time be using those compiler intrinsics directly along with the vector-type supplied by your compiler, and enabling appropriate compiler flags and calling conventions.


If you intend to do that, and you should, then your vector classes end up being a thin wrapper over these intrinsic functions 90% of the time; a wrapper that could obfuscate optimization opportunities from the compiler if you are not careful. 


A vector class can be a useful thing if its your mechanism for providing a non-SIMD fallback or alternative implementations for different vector ISAs -- but other approaches are also viable: conditially-included code (#ifdefs), selecting different source files through target-specific build targets, etc. I suppose you might also elect to use a vector class if your aim is to leverage expression templates to enable vector operator overloads yet still generate code equivalent to the intrinsics, but thats fairly advanced, finicky, and can be brittle.



A matrix class is a more useful thing since matrix operations don't have intrinsics (interestingly, the dreamcast had a 4x4 matrix-matrix multiply instruction, though it had latency equivalent to 4 4-element vector-vector operations), and it provides a good home for bulk-wise matrix-vector (and matrix-point) transformations.

#5288817 OOP and DOD

Posted by Ravyne on 26 April 2016 - 02:54 PM

To reiterate again, OOP is not at odds with DOD. Its entirely possible, likely even, that your DOD code might employ classes, inheritence, even virtual functions in some capacity, even if not in the exact same capacity that a DOD-ignorant OOP progam would. Separately, some parts of your code -- the most computationally-intensive parts, usually -- will benefit most from DOD (and often lend themselves fairly naturally), and other parts of your code will not benefit and perhaps fit a DOD-ignorant, OOP style more naturally. In programming, we don't choose one approach and apply it to the entire program. Its natural and common that some parts of a program will appear more like OOP, functional, or procedural -- we as programmers are left to choose the best approach taking into account the requirements, what language features are available to us, and how we intend to weld these parts together. DOD exists on a separate axis, and can be freely mixed into different parts of the program as needed, regardless of the programming paradigm we'll leverage. Choosing to approach some part of the program from a DOD mindset does have an impact on how you utilize those paradigms, but you tend to think of it as just another requirement that has to be balanced -- it doesn't come crashing through the wall demanding that you can no longer use such-and-such language feature, or that you have to use such-and-such other feature.



By way of example, take the typical OOP approach of having a particle class -- position, mass, velocity, color, lifetime, etc -- and having a collection of those particles -- basically as Frob described earlier. If you were mistaken about DOD and assumed it merely meant "looks like procedural" you could separate the data into C-style structs, and have free functions to operate on them, but that won't be DOD because it didn't rearrange the data, it just rearranged the source code.


A more DOD approach, would be to transmute the multitude of particle objects, represented by the Particle class, into a Particles class that owns all the particles -- now you have arrays (vectors, more likely, but contiguous and homogeneous in any case) of data -- postions[], masses[], velocities[]. colors[], lifetimes[], etc[] -- now, you've re-arranged the data, but you'll notice that this Particles thing still lends itself very well to being a class -- there's not a C-style struct in sight, and you're using std::vector, and you might inherit ExtraCoolParticles from Particles, and you might use a virtual function to dispatch the Update method (its true that DOD prefers to avoid virtual dispatch, particularly in tight loops, but its still sometimes the right tool at higher levels of control).


Moreover, you might notice that mass and velocity are almost always accessed near to one another, and the same for color and lifetime; it could be the case that a better arrangement of the data still would be positions[], masses_and_velocities[], colors_and_lifetimes[], etcs[]. Only profiling will tell you whether this is *really* the better arrangement, but its possible. One element of DOD is separating hot data from cold (that is, frequently-accessed from infrequently-accessed) which is essentially always a win because it leverages caches and pre-fetching better, and another element is to consider grouping desperate elements that are frequently accessed together which is sometimes a win, and sometimes not -- but neither of these say anything about what programming paradigm is employed; its a distinct consideration.