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.
Permalink for comment 552627
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"
Alfman
Member since:
2011-01-28

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