# Language Design

**URL:** https://discuss.kotlinlang.org/c/language-design/9.md

[Latest](https://discuss.kotlinlang.org/latest.md) · [Categories](https://discuss.kotlinlang.org/categories.md)

---

## [About the Language Design category](https://discuss.kotlinlang.org/t/about-the-language-design-category/1336)

<div class="topic-metadata">

**Author:** [@Roman\_Belov](https://discuss.kotlinlang.org/u/Roman_Belov)\
**Replies:** 0\
**Last updated:** [December 4, 2015, 7:56am UTC](https://discuss.kotlinlang.org/t/about-the-language-design-category/1336 "2015-12-04T07:56:42Z")

</div>

Discussions around the Kotlin language itself. See also related channels in Kotlin Slack (you can sign up here): #language-proposals #language-evolution

---

## [Writing an x86 disassembler in Kotlin/Native is making me lose my mind (KT-90596)](https://discuss.kotlinlang.org/t/writing-an-x86-disassembler-in-kotlin-native-is-making-me-lose-my-mind-kt-90596/31267)

<div class="topic-metadata">

**Author:** [@nooraldeenhello](https://discuss.kotlinlang.org/u/nooraldeenhello)\
**Replies:** 2\
**Last updated:** [October 23, 2026, 10:25am UTC](https://discuss.kotlinlang.org/t/writing-an-x86-disassembler-in-kotlin-native-is-making-me-lose-my-mind-kt-90596/31267 "2026-10-23T10:25:07Z")

</div>

Hey everyone, I’m currently writing a standalone, bare-metal x86-64 machine code disassembler and binary reverse engineering engine completely from scratch in pure Kotlin/Native (targeting Windows mingwX64). I chose Ko…

---

## [Trailing lambda for get operator](https://discuss.kotlinlang.org/t/trailing-lambda-for-get-operator/31235)

<div class="topic-metadata">

**Author:** [@Landei](https://discuss.kotlinlang.org/u/Landei)\
**Replies:** 1\
**Last updated:** [September 26, 2026, 9:06am UTC](https://discuss.kotlinlang.org/t/trailing-lambda-for-get-operator/31235 "2026-09-26T09:06:03Z")

</div>

I wrote some code like this: class Cache\<K, V\>(val capacity: Int = 10) { val cache = LinkedHashMap\<K,V\>() fun invalidate(key: K) = cache.remove(key) operator fun get(key: K, onCacheMiss: () -\> V): V = …

---

## [Safe cast a nullable property based on another property value](https://discuss.kotlinlang.org/t/safe-cast-a-nullable-property-based-on-another-property-value/31231)

<div class="topic-metadata">

**Author:** [@MIha\_Markic](https://discuss.kotlinlang.org/u/MIha_Markic)\
**Replies:** 7\
**Last updated:** [September 25, 2026, 6:43am UTC](https://discuss.kotlinlang.org/t/safe-cast-a-nullable-property-based-on-another-property-value/31231 "2026-09-25T06:43:38Z")

</div>

Imagine this class data class Something(val text: String?) { val hasText get() = text != null } and then this code val s = Something("something") if (s.hasText) { val text: String = s.text } Which will fail to co…

---

## [What happened to Amper?](https://discuss.kotlinlang.org/t/what-happened-to-amper/31109)

<div class="topic-metadata">

**Author:** [@Landei](https://discuss.kotlinlang.org/u/Landei)\
**Replies:** 5\
**Last updated:** [August 8, 2026, 9:42pm UTC](https://discuss.kotlinlang.org/t/what-happened-to-amper/31109 "2026-08-08T21:42:16Z")

</div>

I looked for current videos about Amper, nothing. It didn’t seem to be a topic in the KotlinConf, there is no promotion of it, and I couldn’t find a roadmap. Instead, I saw a video about “declarative Gradle”. Honestly, t…

---

## [Is there C# unsafe code like in kotlin?](https://discuss.kotlinlang.org/t/is-there-c-unsafe-code-like-in-kotlin/31138)

<div class="topic-metadata">

**Author:** [@MIha\_Markic](https://discuss.kotlinlang.org/u/MIha_Markic)\
**Replies:** 9\
**Last updated:** [July 30, 2026, 12:53pm UTC](https://discuss.kotlinlang.org/t/is-there-c-unsafe-code-like-in-kotlin/31138 "2026-07-30T12:53:49Z")

</div>

C# has an unsafe keyword which allow for more dangerous and low-level access to data. Is there something similar in kotlin? I couldn’t find anything related so far.

---

## [I am a beginner for Kotlin](https://discuss.kotlinlang.org/t/i-am-a-beginner-for-kotlin/30851)

<div class="topic-metadata">

**Author:** [@balakrishnanultra01](https://discuss.kotlinlang.org/u/balakrishnanultra01)\
**Replies:** 8\
**Last updated:** [July 18, 2026, 12:12pm UTC](https://discuss.kotlinlang.org/t/i-am-a-beginner-for-kotlin/30851 "2026-07-18T12:12:16Z")

</div>

fun main() { var heightAlice = 160 val heightBob = 175 val taller = if (heightAlice \< heightBob) { print("Choose Alice\\n") heightAlice=10 } else { print("Choose Bob\\n") …

---

## [Feature request: Something like C#'s LINQ](https://discuss.kotlinlang.org/t/feature-request-something-like-c-s-linq/20069)

<div class="topic-metadata">

**Author:** [@Kotlinius](https://discuss.kotlinlang.org/u/Kotlinius)\
**Replies:** 16\
**Last updated:** [July 18, 2026, 11:32am UTC](https://discuss.kotlinlang.org/t/feature-request-something-like-c-s-linq/20069 "2026-07-18T11:32:24Z")

</div>

Discussed how to build SQL queries with code in this topic, but figured out that this is not really possible to do in a nice way. We can’t build SQL natively in the language, as @mtimmerm explained in the other topic: T…

---

## [Nameof to get names of program elements](https://discuss.kotlinlang.org/t/nameof-to-get-names-of-program-elements/1518)

<div class="topic-metadata">

**Author:** [@medium](https://discuss.kotlinlang.org/u/medium)\
**Replies:** 15\
**Last updated:** [July 17, 2026, 10:37am UTC](https://discuss.kotlinlang.org/t/nameof-to-get-names-of-program-elements/1518 "2026-07-17T10:37:25Z")

</div>

C# has a really nice feature called nameof. With this expression you can get the name of a program element in a safe way without repeating it as a string. Example: fun process(customer: Customer) { checkArgument(cu…

---

## [The require function should be: fun require(value: Boolean, lazyMessage: () -\> String)](https://discuss.kotlinlang.org/t/the-require-function-should-be-fun-require-value-boolean-lazymessage-string/31074)

<div class="topic-metadata">

**Author:** [@aweiss](https://discuss.kotlinlang.org/u/aweiss)\
**Replies:** 3\
**Last updated:** [May 29, 2026, 8:42am UTC](https://discuss.kotlinlang.org/t/the-require-function-should-be-fun-require-value-boolean-lazymessage-string/31074 "2026-05-29T08:42:07Z")

</div>

Hi all, I think the current require function with the lazyMessage allows unintentional usage. This is it: @kotlin.internal.InlineOnly public inline fun require(value: Boolean, lazyMessage: () -\> Any): Unit { contr…

---

## [Rust-style variable shadowing](https://discuss.kotlinlang.org/t/rust-style-variable-shadowing/16338)

<div class="topic-metadata">

**Author:** [@lkowarschick](https://discuss.kotlinlang.org/u/lkowarschick)\
**Replies:** 52\
**Last updated:** [May 14, 2026, 1:35pm UTC](https://discuss.kotlinlang.org/t/rust-style-variable-shadowing/16338 "2026-05-14T13:35:41Z")

</div>

Preface Having worked with Rust recently, I’ve come to like one very specific feature a lot: Variable shadowing. In rust it is possible to shadow variable names without warnings or errors, even in the same scope, and I …

---

## [What is the receiver supposed to be in a \`withContext\` block (and an extension function)?](https://discuss.kotlinlang.org/t/what-is-the-receiver-supposed-to-be-in-a-withcontext-block-and-an-extension-function/31031)

<div class="topic-metadata">

**Author:** [@nikclayton](https://discuss.kotlinlang.org/u/nikclayton)\
**Replies:** 5\
**Last updated:** [April 20, 2026, 1:27pm UTC](https://discuss.kotlinlang.org/t/what-is-the-receiver-supposed-to-be-in-a-withcontext-block-and-an-extension-function/31031 "2026-04-20T13:27:30Z")

</div>

What is the receiver supposed to be in a withContext block in an extension function? Consider the following example: import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines…

---

## [Null-safety and initialization order](https://discuss.kotlinlang.org/t/null-safety-and-initialization-order/27616)

<div class="topic-metadata">

**Author:** [@dsh2](https://discuss.kotlinlang.org/u/dsh2)\
**Replies:** 15\
**Last updated:** [April 1, 2026, 2:40pm UTC](https://discuss.kotlinlang.org/t/null-safety-and-initialization-order/27616 "2026-04-01T14:40:31Z")

</div>

Dear community, what have I understood wrong about null-safety, if I’m surprised that the following code is causing a NullPointerException? (cf. play.kotlinlang.org/) class DelusiveNullSafety { init { accessProper…

---

## [Kotlin incorrectly uses getters for private fields in open classes](https://discuss.kotlinlang.org/t/kotlin-incorrectly-uses-getters-for-private-fields-in-open-classes/30981)

<div class="topic-metadata">

**Author:** [@MooingDuck](https://discuss.kotlinlang.org/u/MooingDuck)\
**Replies:** 2\
**Last updated:** [March 6, 2026, 7:02pm UTC](https://discuss.kotlinlang.org/t/kotlin-incorrectly-uses-getters-for-private-fields-in-open-classes/30981 "2026-03-06T19:02:42Z")

</div>

@InternalState open class ImmutableIntIntArrayMap { private val map: LongArray @Cache private var lastEntryIndex = 0 ... @Pure fun getLastEntry() = Entry(map\[lastEntryIndex\]) } My code is using a Purity ch…

---

## [Sequences and Inlined Lambdas](https://discuss.kotlinlang.org/t/sequences-and-inlined-lambdas/17228)

<div class="topic-metadata">

**Author:** [@derektom14](https://discuss.kotlinlang.org/u/derektom14)\
**Replies:** 26\
**Last updated:** [March 5, 2026, 7:29pm UTC](https://discuss.kotlinlang.org/t/sequences-and-inlined-lambdas/17228 "2026-03-05T19:29:10Z")

</div>

Suppose you want to do the very common operation of applying a filter and a mapping to a list, and you want the code to be very efficient. The most obvious first solution is to write: val processedItemNames = items …

---

## [Null-safe Nested Map Navigation](https://discuss.kotlinlang.org/t/null-safe-nested-map-navigation/6935)

<div class="topic-metadata">

**Author:** [@sohrab](https://discuss.kotlinlang.org/u/sohrab)\
**Replies:** 3\
**Last updated:** [February 13, 2026, 10:22am UTC](https://discuss.kotlinlang.org/t/null-safe-nested-map-navigation/6935 "2026-02-13T10:22:22Z")

</div>

Is there an idiomatic way of doing null-safe navigation through nested maps? I am trying to move our guys to Kotlin from a lot of Groovy transformations involving JSONs (and no POJOs/POGOs/Data classes). So far it was n…

---

## [Braces : block code and lambda confusion](https://discuss.kotlinlang.org/t/braces-block-code-and-lambda-confusion/30954)

<div class="topic-metadata">

**Author:** [@sylvainspinelli](https://discuss.kotlinlang.org/u/sylvainspinelli)\
**Replies:** 8\
**Last updated:** [February 12, 2026, 8:20am UTC](https://discuss.kotlinlang.org/t/braces-block-code-and-lambda-confusion/30954 "2026-02-12T08:20:23Z")

</div>

Starting with this example: class A { var prop: A? = null fun doX() { if(prop!=null) prop!!.print() else println("prop is null") } fun print(){ println("...") } } We are trying to eliminate the use of !! (…

---

## [Potential null type invariance break](https://discuss.kotlinlang.org/t/potential-null-type-invariance-break/30957)

<div class="topic-metadata">

**Author:** [@LilTOJustice](https://discuss.kotlinlang.org/u/LilTOJustice)\
**Replies:** 6\
**Last updated:** [February 10, 2026, 11:11pm UTC](https://discuss.kotlinlang.org/t/potential-null-type-invariance-break/30957 "2026-02-10T23:11:19Z")

</div>

Disclaimer: I am fairly new to the language, so if null invariance is not considered a strict property of the language, or if there is some other Kotlin “rule” I am breaking here please let me know. I believe I have fou…

---

## [Trailing boolean operations](https://discuss.kotlinlang.org/t/trailing-boolean-operations/30953)

<div class="topic-metadata">

**Author:** [@theaspect](https://discuss.kotlinlang.org/u/theaspect)\
**Replies:** 2\
**Last updated:** [February 8, 2026, 2:14pm UTC](https://discuss.kotlinlang.org/t/trailing-boolean-operations/30953 "2026-02-08T14:14:04Z")

</div>

Allowing trailing || and && both for begining and end will make formatter cleaner val res boolean = obj1.param1 == obj2.param1 || obj1.param1 == obj2.param2 so you can do val res boolean = || obj1.param1 =…

---

## [Intersection Type Compatibility Problem With Java](https://discuss.kotlinlang.org/t/intersection-type-compatibility-problem-with-java/28138)

<div class="topic-metadata">

**Author:** [@piacenti](https://discuss.kotlinlang.org/u/piacenti)\
**Replies:** 7\
**Last updated:** [January 22, 2026, 2:12pm UTC](https://discuss.kotlinlang.org/t/intersection-type-compatibility-problem-with-java/28138 "2026-01-22T14:12:17Z")

</div>

I can currently do something like this in java: private static \<T extends Comparable\<T\> & CharSequence\> T thing(){ return (T) ""; } and just use it var stuff=thing(); variable stuff gets a type hint of Comparable\<…

---

## [\`it\` within \`when\`](https://discuss.kotlinlang.org/t/it-within-when/1420)

<div class="topic-metadata">

**Author:** [@norswap](https://discuss.kotlinlang.org/u/norswap)\
**Replies:** 3\
**Last updated:** [January 12, 2026, 12:08pm UTC](https://discuss.kotlinlang.org/t/it-within-when/1420 "2026-01-12T12:08:35Z")

</div>

Two seconds suggestion: allow referring to the parameter of a when block via the implicit it variable, just like in lambdas. Or failing that, allowing something like when (val x = ....) { ... }. One problem I see: in ca…

---

## [Default Types for Generics](https://discuss.kotlinlang.org/t/default-types-for-generics/7129)

<div class="topic-metadata">

**Author:** [@Fleshgrinder](https://discuss.kotlinlang.org/u/Fleshgrinder)\
**Replies:** 21\
**Last updated:** [December 28, 2025, 12:40pm UTC](https://discuss.kotlinlang.org/t/default-types-for-generics/7129 "2025-12-28T12:40:32Z")

</div>

I could not find an existing topic regarding this issue but maybe my keywords were simply not the right ones to search for. Regardless, here it comes. I would love to see default types for generics in Kotlin like Rust h…

---

## [Automatic constructor](https://discuss.kotlinlang.org/t/automatic-constructor/30913)

<div class="topic-metadata">

**Author:** [@oSumAtrIX](https://discuss.kotlinlang.org/u/oSumAtrIX)\
**Replies:** 1\
**Last updated:** [December 28, 2025, 6:27am UTC](https://discuss.kotlinlang.org/t/automatic-constructor/30913 "2025-12-28T06:27:16Z")

</div>

When you have a super class with many constructor arguments, it becomes tedious to repeat the constructor in all implementing classes. It would be ideal for Kotlin to create a constructor automatically. Instead of: clas…

---

## [Add ternery operator](https://discuss.kotlinlang.org/t/add-ternery-operator/29408)

<div class="topic-metadata">

**Author:** [@minglei.lee](https://discuss.kotlinlang.org/u/minglei.lee)\
**Replies:** 20\
**Last updated:** [December 21, 2025, 1:54pm UTC](https://discuss.kotlinlang.org/t/add-ternery-operator/29408 "2025-12-21T13:54:13Z")

</div>

I love Kotlin, it’s so neat and elegant. :+1: :+1: :+1: When I learned about Kotlin a few years ago, I was surprised to find that I couldn’t write a ? b : c, which is common in many other languages. Of course, I can use…

---

## [Nested null check when only first one is needed?](https://discuss.kotlinlang.org/t/nested-null-check-when-only-first-one-is-needed/30900)

<div class="topic-metadata">

**Author:** [@charles.danilo](https://discuss.kotlinlang.org/u/charles.danilo)\
**Replies:** 2\
**Last updated:** [December 20, 2025, 1:37am UTC](https://discuss.kotlinlang.org/t/nested-null-check-when-only-first-one-is-needed/30900 "2025-12-20T01:37:21Z")

</div>

given code below, why kotlin enforce you to do nested null check , like bellow printCountry function it has 4 null checks with “?.” when just first check is really needed? fun printCountry(person: Person?) { println(per…

---

## [Why kotlin does not provide LinkedList implementation?](https://discuss.kotlinlang.org/t/why-kotlin-does-not-provide-linkedlist-implementation/15991)

<div class="topic-metadata">

**Author:** [@sandeep549](https://discuss.kotlinlang.org/u/sandeep549)\
**Replies:** 33\
**Last updated:** [December 17, 2025, 4:46pm UTC](https://discuss.kotlinlang.org/t/why-kotlin-does-not-provide-linkedlist-implementation/15991 "2025-12-17T16:46:01Z")

</div>

As far as I know, kotlin doesn’t provide LinkedList (Sequential Access variant of ArrayList) implementation. I want to understand the reason behind this ? What makes designer not to implement this ?

---

## [Context parameters require opt-in even in calling modules?](https://discuss.kotlinlang.org/t/context-parameters-require-opt-in-even-in-calling-modules/30889)

<div class="topic-metadata">

**Author:** [@Landei](https://discuss.kotlinlang.org/u/Landei)\
**Replies:** 0\
**Last updated:** [December 15, 2025, 8:01pm UTC](https://discuss.kotlinlang.org/t/context-parameters-require-opt-in-even-in-calling-modules/30889 "2025-12-15T20:01:32Z")

</div>

So, as context parameters are still experimental, I have to opt-in (using the compiler flag "-Xcontext-parameters") when writing functions using them - no surprise here. But when using a function from such a module, I’m…

---

## [Idiomatic way how to implement Java interface properties in kotlin?](https://discuss.kotlinlang.org/t/idiomatic-way-how-to-implement-java-interface-properties-in-kotlin/30876)

<div class="topic-metadata">

**Author:** [@msevcenko](https://discuss.kotlinlang.org/u/msevcenko)\
**Replies:** 3\
**Last updated:** [December 12, 2025, 6:52am UTC](https://discuss.kotlinlang.org/t/idiomatic-way-how-to-implement-java-interface-properties-in-kotlin/30876 "2025-12-12T06:52:42Z")

</div>

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 get…

---

## [Suggested new construct for tight code](https://discuss.kotlinlang.org/t/suggested-new-construct-for-tight-code/30866)

<div class="topic-metadata">

**Author:** [@digorydoo](https://discuss.kotlinlang.org/u/digorydoo)\
**Replies:** 3\
**Last updated:** [December 2, 2025, 6:42am UTC](https://discuss.kotlinlang.org/t/suggested-new-construct-for-tight-code/30866 "2025-12-02T06:42:41Z")

</div>

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 programme…

---

## [Make it easy to repeat something until it succeeds, but at most n times](https://discuss.kotlinlang.org/t/make-it-easy-to-repeat-something-until-it-succeeds-but-at-most-n-times/8097)

<div class="topic-metadata">

**Author:** [@dcuser](https://discuss.kotlinlang.org/u/dcuser)\
**Replies:** 13\
**Last updated:** [November 25, 2025, 12:56pm UTC](https://discuss.kotlinlang.org/t/make-it-easy-to-repeat-something-until-it-succeeds-but-at-most-n-times/8097 "2025-11-25T12:56:27Z")

</div>

These loops: for (i in 0..2) { doSomething() if(somethingFailed()) { continue } break } could maybe be expressed better. Something like this would be nice: try (maxTries = 3) { doSomething…

[Next page](https://discuss.kotlinlang.org/c/language-design/9.md?page=1)
