|
|
|
|
|
by Eridrus
4000 days ago
|
|
Dart makes a decent argument for a smarter compiler. They've implemented "Tree Shaking" in their compiler: essentially cross-library dead code elimination. This would probably be quite tricky in Java land where reflection does add new entry points, but it could be used to solve the problem of "I only need this one function from this library, don't compile in anything else". I was personally quite surprised when I ported from code from Node to Java/Groovy and the resulting shaded JAR was > 70MB, I think at some point it peaked above 110MB. I don't know what I changed, but it's down to 35MB now. But the code that we've written in house on that codebase boils down to 1MB. But besides figuring out that I don't want to make local builds I scp to staging (because scp is terrible), these numbers are all completely equivalent for writing server-side software that runs on dedicated machines. We could certainly make it more efficient, but there's exactly zero business case for it. |
|
Every normal compiler implements simple (i.e. module level) dead-code elimination already.
EDIT: Of course you could use static libs, which does pull in only used symbols, but then you cannot share them across apps and update independently.
I implemented a tree shaker for my lisp and was very happy with it, esp. for delivery. Like Go does it nowadays.