4 ms·
I thought this technique of eliminating dead code was called tree-shaking. And linking to be something entirely different: linking assemblies at (compile|run|an
by sharpercoder 9y ago
I thought this technique of eliminating dead code was called tree-shaking. And linking to be something entirely different: linking assemblies at (compile|run|analysis)-time.
- mitchty 9y agoI've only ever heard it called dead code elimination. Tree shaking appears to be more a javascript thing? Not sure I don't participate in that community at all. https://en.wikipedia.org/wiki/Dead_code_elimination https://en.wikipedia.org/wiki/Dead_code_elimination
- cwzwarich 9y agoIt's an old Lisp term going back decades. Strictly speaking it's not the same as interprocedural DCE, because due to the dynamic features of Lisps you might need the user to specify the extent to which they are willing to disable the dynamic features to save space.
- mitchty 9y agoGotcha, would it be fair to characterize it as tree shaking is more white listing things that have been used versus eliminating code paths that cannot be accessed?
- algorithmsRcool 9y agoYes dead code elimination is also called tree shaking and it is typically done at compile time. However for .NET, since you can use reflection to load any type in an assembly and call any method dynamically, removing a method is isn't statically called could cause you to fail at runtime. Since reflection and dynamic invocation is a major feature of the runtime, they have avoided this optimization before.
- SideburnsOfDoom 9y ago> However for .NET, since you can use reflection to load any type in an assembly and call any method dynamically, removing a method is isn't statically called could cause you to fail at runtime. Indeed. it's not that common, but I would expect it to happen. One example is that many IoC Containers allow you to scan assemblies and register all class + interface pairs that match given rules. There has to be some safety-hatch to express "yes, I really want to keep that class and its methods. Don't strip them out". This seems to be documented here: https://github.com/dotnet/core/blob/master/samples/linker-instructions-advanced.md#limitations https://github.com/dotnet/core/blob/master/samples/linker-in...