3 ms·
Is there more terminology that means "to tree-shake"? I understand javascript does tree-shaking, mainly in the context of code-minifiers, and certain languages
by Chris2048 6y ago
Is there more terminology that means "to tree-shake"?
I understand javascript does tree-shaking, mainly in the context of code-minifiers, and certain languages do "path optimisation" usually at runtime - but I'm not sure how to describe the removal, and modification[0] of code (say, interpreted code) outside JS.
I'd like to "tree-shake" python in order to see what % of code in it's deps is actually used.
[0] e.g removing static parameters, replacing fns with lots of cases into multiple fns etc.
- the_duke 6y ago> Is there more terminology that means "to tree-shake"? Yes, everyone else calls this dead code elimination. [1] (the custom term isn't completely unreasonable, since tree shaking is somewhat different from how compilers do DCE) https://en.wikipedia.org/wiki/Dead_code_elimination https://en.wikipedia.org/wiki/Dead_code_elimination
- Chris2048 6y agoThat page describes "dynamic" elimination, but let's say I call sqrt(x) in my module, but for a fixed value of x - in that case I can just replace the whole fn with a fixed value, but it would require me to detect that the fn is deterministic. Would that still count?
- geokon 6y agoAh okay. To me "tree shaking" was implicitly talking about the dependency tree and removing unused library dependencies. While "dead code elimination" would be a "deep" clean done by a linker when making a static binary (mostly C/C++ land..). There you're looking at a finer granularity than libraries/compilation-units. That's necessarily a bit trickier and I wasn't even thinking that far. But it seems the GraalVM compiler work on this level.