I've been thinking about the long-term direction of Kotlin/Native.
Kotlin/Native already has many ingredients of a serious native language:
LLVM native compilation
direct C interoperability
pointers and native memory APIs
no JVM requirement
multiplatform support
Swift/Objective-C interoperability
much higher-level ergonomics than C
But compared with languages such as Swift, Zig, D and Rust, Kotlin/Native still has a relatively heavy runtime model for some low-level and FFI-heavy workloads.
What if Kotlin/Native eventually offered an ARC/ownership-oriented, no-GC execution mode designed specifically for native systems programming?
The goal would not simply be:
replace GC with ARC
but rather:
make memory lifetime deterministic, make native ABI boundaries thinner, and allow Kotlin/Native to operate as a true general-purpose native systems language.
Swift shows that ARC can work well for a high-level native language
Swift is probably the most obvious comparison.
Swift gives developers:
high-level language features
value types
reference types
deterministic ARC-based object lifetime
native compilation
very close integration with Objective-C and C
ARC is not free, of course. Retain/release operations have overhead, cycles still need to be handled, and compiler optimization matters enormously.
But modern compilers can perform ownership analysis and remove many unnecessary retain/release operations.
That suggests an interesting direction for Kotlin/Native:
Kotlin object semantics
β
ownership analysis
β
ARC when required
β
retain/release elimination where possible
Instead of requiring a tracing GC for all normal native object lifetime management.
Zig shows what a very thin native boundary can look like
Zig takes almost the opposite approach.
It has:
no tracing GC
explicit allocators
direct pointer-oriented memory access
first-class C ABI compatibility
native C header integration
very small runtime assumptions
For low-level FFI, the model is extremely simple:
Zig
β
C ABI
β
C library
Primitive values, pointers, structs and function pointers can cross the boundary with almost no semantic translation.
Kotlin/Native could benefit from having a similarly explicit native ABI zone.
For example:
@CAbi
external fun send(
handle: ULong,
data: CPointer<UByteVar>,
size: UInt
): Int
Ideally this could compile approximately as:
Kotlin/Native
β
LLVM direct native call
β
C ABI
with no boxing, no object conversion and no GC transition for ABI-safe types.
D shows that a high-level language can also expose a low-level mode
D is another interesting comparison.
Normal D provides a fairly rich runtime and high-level programming model.
But D also has BetterC, which allows developers to use a restricted subset of the language without relying on the full D runtime or garbage collector.
That is especially interesting for Kotlin/Native.
Kotlin/Native would not necessarily need to force every program into one memory model.
It could support something conceptually similar:
Kotlin/Native
Normal Native Mode
βββ ergonomic Kotlin objects
βββ ARC
βββ deterministic lifetime
βββ higher-level runtime services
Systems / ABI Mode
βββ no tracing GC
βββ POD types
βββ pointers
βββ slices
βββ handles
βββ function pointers
βββ explicit allocation
βββ predictable native ABI
This would be somewhat analogous to what BetterC provides for D, but designed around Kotlin's type system and compiler architecture.
The interesting combination would be
Kotlin/Native could potentially take lessons from all three languages:
Swift
β ARC
β ownership optimization
β deterministic object lifetime
Zig
β thin C ABI
β explicit low-level memory access
β minimal hidden runtime behavior
D / BetterC
β high-level language
β optional low-level runtime-free execution mode
Kotlin
β ergonomics
β coroutines
β multiplatform
β existing ecosystem
That combination could be very interesting.
FFI is where this could matter most
Today, the expensive part of native interoperability is often not the actual machine-level function call.
The expensive part is everything around it:
Kotlin object
β
runtime representation
β
pinning / stable references
β
interop wrapper
β
native ABI
For Strings, collections, callbacks and managed objects, this overhead can become significant.
A systems-oriented Kotlin/Native mode could instead encourage ABI types such as:
integers
floats
pointers
handles
POD structs
slice { pointer, length }
function pointers
Then the boundary becomes:
Idiomatic Kotlin API
β
zero-cost ABI adapter
β
C ABI
β
Rust / Zig / D / C / C++ / Swift
This would be useful for:
networking
databases
RPC frameworks
UI engines
rendering engines
game engines
audio
embedded systems
native SDKs
OS components
This would also make Kotlin/Native more independent
Today Kotlin/Native is often perceived as:
Kotlin without the JVM
I think it has the potential to become something much more ambitious:
a general-purpose native language with Kotlin's syntax and ecosystem
That would put it into a very interesting design space.
Not as strict as Rust.
Not as low-level as Zig.
Not as runtime-heavy as traditional managed languages.
And more ergonomic than C++ or D for many developers.
Something like:
Kotlin ergonomics
+
Swift-like ARC
+
Zig-like thin FFI
+
D BetterC-like systems mode
+
LLVM
+
Multiplatform
That combination doesn't really exist today.
The biggest technical question is probably whether Kotlin's existing object model and runtime could support an ARC/no-GC execution mode without fragmenting the language too much.
For people familiar with Kotlin/Native internals:
How realistic would an ARC + ownership optimization + no-GC systems mode actually be?
And would this make Kotlin/Native more attractive to you for systems programming?