3 ms·
I dunno, I'm a game programmer and it seems a bit too much for me personally. I just John Carmack it, and always do the simplest thing for me as the dev. If the
by everyone 3y ago
I dunno, I'm a game programmer and it seems a bit too much for me personally.
I just John Carmack it, and always do the simplest thing for me as the dev. If the benchmarks arent fit for purpose¹ then I will look at profiler to see what lowest hanging fruit is to optimise. I'm not gonna guess what is slow, I am not a computer, I only just look at profiler.
¹This almost never happens.
- sbmthakur 3y agoWhat does "John Carmack it" means? Take the simplest and correct approach?
- everyone 3y agoLike what I described, start with the utter simplest/easiest code for you the developer, and only optimise it/make it more complicated, later if it's benchmarked and not up to a standard you are aiming for (of feature quality or performance or whatever). There was a bit about it in that book "Masters of DOOM" I also personally equate simplest/easiest code for you with most maintainable code also.
- dragontamer 3y agoAh yes, John Carmack. The developer who is known for writing simple, easy to understand code. float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; }
- mhh__ 3y agoCarmack didn't write that
- NGRhodes 3y agoIt exists in the Q3A code: https://github.com/id-Software/Quake-III-arena/blob/master/code/game/q_math.c https://github.com/id-Software/Quake-III-arena/blob/master/c...
- everyone 3y agoHe could utterly suck as a programmer, or even be fictitious, but that "John Carmack approach" as I call it is still great imo.
- dragontamer 3y agoExcept the reason why Quake (and other such 1st person shooter) games are very fast and optimized... is because John Carmack encouraged high-performance programming which is necessarily only practiced and understood by a very small number of programmers. Carmack (and id software games) are legendary in terms of their high-performance. And given the source code of these games... the source code filled with raw assembly language and other such tricks like I posted above... the source code is nearly impossible to read for the "typical" programmer. ---------- This is absolutely not a company (or engineer) who did things "simply". He did things in a extremely difficult, high-performance first engineering mindset. I dare say that John Carmack's practice is closer to "premature optimization", built around abusing incredibly low-level tricks to improve the performance of their various video games... and strategically choosing parts of the video-game simulation that people would prefer high-performance over accuracy. (IIRC: the Fast Inverse Square Root algorithm above is only ~4 digits or 12-bits worth of accuracy). This was a programmer (or at least, programming team) that at a high level, decided that 12ish-bits of accuracy (out of 23-maximum bits of precision) was enough for their purposes in the vast majority of their code. And then used that slight performance increase to have a smoother-feeling game than their competition. ---------- IIRC, John Carmack is a legendary programmer in terms of low-level 3d details. He is a good programmer, but his style is the complete opposite of what you're calling it.
- mhh__ 3y agoYou wouldn't actually know how to optimize it other than by guessing if you didn't have a rough idea of the computers memory hierarchy.