ninepoints.just regular fiat Profile picture
Feb 27, 2022 15 tweets 2 min read Read on X
With all the discussion on the STL, I wanted to make a quick thread to summarize the main reasons why many AAA studios (correctly) opt out of the STL. This isn't to say the STL isn't for *anyone*, but the reasons to avoid using it aren't unfounded either 1/🧵
The STL implementation varies depending on platform/compiler choice. This seems like a small matter, but sometimes we *need* the functions to behave in a controlled manner across all platforms. 2/n
Consistent behavior means similar execution order, deterministic results in scenarios where determinism matters, and even a consistent ABI you can rely on to share code between compatible platforms. 3/n
Furthermore, you have a consistent debugging experience (and a fast one, if reasonably fast debug builds are a priority for you, which they absolutely are in AAA). 4/n
Another thing about the STL is that it simply wasn't designed with *tracking* in mind. That is, attributing memory allocations accurately. It's not good that just "push_back" can result in an allocation you can't track. You could use custom allocators but... 5/n
...custom allocators in the STL are *really* difficult to use. This is probably more opinion than fact, but I think the interfaces I've worked with in the games industry are a lot easier to grok than std::pmr and using the allocator trait. 6/n
In many cases, the STL is actually flat out missing functionality that requires intrusive changes to add or correct. For example, adding elements to containers without initializing. Unsafe scary behavior? Sure but we need escape hatches on hot paths! 6/n
In some cases, the STL enforces various semantics that you *don't* need that hurt performance. For example, iterator stability is something that imposes restrictions on container implementation you don't always need. 7/n
Another good one is std::shared_ptr which supports std::weak_ptr. The mere fact that the implementation needs to support a notion of weak_ptr at all affects the implementation! 8/n
Error handling vs exception handling is another popular one. It's true that exception overhead when the exception is not thrown is negligible, but several aspects of the STL uses exceptions for common error cases you'd expect to encounter. 9/n
You can, of course, disable exceptions, use the error variants, etc. But the fact remains that the primary APIs were designed expecting exceptions to be around, as opposed to being designed around more performant error handling from the get-go. 10/n
In short, to me, the main pitfalls of STL are related to uniformity, debuggability, performance, and design. These aren't problems that you can solve by "bolting stuff onto the STL." Given how foundational these concepts are, people shouldn't be surprised that AAA rolls their own
off by 1 error in the thread numbering oops ignore pls thanks
Last note: of course, I use the STL where appropriate in personal projects, when interfacing with other libraries, or cases where none of the reasoning above applies. As with most things in engineering, it's not black and white so use your judgement. /🧵
A little sloppy with my language here, but when I wrote "ABI" here, I was referring to "data layout" (struct member sizes, order, etc.), and not "calling convention"

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with ninepoints.just regular fiat

ninepoints.just regular fiat Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @m_ninepoints

Feb 27, 2022
When we dubbed "order-independent transparency" as such, we really missed the opportunity to name it "farraginous blending" or something (/s)
Dual-source blending could have been "biparous blending".
Supersampling is actually eellogofusciouhipoppokunurious sampling
Read 4 tweets
Apr 19, 2021
I see a lot of C++ hatemail in my twitter timeline, but before you go "all-in" on Rust, do your due diligence and consider the following things:
Does your job have a lot of specialized low level data structures with self referential pointers/refs? Well, you can't port this to Rust reasonably at all. The language *assumes* that types move destructively. It's a great default, but you can't turn it off.
Do you rely on shared linkage to either save disk space, distribute binaries internally, or hot-reload code? Well make sure you're ok to restricting the library interfaces to the C ABI only. Rust compiler versions are not ABI compatible with each other
Read 8 tweets
Nov 10, 2020
For people interested making an engine that supports both Vulkan and D3D12, here's a quick summary of differences you should plan for. I can't comment about any other proprietary APIs (console), but setting yourself up for Vulkan/D3D12 is a decent start for all of them (1/n)
1. Descriptors in Vulkan are strongly typed and are untyped in D3D12. Descriptors in VK refer to buffers, images, samplers and must be provisioned for in a descriptor pool. Descriptors in D3D12 are simply virtual addresses, without type information
2. D3D12 has no concept of "descriptor sets." Instead, you can bind descriptors to particular "register spaces" and you have to manage this grouping yourself.
Read 14 tweets
Jan 14, 2020
0/n) How to stay up-to-date with math as a working programmer (been asked this a bit after the last thread on learning graphics programming)
1/n) There are a few foundational tasks that I think engineers involved with computation/numerical work need to just *know* on any given day of the year, so if these techniques are a bit rusty, I would start here. These techniques are ...
2/n) Taking a derivative of any polynomial and all common transcendental functions (things to just *know* #1)
Read 18 tweets
Jan 10, 2020
0/n) How to learn graphics programming (but not in a hurry): self-study edition! This thread is highly opinionated, and not what I went through (technology changes), but what I would recommend today. You don't need all of the following to get a job...
but just start the path and continue learning and learning. Interview earlier than you think you're qualified and listen to feedback. Learning on a job is a lot easier than learning on the side.
1/n) Don't use any commercial engine or framework to start. There's far too much "magic" involved that will prevent you from understanding what's going on. You can always reference them or use them later.
Read 20 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(