The Beauty Of Doom 3 Source Code

preview_player
Показать описание
Recorded live on twitch, GET IN

By: Shawn McGrath

MY MAIN YT CHANNEL: Has well edited engineering videos

Discord

Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
Рекомендации по теме
Комментарии
Автор

"Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function."
-- John Carmack

ExpensivePizza
Автор

People who dont like comments havent had to deal with 30yr old code that was done by a guy whos been dead for 12years.

lordfrz
Автор

Having worked in SW for many years, for me what defines a beautiful code base is very simple:
When somebody gives you an initial ticket to add some functionality, as usually happens when you 1st join a team, without knowing the code base, it should be super simple to track down where code needs to be added, look at the surrounding code, and figure out how to augment it to do what you need. If that can all be done in a short time frame, than IMO the code is beautiful. And that's all there is to it, IMO.

Code needs to be maintained & built upon, it's as simple as that. So as long as it's easily approachable and readable? It's good.

MrSlowestD
Автор

@16:00 I think a little vertical whitespace can be considered a form of self-documenting code, as it can help group statements in a function together based on their purpose and demarcate these ideas from others.

lukekurlandski
Автор

"Code should be self-documenting" is a very funny point.

I had an interview once at a consultancy where one part of their technical interview was some kind of code analysis. They gave me a short piece of code where they said to assume it runs fine and has no errors. The task was to somehow make it better. They left the room and gave me some time to think. My simple answer when they got back was "more self-explanatory function and variable names", which they sort of accepted, I think, but they mainly wanted comments in there. Worst technical interview I've ever had. I kinda failed that one, and had another one at the same company where we spent an hour talking about a developer roadmap. (Should probably say the code wasn't that complex, getting an item from an array and some other functions)

Had two other technical interviews at two other places that were both sort of a pair programming session to write some unit and integration tests. Those were much better

TBTapion
Автор

That “unlock a problem solving way” is the fondest memory of my dad an I when he showed me away to solve this Hanoi Towers puzzle in 4 or 5 lines of code. Teaching me 15 year old me about recursion. And after he showed that magic told me to avoid using recursion whenever you can or are 100% sure it can’t cause a stack overflow.

CallousCoder
Автор

Just wait until you need to port a Japanese game from the 90s to present day consoles… you will absolutely love comments.

martijn
Автор

I had hoped this video to be an original look through of the Doom 3 source code it is a 40 minute ramble about someone's blog post.

Tibbon
Автор

The reason a lot of people don't like having curly braces on the same line is so you easily tell which curly brace relates to which other curly brace quicker. In a lot of IDE's you highlight one and it highlights the other. When are in the same horizontal position it jumps out much quicker.

robwalker
Автор

telecommunications is the hardest "medium" to program in. actually it's typically regarded as the most difficult, highest failure rate and highest expert level (meaning need longer time to establish seniority) than any other field.. in human history. i kid you not those people are doing the hardest engineering in the world only for a rogue cosmic ray to flip a bit in their L5 switch and yet somehow companies like cisco are able to maintain 99% uptime for everyone. it is a massive feat that no one notices.

manawa
Автор

I am not a rust dev, nor am I using htmx, but I totally felt soulbros with Prime when he pulled out his "Devtools" and started removing annoying html blocks from the page he reads. I do that with ublock.

I also separate code blocks with empty lines, it is like commas to me: you can read without them, but it is nicer.

elzabethtatcher
Автор

16:00 I definitely prefer spacing in blocks. I find it infinitely easier to read (even when I wrote it myself) when there are separations. And as far as I remember doom3 source does it. I only surfed it a couple of times, but I've worked a lot with Quake 2 and Quake 3 source code and they definitely leave space in those.
Also, it should be noted that Doom3 was iD's first project using C++. They used C for all their previous projects, so Doom3 is C++ with a heavy influence of their C habits.

(I suspect they only moved to C++ because the people who used to license the engine were requesting it to be C++)

jal
Автор

I love this commentary for four reasons:
1. Operator overloading. I hate it someone made a a bit shift into a string concatenation..
2. I spent to many hours debugging ATL/STL in the late 90s/early 2000s. That was incredibly frustrating.
3. API design. Focus on clarity, not cleverness. I appreciate you highlighted that.
4. I have my copy of effective c++ right behind me. Thanks for that reference.

Isotech
Автор

If you checkout Carmack's contribution to the Meta Quest codebase re: VR motion controller, you'll see lots of highly detailed ASCII art schematics showing the system and then a bunch of beautifully self-documented stuff.

AustinSnider
Автор

logical code blocks gang. Love to bunch things together that are related and then leave a space before the next thing.

Tabu
Автор

"If your code definition takes more space than body, you probably left the path of good programming"
TypeScript: 👀👀👀

SkywalkerWroc
Автор

I used to work at a game dev company that wrote in C++ and their codebase was not beautiful let me tell you. There was 3 different sets of string handling paradigms that had to be used in different places in the code, Thats right, they had stringhash, stringview, and stringviewhash in 2 or 3 different forms each. It was insane because they weren't even all mutually compatible with eachother.

triplebog
Автор

Regarding "one function should do exactly one thing" I think that it is more important to avoid doing things like mutating and persisting in one function than it is to limit to one thing, because "one thing" is highly subjective.

CottidaeSEA
Автор

In regards to writing overly generic code and it being ugly.
People need to learn they aren't trying to implement standard library functions, that have to be used by millions of people without knowing their exact use case.

Use a specific implementation if you don't need something generic.
For instance, from the code he provided, he's defining an allocator type, ala the standard library.
Most people will _never_ need to pass a specialized allocator to a class, so why would you write a class for your program that allows you to override the allocator?

If you find you need that specific class, but slightly more generic, consider making it templated, but again
*this doesn't mean you have to go balls to the wall generic*

Just support _your_ use-cases unless you're writing a library intended to be consumed by a large array of people with a large array of uses.

khatdubell
Автор

On input and output, I miss Ada's solution for this. You can declare a function parameter as `IN` `OUT` or `IN OUT`

timedebtor