https://kotlinlang.org logo
Join Slack
Powered by
# forum
  • r

    rss

    10/12/2025, 6:39 PM
    A syntax-level support for reactive ref type A reactive pipeline is very commonly used in various sicarios. In frontend development, we use such pipelines to bind the states and views in many ways. For example, we have ref and computed in Vue. We have re-executing mechanism in React and Compose. In server side development, we use streams and flows to process sequential data. However, to define the reactive pipeline is not that intuitive. For example, to define c=a+b, we have to write a lambda with explicit specifications. The lambda...
  • r

    rss

    10/13/2025, 7:59 AM
    Is it possible to configure demand delivery in KMP project I’m working on a Kotlin Multiplatform (KMP) project and want to explore whether it’s possible to configure on-demand feature delivery, similar to Android’s Play Feature Delivery or Play Asset Delivery. The idea is that we have a super app consisting of multiple modules say four independent apps/features and I want to separate each one so that when the user selects a specific app, it’s downloaded on demand and then opened directly within the same super app. I’d like to know: Can a KMP...
  • r

    rss

    10/13/2025, 10:19 AM
    I need guidence regarding navigation in KMP We have a native Android app that is mostly WebViews and uses Jetpack Navigation. We want to start migrating to fully native screens using Kotlin Multiplatform (KMP) to share both logic and UI between Android and iOS. None of us on the dev team has prior KMP experience. My assumption is the following: we could create a KMP module for, say, SSO, which uses <a href="https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-navigation-routing.html" rel="noopener nofollow ugc">Compose...
  • r

    rss

    10/15/2025, 6:39 AM
    C++ Library for Desktop Build I just started to learn KMP and I want to see how to integrate C++ code into my project. I successfully edited the build.gradle.kts to build a C++ library for Android and have called a JNI function in the library. // composeApp/build.gradle.kts android { ... externalNativeBuild { cmake { path = file("src/main/cpp/CMakeLists.txt") version = "3.22.1" } } But the desktop version is not able to do the same. If it helps. So far I added the...
  • r

    rss

    10/16/2025, 10:19 PM
    Delete / clear account I like to periodically scrub my online presence. I don’t mind the content going on to exist, but I would like the username to be replaced by [deleted account] or something similar. The profile page doesn’t allow me to edit things like user handle or delete the entire account. Please make that an option. 1 post - 1 participant Read full topic
  • r

    rss

    10/20/2025, 12:19 PM
    Errors running kotlin class from comd-line hello everyone, I’m trying to run a kotlin class from CLI(Kotlin command-line compiler | Kotlin Documentation), but I get some errors: <a class="lightbox" href="

    https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/f/f438507ef51a0277699e86512589ac5b9ca5d72f.png▾

    " data-download-href="/uploads/short-url/yQt9FkSlyIuDtl0KwFEiQ12KAgL.png?dl=1" title="image" rel="noopener...
  • r

    rss

    10/23/2025, 8:39 AM
    Real-world health &amp; posture app built with Compose Multiplatform + Ktor (Android, iOS, Backend) Hi everyone I wanted to share my production app StandProud — a real-world fitness app focused on posture correction and back-health improvement, built entirely with Compose Multiplatform and Ktor (Android, iOS, and backend). The app helps users improve posture and reduce back pain through science-based workouts. It’s already live on both app stores and running in production. Tech stack: Compose Multiplatform (UI), Kotlin Multiplatform architecture, Ktor backend (Google Cloud Run +...
  • r

    rss

    10/24/2025, 11:49 PM
    How to use SQLite without GUI? only print console With the GUI, everything is fine, but when I try to do it without the GUI, I get errors. Is this possible? I'm new to Kotlin. Thank you very much. 1 post - 1 participant Read full topic
  • r

    rss

    10/27/2025, 2:59 AM
    Should I convert from Groovy DSL to Kotlin DSL? I have an Android application with Groovy DSL. Should I convert it to Kotlin DSL, and does anyone know how to convert from Groovy to Kotlin? 1 post - 1 participant Read full topic
  • r

    rss

    10/27/2025, 5:39 AM
    Error on pausing / resuming / stoping the audio class AudioSource constructor ( context: Context ){ private val mediaRecorder = MediaRecorder(context) private val outputFile = File(context.getExternalFilesDir(Environment.DIRECTORY_MUSIC),"sample.mp4") fun start(): String? { try { mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC) mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP) mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB)...
  • r

    rss

    10/27/2025, 6:19 AM
    What's an idiomatic way to name a function that takes `() -&gt; Unit` vs `suspend () -&gt; Unit` I’m trying to get up to speed with Kotlin. One of the things I keep hitting snags with is how functions and suspend functions feel like oil and water and don’t mix. For example if I wanted to wrap some code like this: time { doSomething } I apparently can’t have it work regardless of whether doSomething is suspend or not: package meh; // I'm not really trying to time code; I'm actually trying to specialize assertFails // This is just a minimum reproducible program that demonstrates where...
  • r

    rss

    10/28/2025, 4:59 PM
    Understanding Primitive Classes in Kotlin In Kotlin, everything looks like an object, but behind the scenes, the compiler is smart enough to use primitive types where possible for better performance. Let’s explore how Kotlin’s primitive-like classes such as Int, Double, Boolean, and String actually work. What Are Primitive Classes? Primitive classes in Kotlin are lightweight, built-in types that represent basic data. They behave like objects but are compiled down to primitives (like int, double) on the JVM for efficiency. Example:...
  • r

    rss

    10/31/2025, 12:49 PM
    withContext breaks coroutine supervision I have the following exception handler (just as example): class StatefulCoroutineExceptionHandler( private val logging: Boolean ) : CoroutineExceptionHandler { val throwables = mutableListOf() override val key: CoroutineContext.Key = CoroutineExceptionHandler.Key override fun handleException( context: CoroutineContext, exception: Throwable, ) { if (logging) { log.error("{} - {}", exception.javaClass.canonicalName, exception.message)...
  • r

    rss

    10/31/2025, 2:09 PM
    BOB Conference 2026 - Call for Contributions, Early tickets available https://discuss.kotlinlang.org/#p-80208-what-happens-when-we-use-whats-best-for-a-change-1“What happens when we use what’s best for a change?” https://bobkonf.de/2026/cfc.html Berlin, Mar 13 Deadline: November 17, 2025 <a name="p-80208-looking-for-speakers-2" class="anchor"...
  • r

    rss

    11/02/2025, 4:09 PM
    Problem of mutating data class for use in Jetpack Compose The problem: The difficulty of maintaining the “stability” of large classes for Compose and mutability. The inevitability of the boilerplate code. I ran into the problem that Kotlin together with Jetpack Compose cannot handle working with large data models. Real cases often requires the declaration of many large classes in which there are several dozen fields. Example: Let’s imagine that we have a report document that contains many tables, lists, calculations and about 400 fields in total....
  • r

    rss

    11/04/2025, 6:49 AM
    Using multiple KMP modules in Swift For simplicity’s sake let’s consider a following dependency graph: kmpA (depends on kmpB) kmpB (no deps) swiftC (depends on kmpA and swiftD) swiftD (depends on kmpB) I’m trying to pass an object of type X (declared in kmpB) from swiftC to swiftD. Looking at mismatch type compiler error it seems that when kmpA and kmpB are built into xcframework they both expose type X with a different prefix kmpAX and kmpBX so essentially compiler sees them as 2 different types even though they have a...
  • r

    rss

    11/10/2025, 3:49 PM
    I am a beginner for Kotlin fun main() { var heightAlice = 160 val heightBob = 175 val taller = if (heightAlice < heightBob) { print("Choose Alice\n") heightAlice=10 } else { print("Choose Bob\n") heightBob } println("Taller height is $taller") println("value changed heightAlice : $heightAlice") } /* How to work : heightAlice value assigned 10, But -> println("Taller height is $taller") output is : kotlin.Unit The heightAlice : 10 value is changed....
  • r

    rss

    11/10/2025, 11:29 PM
    Segfault crash invoking kotlinc-native (konan) Hello, I would like to use Kotlin as native language. So, I create a simple file and invoke a compiler: $ kotlinc-native -version Current kotlin-native dir: /nix/store/-kotlin-native-2.2.21 New writeable kotlin-native dir: /tmp/tmp.tvikhlq2fN info: kotlinc-native 2.2.21 (JRE 21.0.9+8-nixos) Kotlin/Native: 2.2.21 But the compiler crashed for no known reason $ kotlinc-native Main.kt -o main # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at...
  • r

    rss

    11/16/2025, 5:09 PM
    JVM dependencies are not clear to me, esp. Regex Hi, as a Kotlin beginner, I am not sure what I can use when I want to create a JVM independent library. I try to use only the “Common part” of the documentation, as for my purposes this seems feasable avoiding implementing platform-dependent expect/actual code myself. But its hard to find out if I am doing this correctly. For example, I need Regex. There seems to be a JVM Regex implementation, and there is also kotlin.text.Regex. And Regex is described in the Kotlin documentation. So what...
  • r

    rss

    11/20/2025, 9:09 AM
    Capturing context parameter I am investigating the new feature of kotlin, Context parameters. In some edge situations, you may have a block of code that has accessible some context(s), which are however not directly accessible (not bound to any variable). They are available only for propagating when function with context parameter is called. Is there some idiomatic way how to access such anonymous context? To do it, I created a little helper that is as easy as context(context: C) inline fun captureContext() = context...
  • r

    rss

    11/21/2025, 11:49 AM
    Parse Kotlin build.gradle.kts Script via ScriptDefinition Use Case: OpenRewrite is a tool to performce large-scale code migrations/refactorings which leverages parsing Java/Groovy/Kotlin sources and performing modifications on them. For Kotlin you can find the parsing code in <a href="https://github.com/openrewrite/rewrite/blob/e268a630f35f4c7227af44fa53172e9e5d8fc412/rewrite-kotlin/src/main/java/org/openrewrite/kotlin/KotlinParser.java#L383" rel="noopener nofollow...
  • r

    rss

    11/25/2025, 1:29 PM
    Why does takeIf allow nullable receivers in its predicate? The signature of takeIf (and takeUnless) is: public inline fun T.takeIf(predicate: (T) -> Boolean): T? instead of: public inline fun T?.takeIf(predicate: (T) -> Boolean): T? Why does Kotlin allow null as a possible value passed to the predicate? What is the rationale for not restricting T to non-null types? 1 post - 1 participant Read full topic
  • r

    rss

    11/26/2025, 12:09 AM
    Empty Main function I read online that the Main function is the starting point of the program. Is it possible to start a Kotlin program with an empty Main function, that is, fun Main(), & nothing else? I’m intrigued about Kotlin & I’m eager to start learning it. I’ve already installed IntelliJ on my Mac. 1 post - 1 participant Read full topic
  • r

    rss

    11/28/2025, 4:29 AM
    What are the differences between Kotlin Multiplatform &amp; Compose Multiplatform? I installed IntelliJ on my Mac. I have a book on Kotlin programming. I’m learning Kotlin! I’ve explored different programming languages - BASIC(before it became Visual Basic), Visual Basic, Turbo Pascal, & Java. Java is so verbose. On Basic, I did some programs that plotted parametric equations. That’s what I’m primarily interested in doing - graphics programs like parametric equations, fractals, trig functions. I read online that Java Swing & AWT are obsolete. Yet a website stated that they...
  • r

    rss

    11/28/2025, 1:49 PM
    Suggested new construct for tight code If you have an algorithm that is already O(n^2), that’s already bad. But if your inner loop creates new objects that need to be garbage-collected, that’s terrible! Here’s a suggestion how we could help both the programmer and the compiler to deal with tight loops by introducing a new construct that restricts a block of code such that no new objects must be created. fun doSomething() { val stuff = Stuff() // new object, OK, outside tight block tight { val arr = stuff.data // getter...
  • r

    rss

    11/29/2025, 2:09 AM
    I’d like to be able to plot trig functions &amp; fractals &amp; parametric equations on Kotlin I’d like to be able to plot trig functions & fractals & parametric equations on Kotlin. I read about Let’s Plot. Back when Basic was Basic & not Visual Basic, I created programs that plotted parametric equations. It was right neat watching the equations be plotted. That’s what I’d like to with Kotlin. I’d like to create a window with buttons & text boxes so that I can put in X & Y coordinates & degrees(not radians) & see the plots drawn. I guess that Kotlin out-of-the-box cannot plot...
  • r

    rss

    12/03/2025, 2:59 PM
    Extra branches in the when statement (coverage) Trying to get code coverage with a “when” expression using Kover or Intellij Coverage Plugin. There are always extra branches that prevent you from achieving 100% coverage. For example, the Intellij Coverage plugin and Kover show 9 branches: private fun replaceGuid(guid: String): String { return when (guid) { "11" -> "11" "22" -> "22" "33" -> "33" else -> guid } } If you rewrite the condition using “if”, there will be 4...
  • r

    rss

    12/04/2025, 8:59 PM
    Idiomatic way how to implement Java interface properties in kotlin? I didn’t find any detailed information about the rules how public getters of kotlin properties interoperate with inherited java methods. For instance, I have Java interface: public interface JavaNamed { String getName(); } I want to implement it in Kotlin using simple property. What is the easiest and most idiomatic way to do it? This does not work: class KotlinNamed(override val name: String): JavaNamed Surprise, name overrides nothing. This does not work either: class...
  • r

    rss

    12/05/2025, 1:19 PM
    LongRange.count() returns Int and cause an Exception There is a LongRange, which exposes a method count(), by Iterable extension: package kotlin.collections // file: _Collections.kt public fun Iterable.count(): Int { if (this is Collection) return size var count = 0 for (element in this) checkCountOverflow(++count) return count } But calling this method may cause an exception, as the return type is Int. Example: Exception in thread "main" java.lang.ArithmeticException: Count overflow has happened. at...
  • r

    rss

    12/05/2025, 11:59 PM
    KMP iOS integration We are starting to look at using KMP for code sharing between our Android and iOS apps. As we get hands-on with a POC, I was wondering if people has any resources that could help us accelerate our understanding of what it takes to adopt KMP in iOS apps. I’m talking about the “gotchas”, “painpoints”, and surprised that iOS devs usually run into. I personally expect that adopting KMP could have a DevX impact for iOS devs. Any resources or thoughts you can share? 1 post - 1...