News for hackers. Stuff that matters.
Re:Tree-Shaking: A Reference Guide by juki on Wednesday May 26, 2021 @05:30AM (#27288208)
Yes, in image based languages DCE is used inside functions to eliminate things like branches that can never be executed, but a function that is never called is not dead code since it might get called later. Tree shaking is used to optimize the final deliverable by saying that there will be no more changes or `eval`s, so anything that isn't reachable from the root(s) can be eliminated.
Re:Tree-Shaking: A Reference Guide by funcDropShadow on Wednesday May 26, 2021 @06:28AM (#27288594)
Whether dead-code elimination would remove whole functions depends on some basic assumption of the tool doing it --- usually a compiler. Some languages are considered closed worlds whereas others are usually considered as open worlds, e.g. Smalltalk, Java and Lisp. Under an open world assumption, everything that could be called by some code added later has to be retained. Some tools nevertheless apply a closed-world assumption to an "open world language" and take additionaly arguments what to consider entry points that should be retained. An example for such a tool is Proguard in the Java world.