Re:Farm: Fast vite compatible build tool written in Rust
by IshKebab on Saturday June 22, 2024 @02:37AM
(#40756906)
I would just use "dead code elimination" instead. They're the same but that actually tells you what it is.
[ Parent
| on HN ]
Re:Farm: Fast vite compatible build tool written in Rust
by aaaaaaabbbbbb on Saturday June 22, 2024 @02:42AM
(#40756933)
Since tree-shaking is a common term across frontend build tooling documentation, I adopted it as well.
Dead code elimination in its traditional form also runs during code minification, which is a separate build step from bundler tree shaking. Having separate terms avoids ambiguity.
Re:Farm: Fast vite compatible build tool written in Rust
by egeozcan on Saturday June 22, 2024 @08:04AM
(#40758448)
Tree shaking is the removal of unused exports, a very specific thing for JS. Dead code elimination is a broader term which includes tree shaking, but is usually used for the elimination of code after the compilation (or transpilation/minification in js/ts case) in the front-end world.
A practical example would be that tree-shaking wouldn't remove the variable b in "export function foo(x) { let b = 10; let a = 20; return x + a; }" but if this export isn't imported anywhere, then it would remove the whole function definition. Uglify.js, which does dead code elimination would remove the unused b variable.
Re:Farm: Fast vite compatible build tool written in Rust
by IshKebab on Saturday June 22, 2024 @03:49PM
(#40761630)
Sure, tree shaking is just a very basic dead code elimination algorithm. But there's no reason to give it such a prominent and confusing name. Just call it "basic dead code elimination"! If you must be specific (why?) call it "dead export elimination".
Re:Farm: Fast vite compatible build tool written in Rust
by egeozcan on Saturday June 22, 2024 @04:22PM
(#40761877)
I don't disagree with you, but on the other hand, it was really a hard problem in js (partly because functions having outside context and mainly because how mutable modules are (were, with commonjs)), so it became a huge race for optimization. Now it's really mostly dead code elimination because how much saner es modules are yet the name stays. But hey, we also don't call televisions "bigger monitors with built in spying OSS", names have a tendency to stick :)