Hacker News new | ask | show | jobs
by flohofwoe 2053 days ago
A similar problem exists in the C/C++ world: designing a library in a way that supports good dead-code-elimination isn't something that many library authors think about.

Interestingly plain C libraries often do this better than C++ libraries (e.g. too generous use of virtual-method-interfaces in C++ libraries, or making heavy use of C++ stdlib containers when simple C-style arrays would do as well).

The Unity engine also suffered from a similar problem: If you used a simple physics feature like a stabbing collision check somewhere in your code, the entire physics module was pulled in, even though the code needed for stabbing checks is only a few percent of that physics module.

This is why I'm a bit sceptical that improvements in the .NET "machinery" alone can solve this problem. You also need to restrict language features and select the right dependencies. This is a general problem, not just web-specific, it's just that reducing the output binary size typically isn't a high-priority problem outside the web.

1 comments

Yeah, as you point out C++ libraries are especially hard to do DCE on. If you want to ship ICU in the browser right now it is a very big blob that it's hard to perform DCE on because the vtables retain lots of unused code and every API depends on every other API. A lot of this stuff was designed in an era before anyone could have anticipated the size constraints that would apply in 2020.