Linked by Thom Holwerda on Fri 15th Feb 2013 10:40 UTC
General Development "Since I left my job at Amazon I have spent a lot of time reading great source code. Having exhausted the insanely good idSoftware pool, the next thing to read was one of the greatest game of all time: Duke Nukem 3D and the engine powering it named 'Build'. It turned out to be a difficult experience: The engine delivered great value and ranked high in terms of speed, stability and memory consumption but my enthousiasm met a source code controversial in terms of organization, best practices and comments/documentation. This reading session taught me a lot about code legacy and what helps a software live long." Hail to the king, baby.
Thread beginning with comment 552627
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[2]: Code Review
by Alfman on Fri 15th Feb 2013 15:04 UTC in reply to "RE: Code Review"
Member since:

Bill Shooter of Bul,

"Eh,I've always preferred using arrays rather than numerically named vars. It usually is easier that way."

I don't prefer arrays, but I guess I can see why you would.

My concern would that in many languages the arrays will have an additional performance cost though, requiring more indirection and more calls to alloc/free, and maybe more bounds checking as well. Even with C, the array might conceivably force the compiler to use a specific memory structure when the variable solution might have allowed more register optimizations. Its very hard to predict compiler's optimization behavior these days though.

Edit: How would you formulate a draw line function using arrays?
drawline(single x1, single y1, single x2, single y2);
drawline(single x[2], single y[2]);

// Above is too weird for me, structures would be a bit better.
drawline(coord p1, coord p2)
drawline(coord p[2]);

Edited 2013-02-15 15:11 UTC

Reply Parent Score: 2

RE[3]: Code Review
by Bill Shooter of Bul on Fri 15th Feb 2013 15:38 in reply to "RE[2]: Code Review"
Bill Shooter of Bul Member since:

Yeah, I'd use structs too. High performance graphics code isn't my specialty so maybe in some scenarios its a bad idea, but I still have a hard time believing that the performance hit outweighs the utility of an organized data structure of some sort. I mean, if its really performance critical, use assembly.

Reply Parent Score: 2

RE[4]: Code Review
by Laurence on Fri 15th Feb 2013 16:43 in reply to "RE[3]: Code Review"
Laurence Member since:

if its really performance critical, use assembly.

These days compilers are so good at optimising that you're more likely to write better performing code in C than assembly.

Reply Parent Score: 2