Live data from Hacker News

Doom3 is the proof that “keep it simple” works

gamedev.net

81–90 of 111 posts

Re: Doom3 is the proof that “keep it simple” works

#81

As someone who wants to learn modern c++, what are some good resources/books to learn from ? I have python and java experience and I have been reading Accelerated C++ since a while now.

As an addendum, I highly recommend not reading decade old source code like this as an example of modern C++. C++11/14 have changed the language so much for the better that anything targeting C++03 should be ignored for new projects and especially for new learners.

Also, avoiding Boost and Qt early on is also a good idea. Both have tremendous stylistic and design differences from ISO C++ and while the language supports all of them when using the Boost libraries and Qt toolkit you need to shift mindset entirely in how you are writing code to match the backing architecture. Learn the core language first.

Re: Doom3 is the proof that “keep it simple” works

#83
post #30

Earlier quoted context omitted.

The most common argument: Pass by reference hides the implication of a side effect on the parameter. If you expect the function to manipulate the parameter, passing by pointer is clearer. Pass by reference was also only added to efficiently support copy constructors and more importantly operator overloading, both of which are syntactic sugar that a C with Classes style would normally avoid. Template programming also…

Fair points, although all references should ideally be const unless there are side effects. It's not perfect though, since you can't tell from just viewing the calling code, you have to check the function prototype. References also help avoid problems with pointer aliasing, and make it clear that the called function definitely cannot delete the passed objects. So it's more than just syntactic sugar. (n.b. I'm not arg…

Also, references can't be nullptr, which eliminates needs for null checks and makes clear that nullptr isn't a valid value. RVO also makes "returning" values through non-const references not as necessary.

Though, the most important thing is consistency and readability over using fancy new features, so they should stick to the style they were using for the project.

Re: Doom3 is the proof that “keep it simple” works

#84

Earlier quoted context omitted.

Over 150 lines of code in a simple method? C-style declaration of all the variables in the beginning? (Yes, I know what Carmack said about how he written the project; this explains it, but doesn't make it good C++ code.) Unclear flow with just one comment, which doesn't really explain anything?

You should try a Perl codebase. In just this one module I'm looking at, there's methods with 505, 880, and 995 lines.

A popular VoIP product has switch statements that are in the thousands.

Re: Doom3 is the proof that “keep it simple” works

#85
post #60

> Doom3 is the proof that “keep it simple” works This statement suits even better to id Tech 3 (Quake 3). John Carmack mentioned: I still think the Quake 3 code is cleaner, as a final evolution of my C style, rather than the first iteration of my C++ style [Doom 3] : http://kotaku.com/thanks-a-few-comments-in-some-ways-i-still... and he linked to his blog post about "Functional Programming in C++" on the now defunct…

Wait, HL2 uses the Quake engine? I know HL1 did, but I thought HL2's engine was Valve's in-house work.

Re: Doom3 is the proof that “keep it simple” works

#87
post #85
post #60

> Doom3 is the proof that “keep it simple” works This statement suits even better to id Tech 3 (Quake 3). John Carmack mentioned: I still think the Quake 3 code is cleaner, as a final evolution of my C style, rather than the first iteration of my C++ style [Doom 3] : http://kotaku.com/thanks-a-few-comments-in-some-ways-i-still... and he linked to his blog post about "Functional Programming in C++" on the now defunct…

Wait, HL2 uses the Quake engine? I know HL1 did, but I thought HL2's engine was Valve's in-house work.

HL1 uses the GoldSrc engine, which is a heavily-modified version of the Quake engine.

GoldSrc was again heavily modified to become the Source engine, but it does retain direct lineage to Quake.

http://en.wikipedia.org/wiki/Source_%28game_engine%29#Origin...

Re: Doom3 is the proof that “keep it simple” works

#88

As someone who wants to learn modern c++, what are some good resources/books to learn from ? I have python and java experience and I have been reading Accelerated C++ since a while now.

I really enjoyed Effective Modern C++. It covered the interesting stuff I wanted to know, and skipped the introductory "in case you've never programmed before" fluff.

http://shop.oreilly.com/product/0636920033707.do

Re: Doom3 is the proof that “keep it simple” works

#89
post #85

Earlier quoted context omitted.

Wait, HL2 uses the Quake engine? I know HL1 did, but I thought HL2's engine was Valve's in-house work.

HL1 uses the GoldSrc engine, which is a heavily-modified version of the Quake engine. GoldSrc was again heavily modified to become the Source engine, but it does retain direct lineage to Quake. http://en.wikipedia.org/wiki/Source_%28game_engine%29#Origin...

Oh, that's pretty cool.

Gotta love how well-known brand names like Source originated as internal dev jargon. I've always been fascinated with things like that.

Re: Doom3 is the proof that “keep it simple” works

#90
post #65

Earlier quoted context omitted.

I would also add Effective STL too. A Tour of C++ by B. Stroustrup is a good start point for a beginner too

Well, don't forget about exceptions, unless you decide to ban them like many people do. So add: Exceptional C++ by Herb Sutter More Exceptional C++ by Herb Sutter Exceptional C++ Style by Herb Sutter And Templates: C++ Templates: The Complete Guide by Josuttis & Vandevoorde And of course you need some background in generic & metaprogramming, so add: Modern C++ Design by Alexandrescu Advanced C++ Metaprogramming by Ge…

All of that is hardly prerequisite for using modern C++ on a day-to-day basis. You can get away with just reading "A Tour of C++" and the Effective C++ books.

If you want to start writing highly generic libraries with the intention of submitting them to boost, then absolutely you should be reading everything in your list and more. But how many C++ programmers are writing boost libraries?

Post reply on HN