3 ms·
Unfortunately you can't treeshake a language that supports reflections. So it's not like a C++ program where unused parts get dropped. You can manually remove
by contrarian1234 3y ago
Unfortunately you can't treeshake a language that supports reflections. So it's not like a C++ program where unused parts get dropped.
You can manually remove dependencies or.. I think in the Android world you specify what classes can be reflected on and then strip unused code with Proguard (though I could never get it working with Clojure)
Would love to be corrected if I got any of it wrong
- koolba 3y ago> Unfortunately you can't treeshake a language that supports reflections. I’m pretty sure that’s exactly what the Google Closure Compiler does: https://developers.google.com/closure/compiler/docs/limitations https://developers.google.com/closure/compiler/docs/limitati... Though it has a ton of restrictions on how you write code and how you can use reflection.
- izacus 3y agoI'm afraid you did get it wrong - it's very standard to do that on all Android apps. The part that you missed is that reflection is rarely used in production apps (partially because for a long time, reflection was VERY expensive on Dalvik/ART runtimes) and can be easily handled by configuration for minifier/optimizer to explicitly keep code. Even C++ you mention does that - you have explicit __attribute__ calls to avoid linker from dropping code you want to keep for reflection purposes.
- meindnoch 3y ago>Unfortunately you can't treeshake a language that supports reflections. Like JavaScript?
- gkbrk 3y agoYes, you can't treeshake Javascript. You can treeshake a subset of Javascript. If you are limiting tooling to subsets, you can also compile subsets of Python or Javascript to machine code.
- pjmlp 3y agoYou surely can, it is a thing since Smalltalk and Common Lisp images. On Java's case, all AOT toolchains and embedded deployment workflows have supported similar capabilities.