Why did tree shaking as a phrase come to exist when “dead code elimination” had been around forever?
Tree-shaking, the horticulturally misguided algorithm (2023)
81–90 of 151 posts
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#82Earlier quoted context omitted.
I believe low hanging fruit is not specific to CS. Regardless, it is a perfect metaphor. You want to eat an apple: which one do you pick? Taking the low-hanging fruit is less work right now and gets you to your immediate goal, but disregards general efficiency. Sure, picking a whole tree is more efficient. But if you want a single apple, taking the low hanging fruit is the fastest approach. The metaphor works because…
As I said, it’s what amateurs do. We are not amateurs.
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#83Earlier quoted context omitted.
I believe low hanging fruit is not specific to CS. Regardless, it is a perfect metaphor. You want to eat an apple: which one do you pick? Taking the low-hanging fruit is less work right now and gets you to your immediate goal, but disregards general efficiency. Sure, picking a whole tree is more efficient. But if you want a single apple, taking the low hanging fruit is the fastest approach. The metaphor works because…
As I said, it’s what amateurs do. We are not amateurs.
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#84Tree-shaking is such a bad misnomer. Virgil's compiler calls this "reachability analysis" and it's built into the compilation model. The compiler will parse and typecheck a program's (and libraries' code), and run initializers, but after that the compilation proceeds by exploring from the main entrypoint(s) and only reachable code is analyzed and ends in the final binary. It will happily generate a program (without r…
I don't think so. I never considered tree-shaking to refer to the plants, rather the data structure.
If you imagine the diagram of some source code as a physical object, then shaking it would cause anything unreachable from the root to fall away.
I really don't see how reachability analysis is any different. One term just invokes a more spacial sense of reasoning.
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#85This article is very correct: Wasm has a code size problem. This is a problem in browsers because all that code has to be downloaded to start the site. It's also a problem for serverless architectures, where code is often loaded from cold storage to a specific server on-demand while a client waits. Tree-shaking might help, but I feel like it's only an incremental optimization. Fundamentally the reason Wasm programs a…
Lot I don't know about how browsers are shipped, but it seems to me like browsers could easily get away with packing in a few languages and their STLs as part of their default installs. Python is what, 25MB? Would another couple hundred megs of disk space be such a big deal?
Being able to cache runtimes and libraries like that across sites would be nice, though (but probably enables fingerprinting, so one Python runtime per origin it is).
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#86Another example - flutter can tree shake unused icons/glyphs from fonts - https://www.reddit.com/r/FlutterDev/comments/f4h3l9/tree_sha...
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#87Earlier quoted context omitted.
dead branches and loose leaves are connected to a real tree in the same way that dead code is connected to the program in a file. if you break off the dead branch, nothing happens to the tree, just like when you remove unused code, nothing happens to the program.
> if you break of the dead branch, nothing happens to the tree, just like when you remove unused code, nothing happens to the program. Indeed, and this has been known since the 80s as dead code elimination. So why are we using a new, less descriptive, more confusing term again?
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#88Earlier quoted context omitted.
I believe low hanging fruit is not specific to CS. Regardless, it is a perfect metaphor. You want to eat an apple: which one do you pick? Taking the low-hanging fruit is less work right now and gets you to your immediate goal, but disregards general efficiency. Sure, picking a whole tree is more efficient. But if you want a single apple, taking the low hanging fruit is the fastest approach. The metaphor works because…
As I said, it’s what amateurs do. We are not amateurs.
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#89Tree-shaking is such a bad misnomer. Virgil's compiler calls this "reachability analysis" and it's built into the compilation model. The compiler will parse and typecheck a program's (and libraries' code), and run initializers, but after that the compilation proceeds by exploring from the main entrypoint(s) and only reachable code is analyzed and ends in the final binary. It will happily generate a program (without r…
> Tree-shaking is such a bad misnomer. I don't think so. I never considered tree-shaking to refer to the plants, rather the data structure. If you imagine the diagram of some source code as a physical object, then shaking it would cause anything unreachable from the root to fall away. I really don't see how reachability analysis is any different. One term just invokes a more spacial sense of reasoning.
Re: Tree-shaking, the horticulturally misguided algorithm (2023)
#90Tree-shaking is such a bad misnomer. Virgil's compiler calls this "reachability analysis" and it's built into the compilation model. The compiler will parse and typecheck a program's (and libraries' code), and run initializers, but after that the compilation proceeds by exploring from the main entrypoint(s) and only reachable code is analyzed and ends in the final binary. It will happily generate a program (without r…
Many things in software are misnomers. Personally, I think it’s an amazing name. The first time I saw the term, I knew exactly what it was without any further research. You shake a tree to remove the loose things. In this case, it was clear that unused packages are being “shaken” from the tree.
But it's an ok term overall.