Tree-Shaking: A Reference Guide
smashingmagazine.com
Tree-Shaking: A Reference Guide
1–10 of 10 posts
Re: Tree-Shaking: A Reference Guide
#2There is a perfectly good name for this that is used in many other contexts, called "dead code elimination", which is also fairly self-explanatory if you haven't come across the term before.
Re: Tree-Shaking: A Reference Guide
#3The Web development scene is sometimes just so foreign thing to me. I've many times wondered, what does tree-shaking mean when listed in some features in some framework. I think I've looked up it in several occasions and it hasn't stuck with me. It throws me off as it sounds like some kind of ast fuzzing or whatever (perhaps like heckle in ruby). There is a perfectly good name for this that is used in many other cont…
Re: Tree-Shaking: A Reference Guide
#4The Web development scene is sometimes just so foreign thing to me. I've many times wondered, what does tree-shaking mean when listed in some features in some framework. I think I've looked up it in several occasions and it hasn't stuck with me. It throws me off as it sounds like some kind of ast fuzzing or whatever (perhaps like heckle in ruby). There is a perfectly good name for this that is used in many other cont…
That article claims that "tree shaking" is different because:
> Rather than excluding dead code, we’re including live code.
That's a misunderstanding of the term "dead code elimination". Classic dead code elimination techniques have always worked by first identifying potentially live code and then eliminating the rest.
Re: Tree-Shaking: A Reference Guide
#5The Web development scene is sometimes just so foreign thing to me. I've many times wondered, what does tree-shaking mean when listed in some features in some framework. I think I've looked up it in several occasions and it hasn't stuck with me. It throws me off as it sounds like some kind of ast fuzzing or whatever (perhaps like heckle in ruby). There is a perfectly good name for this that is used in many other cont…
afaik tree-shaking is an old old term, it might be less obvious in the web context because it's probably inherited from 70s programming languages (lisp, smalltalk or similar, i can't really say).
Re: Tree-Shaking: A Reference Guide
#6The Web development scene is sometimes just so foreign thing to me. I've many times wondered, what does tree-shaking mean when listed in some features in some framework. I think I've looked up it in several occasions and it hasn't stuck with me. It throws me off as it sounds like some kind of ast fuzzing or whatever (perhaps like heckle in ruby). There is a perfectly good name for this that is used in many other cont…
Adding to the confusion is this often-cited article: https://medium.com/@Rich_Harris/tree-shaking-versus-dead-cod... That article claims that "tree shaking" is different because: > Rather than excluding dead code, we’re including live code. That's a misunderstanding of the term "dead code elimination". Classic dead code elimination techniques have always worked by first identifying potentially live code and then elim…
Tree Shaking is dead code removal. They're one and the same.
Re: Tree-Shaking: A Reference Guide
#7Earlier quoted context omitted.
afaik tree-shaking is an old old term, it might be less obvious in the web context because it's probably inherited from 70s programming languages (lisp, smalltalk or similar, i can't really say).
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
#8What makes ES6 imports static analyzable is the fact that you are forced to name exported/imported symbols individually (instead of exporting objects as with commonjs) and the fact that module identifiers have to be string literals. You can keep these 2 properties even when you'd nest imports.
In fact, there's an ES proposal form the author of reify to support this in ES, which explains this further: https://github.com/benjamn/reify/blob/master/PROPOSAL.md
Re: Tree-Shaking: A Reference Guide
#9Earlier quoted context omitted.
Adding to the confusion is this often-cited article: https://medium.com/@Rich_Harris/tree-shaking-versus-dead-cod... That article claims that "tree shaking" is different because: > Rather than excluding dead code, we’re including live code. That's a misunderstanding of the term "dead code elimination". Classic dead code elimination techniques have always worked by first identifying potentially live code and then elim…
Yeah this is just Rich Harris trying to sound smart it seems. I always had a problem with that exact quote because it's just another web-delusional attempt at reinventing the wheel with a flashier name. Tree Shaking is dead code removal. They're one and the same.
I certainly didn't _invent_ the term 'treeshaking', I merely (unwittingly) helped popularise it in the JS ecosystem. The relevant parts of the Twitter thread:
> the reality is that at the time i wrote that, when Rollup was in its early stages, minifiers empirically didn't eliminate as much code as Rollup did
> i think it's worth looking at this from the perspective of the respective terms' connotations, rather than the strictly technical definition (which i agree has been overstated; mea culpa for my part in that). DCE is something you do to programs; treeshaking is what you do to libraries. It may be the same thing, but the prevalence of the idea of treeshaking has put the onus on library authors to make their libraries DCE-able, in a way that has coincided with the adoption of ESM