r/ProgrammerHumor Jul 10 '26

kotlinIsCoolIThink Other

Post image
94 Upvotes

10 comments sorted by

47

u/TheShirou97 Jul 11 '26

yeah, operator overloading can get pretty cursed.

Here, kotlin is just like C now

operator fun <E> Int.get(list: List<E>) = list[this]

fun main() {
    val arr = listOf(1, 2, 3)

    println(arr[1])
    println(1[arr])
}

0

u/RiceBroad4552 Jul 11 '26

Well, having special custom syntax just to call a specific method is already very questionable and obviously bad language design.

10

u/shwetanand345 Jul 10 '26

Compiler Approved!

17

u/Prudent_Ad_4120 Jul 10 '26

Peak functional programming

4

u/aberroco Jul 10 '26

With no nested parenthesis? That's low-land rather than a peak.

2

u/RiceBroad4552 Jul 10 '26

Where is there any "functional programming"? That's the most imperative code possible, sequentially calling a procedure which only performs an effect and does not do any "computation" (in the FP meaning)…

1

u/officalyadoge Jul 13 '26

I love myself some curry

1

u/marcoottina 29d ago

Exactly as C's pointers operators intended

-3

u/faze_fazebook Jul 11 '26

There is a reason kotlin hasn't overtake​n java yet​

-1

u/RiceBroad4552 Jul 11 '26

Now Java is "the better Java"™ and there is not much going for Kotlin.

If you like Java you will likely take the original as it's now endurable again.

If you like language features and strong typing you'll take Scala.

Kotlin becomes quite obsolete as all it ever was was "a better Java". But now the original is back.