My "hello world" fat jar is 1.6Mb... Is there any ...
# announcements
v
My "hello world" fat jar is 1.6Mb... Is there any way of shrinking this down? I'm hoping to build an app for a Raspberry Pi, and will choose between Kotlin, C (or even assembly!) for programming it.
a
The kotlin stdlib is 1.4mb, so not sure you can get it much smaller, unless there are some special extra optimizations...
b
What about kotlin hello world in kotlin native?
j
Yes there is a way. But... what are the criteria for picking one or other implementation language? Why does it matter that the jar file is xMb? A Pi has 4Gb (ish) - yes it could be smaller, but unless the constraints are expressed it is not possible to know if the change is meaningful.
v
I may look at Kotlin native in the future, yes. I'm also learning ARM assembly, so I've gone from a <1Kb assembly file to a 1.6Mb JAR for the same functionality. Just a bit of a shock :)
m
I think I saw somewhere a post about being able to compile without the standard library. But then you don't have the standard library... Not sure if it's really that important to save such a small amount of space.
Meanwhile most (end user) deployment strategies involve bundling an entire JVM with your app.
j
☝️ 2
👍 2
🤯 1
👏 1
n
File sizes for Kotlin Native binaries (of the ELF type - https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) with a hello world type program using the linuxX64 target: • Release Binary: 368 KB • Debug Binary: 1368 KB
Note that Kotlin Native isn't heavily optimised yet, and is heavily reliant on the LLVM toolchain generating small sized binaries.
I am involved in two commercial projects with one using Kotlin JVM, and the other using Kotlin Native. By contrast there are dramatic differences in file size with Kotlin Native coming out on top by a wide margin: • Kotlin Native Release Binary: 2048 KB • Kotlin Native Debug Binary - 5452 KB • Kotlin JVM JAR File - 17140 KB Some C libraries are statically linked in the Kotlin Native binaries. Most C libraries are dynamically linked in the binaries.