
Shrinking a Kotlin Binary by 99.2% - farmerbb
https://jakewharton.com/shrinking-a-kotlin-binary/
======
brabel
If you're going to get rid of all your Kotlin std lib usages by explicitly
replacing them, after inspecting the actual class files generated by the
compiler, with standard Java methods (and hope that no future change will re-
introduce them) and you care so much about the size of your jars, I would say
you're better off simply going back to Java, perhaps using the very latest
version (since you're willing to use Kotlin that shouldn't be a problem) which
has lots of niceties and to me, at least, looks a lot better than using Kotlin
with these kinds of hacks. Add a nullability static analysis check and you're
gold.

~~~
dtech
At that point, why not use Rust or Go or D or whatever with significantly
smaller binary sizes and (un-optimized) faster speeds.

~~~
tasubotadas
Not on Android

~~~
FlyingSnake
Rust has first class support for Android.

~~~
eptcyka
Cool, so I can start a new service and bind activities to it from Rust without
having to deal with a nasty JNI or an unstable ABI that changes under my feet?

------
wnoise
> \- val old = args[0].let(::File).readText() > \- val new =
> args[1].let(::File).readText() > \+ val old =
> args[0].let(Paths::get).let(Paths::readString) > \+ val new =
> args[0].let(Paths::get).let(Paths::readString)

Missed index. 0!=1.

~~~
xvector
That’s an impressive catch. I would never have noticed this. How did you get
this good at code review?

~~~
saagarjha
It helps that the correct code is just above the buggy replacement…

------
toolslive
It used to help a lot (30-40%) to sort the class files of a librarly on
canonical name before you add them to its jar. Class files contain that name,
and are (typically) small. Your compression factor will grow. (maybe that
trick is standard now)

~~~
Jake_Wharton
Removing `-dontobfuscate` will change all the package, type, and function
names to be single letters for the same result of greater compression.

The goal here was to just get it small enough, not the smallest it could
possibly be.

------
mro_name
any idea how to get the swift upload network traffic down?

My 500K objc ipa ported to swift
[http://mro.name/ShaarliOS](http://mro.name/ShaarliOS) now is ~8MB (OTA test
ipa), ~28MB for production upload causing ~300MB traffic until finally
uploaded via xcrun, taking 1h on my rural uplink.

Has anybody an idea how to get back to sane dimensions?

------
setheron
Looks like most of the size reduction was from running R8. The rest seems
meaningless.

