For now Kotlin/Native generates order of magnitude...
# kotlin-native
m
For now Kotlin/Native generates order of magnitude bigger and slower code compared to plain C equivalent.
n
How much bigger (code, runtime and standard lib size) is Kotlin Native than C? Very important to have some basic Kotlin Native CLI profiling tools to measure performance in a number of different areas. Some of the areas covered by the profiling tools would include code size (as mentioned ☝️), memory (RAM) consumption separated by stack/heap and element type (classes, objects, variables, constants etc), CPU usage, number of times the Kotlin Native program blocks and how long each block occurs (concurrency).
m
Last time I measured - it was approx 20x times bigger.
Not counting stdlib, just code generated by compiler.
n
Does Konan do any dead code elimination?
n
Does the upcoming Kotlin Native benchmark tools cover code size?
Real need to have a basic Kotlin Native sample which is suitable as a reference point for benchmarks (incl code size).
m
That "blink led" sample is quite real - it's like "hello world" for microcontrollers.
n
What is the target hw (is it targeting the Rpi)? Does the Kotlin code size include the Kotlin Native runtime and std lib?
m
No, I compiled it on windows host for windows target, x86-64. For another targets both sizes will change, so difference will be the same, more or less. And no, I do not count stdlib, so difference really is even worse.
o
guess this kind of measurement is close to useless, when comparing text segment for trivial C and Kotlin programs, probably bigger size application having data structures and computations shall be compared
m
what data structures? it counts only size of "main" (89 bytes) and "Konan_start" (1004 bytes).
o
usually maps, list, sets are considered data structures
m
did you see that repository? disassemled listings of relevant procedures do not include any of this maps, sets etc.
o
sure, but the point is, that to meaningfully compare size of programs, they have to do something valuable, for example manipulate with some data structures
m
microcontrollers do not manipulate that structures, it manipulate io ports.
Question was "is K/N usable in Ucs?" - answer is "no, for now". In many other use cases answer is different, of course.
n
Isn't a language unusable without a standard lib (covers all basic data types, basic debugging via print..., basic collection functionality etc)?
There are other languages like Python (via Micro Python) which have been successfully ported to uCs (

https://www.youtube.com/watch?v=zYAUl1lqapU

). Kotlin SHOULD be portable to some ARM based uCs with the right changes under the hood in due time... 🕐 . Put it this way since JS can run on some uCs 😲 (

https://www.youtube.com/watch?v=j1TsCmDhFtk

) 🏃 it is possible to write some embedded programs using a high level language, which will run on some uCs.
My point about the need for Kotlin Native profiling tools still stands, and has been validated with some of the previous messages. Currently there is no easy/accurate way to determine resource usage of a Kotlin Native program (eg CPU usage, RAM used, code size). It is like navigating a room in the dark 🕶️ (inaccurate), which when translated to Kotlin Native development isn't a good way to determine if a Kotlin Native program is using too many resources or not (guessing doesn't work well).