This comment by Carmack seems to imply that the restrained use of advanced C++ features was more by accident then by design:
I had C and Objective-C background, and I sort of "slid into C++" by just looking at the code that the C++ guys were writing. In hindsight, I wish I had budgeted the time to thoroughly research and explore the language before just starting to use it.
You may still be able to tell that the renderer code was largely developed in C, then sort of skinned into C++.
That doesn't necessarily imply that he's saying he should've used more advanced features. It could just as well mean he should've understood better the features he did use.
Fabian Sanglard's exploration[1] of Doom3 is much more in depth than this article, though the author does quote Sanglard's analysis albeit with a small source link
The vanilla code review goes into the app structure first, and (what little I've read of) the BFG review compares that codebase against the vanilla one.
Ads that are decently educational? Compared to what we deal with currently, I have no problem with edu-ads becoming the next great trend in advertising.
The issue is that we lose the distinction between content and ad. As this distinction blurs, less people will be able to say which is which. I guess the real question underlying this is the one underlying advertising in general, how much are we morally allowed to manipulate someone who did not give informed consent for the purpose of modifying their behavior in a way that is beneficial to us?
You must be the target audience then because I read a great article about Doom3 and have no clue what youre talking about. I also dont know what CppDepend is...
But as somebody with zero experience, I wasn't aware when reading that this was a tool and not a part of the language itself. I read articles like these because I have an interest and a lack of knowledge, and I'm learning all kinds of things today.
I've been a longtime fan of Carmack, and I wish I could read and understand his work for myself!
I was seated at the restroom at work yesterday morning when I noticed a strip of plastic had been added to the gap between the metal stall and the metal stall door. It was branded Privacy Cover (patent pending).
Welcome to the future where everything is branded and everyone is an Avon lady, endorsing some set of pet products :)
You might be interested to know that other parts of the world seem to have solved this quite ingeniously.. At least in Australia and New Zealand it is very common to have stalls with doors hinged and sized so when shut they overlap an outer bit. No gap.
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?
Context is important, to anyone developing D3 code, this code might be obvious and comments would be unnecessary. Considering 'geterdone' attitude of many game projects, with high levels hackery, this is very nice code.
It's a "simple method", but it's responsible for a bunch of initialization, so yeah, it's kind of expected to be long.
Notice, though, that each section is pretty straightforward in what it does...basically forEach's.
You could make the argument for greater polymorphism in types, or something like a visitor pattern over collections or something, but honestly this is readable and maintainable code.
More comments at the function declaration would've been nice, but the implementation is pretty straightforward.
"As we can observe many structs are defined, for example more than 40% of DoomDLL types are structs. They are systematically used to define the data model. This practice is adopted by many projects, this approach has a big drawback in case of multithreaded applications. Indeed, structs with public fields are not immutable."
The engine of Doom 3 (id Tech 4) was good. The game itself was repetitive and a bit boring. It was a few months late Aug 2004, and Far Cry 1 (March 2004) already overshadowed it in terms of graphics and gameplay.
Licensing the id-Engine to other companies was very successful during the id Tech 2 (Quake 1/2) and id Tech 3 (Quake 3) era. Back then the Unreal engine was only used in Unreal and Unreal Tournament '99, with Deus Ex as an early adopter.
But few games were released starting with id Tech 4 (Doom 3) and later id Tech 5 (Rage). Compromises during the development of id Tech 4+ meant it wasn't suitable for many different purposes. Only small levels with a few light sources were possible - the later "mega texture" addition partly solved that issue but meant a huge hardware step during development and prevented Mods and custom maps. In retrospect the Unreal 3+ and CryEngine 1+ offered comparable results without sacrifice their universalizability. http://en.wikipedia.org/wiki/Far_Cry_(video_game) , http://en.wikipedia.org/wiki/Doom_3 , http://en.wikipedia.org/wiki/Id_Tech_4
All of these id tech engine games can be edited with the GtkRadiant map editor (Half Life, Call of Duty, Quake 3, Doom 3, etc.): http://en.wikipedia.org/wiki/GtkRadiant
I wonder what John Camack's current thoughts are on C++ design. I rarely use inheritance and usually have either inlined functions or functions that operate on arrays or many objects at a time. I also use templates when they deal with straight type substitution (including functions). I am though starting to get familiar with extern templates to be able keep compile times down.
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 requires pass by reference but templates are sugar on sugar so not the core reason why pass by reference is needed.
Ps. Disclaimer: I haven't checked if the Doom3 code uses these features.
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 arguing that pointers are bad and should never be used, I still just don't see a clear reason never to use references. The id Software coders are smart, they must have had good reason to pick their choice)
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.
Depends on how you interpret the "argument." If the argument is "all software projects can/should 'keep it simple'" then yes, it's clearly a logical fallacy.
But if the argument is "'keep it simple' works for some software projects," one example proves the point. This seems the more generous interpretation.
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.
The C++ Programming Language, 4th edition
Bjarne Stroustrup
The C++ Standard Library, 2nd Edition
Nicolai M. Josuttis
Effective C++, More Effective C++, Effective Modern C++
Scott Meyers
http://en.cppreference.com
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?
Yeah and the Exceptional C++ series is not 'about exceptions' either. It looks like he just googled 'c++ exceptions book', and the same for templates and metaprogramming, probably.
It is also excellent for people who have worked in an older style of C++ and want to get a jumpstart on modern practices and the new C++11 features and keywords.
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.
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.
This is back in the good old days when C++ didn't have all the crap, and everyone wanted to stay away from doing advanced stuff with STL and RTTI. Linus famously said that Linux is written in C if only to keep away the C++ developers.
Does anyone love the new C++, and if so, what are their experiences with being on teams that use the full range of functionality? Do you need a language lawyer?
I do enjoy programming in C++11 style. What I like the most is that once you understand the quirks, you would see a lot of opportunities to improve performance but only when necessary (Like using moving semantics if you have to pass a big object through several function calls)
Also STL has improved a lot and I am very happy that I don't need to include a huge dependency such as Boost or POCO just to have a hash table for instance.
This comment represents the my biggest frustration with current programming tools & practices. You shouldn't have to include any libraries. Ever! And you shouldn't have to rewrite some code that does something that's already available and well-written. That, and, if you want to include some functionality, there will be 13,000 versions of the same functionality for you to review before you decide which one to learn and commit to. (And it is easier to write it yourself sometimes.)
There's no reliable way for languages themselves to standardize and aggregate the work that others do. You just hope the language designers are willing to put up a new version, (and that it's a decent one) and they end up doing it ever-so-slowly because it's not automated in any way. Hand-pick and re-roll. There's no metric-based signaling or automated analysis or anything, it's just whatever your experts opine.
For basically every piece of software I work on this would have horrible security implications. Let me spell it out in black and white: every time someone does a deployment, by default it will download code from the internet and incorporate it into production code. All one would need do is subvert one external code provider and they'd have the ability to inject code into countless production systems at will. How much do you trust github or bitbucket? Would you give them the keys to your business, and your customer accounts?
> Note: Please offer only positive, constructive comments - we are looking to promote a positive atmosphere where collaboration is valued above all else.
And keep your rose-colored glasses on at all times. You shall see no evil, hear no evil, speak no evil and never grow out of childhood.
These days just use expand tab, in an age of online code review tools etc it's just better not to have to configure every system to interpret tabs to your given number of spaces - just write the damn spaces into the file.
> "it's just better not to have to configure every system to interpret tabs to your given number of spaces"
The entire point of "tabs to indent; spaces to align" is that you don't need to make sure everyone displays tabs the same way. If we are using that scheme and I have mine set to 4 spaces but you have yours set to 8, everything is fine. There is no problem there.
Yeah, but since every time someone new comes along who doesn't understand what this means (witness the replies you're getting)... no tabs. It's just easier this way.
8 spaces tends to be the de facto standard tab width. But because tab is it's own ASCII character (0x09), much like how space (0x20) and the lower case letter 'a' (0x61) are, it means it's up to whatever text processors used (eg diff, vim, GitHub web application, etc) to interpret a tab character by whatever width they choose. Which is why tab spaces are a per-application setting, eg:
diff --tabsize=4 ...
vim "+set tabstop=4" ...
http://github.com/.../file?ts=4
They were building Rage at the time. I'm sure the budget for that game was like 5x that of D3.
Shit runs late, cost blooms.
Lots of 90's era twenty person shops had trouble dealing with increasing costs.
I can't say for Id Software, because I have no clue about their financials. But historically, people who run profitable companies do not want to sell them. They want to grow them so they can make even more money. These days startups which are "owned" by VC money, usually have to sell so the VCs can recover their investment.
I had C and Objective-C background, and I sort of "slid into C++" by just looking at the code that the C++ guys were writing. In hindsight, I wish I had budgeted the time to thoroughly research and explore the language before just starting to use it.
You may still be able to tell that the renderer code was largely developed in C, then sort of skinned into C++.
(Source: http://fabiensanglard.net/doom3/interviews.php)