Kotlin needs more exciting new features, and that probably means embracing more controlled risk

I’ve been using Kotlin for 7+ years now. I love Kotlin. I understand and appreciate that Kotlin is strongly-typed. I enjoy and celebrate knowing that some things will never ever be null. But I enjoyed it more when there was a steadier stream of major feature upgrades- things that would tangibly improve my coding experience. Destructuring was great! It was genuinely nice to suddenly be able to condense many assignments into a single set of parentheses. Same with delegating interfaces. But scrolling through the github releases for the last couple of years and looking at each “new features” section is somewhat depressing. Compiler updates and improvements are important and laudable, but they don’t send a tingle up my leg. When was the last time we got a major feature that made using kotlin more enjoyable?

Let me declare 10 variables of the same type with a comma-separated list!
var (a, b, c, d, e…): Int

It seems silly, but today I’m parsing out the properties I need to complete a class (repeatedly) from a stream of strings, and I would love to have two concise lines of declared variables: one group for ints and the other for floats. Or let me just use one “var”, and comma separate the name and type.

var a: Int, b: Float, c: Whatever…

I’m not picky, just throw me a bone!

Or give me a standard library way of instantiating a data class from a map of strings. Call it Restructuring. Is it safe? Absolutely not. But it would be super convenient, and convenience should be winning the day at a higher rate than it has been. Make me opt-in, if you must. But Kotlin can’t be an exciting language to continue to invest time if it’s progressing at the speed of what you can smart-cast with 100% certainty.

A minor tweak to a subset of ‘when’ statements is not a good “New Feature.” New range operators are fine, but they’re also not good “new features.” The long forum arguments about unity classes or instantiating from a map or a ternary operator were fun …when they started 7-10 years (or more) ago. But it’s not fun when everything resolves to “we talked about. can’t do it, won’t happen.” You can chart Kotlin’s decreasing level of adventurousness by reading through the KEEP proposals for the last few years. It’s a graveyard for big, fun ideas, and the more they get ignored, the smaller and less intriguing the suggestions get.

I’d rather see topics which allow you to implement new behavior (like context parameters) on the roadmap instead of minor tweaks of the general syntax (which are often notoriously hard to implement because of all the edge cases).

2 Likes

Personally I would opt for a more advanced pattern matching with nested destructuring. Putting aside Scala or Rust, currently even Java seems far ahead in that area. :stuck_out_tongue:

1 Like

Yeah, that’s also a pain point. To be fair, you can already do something like this in the current state of the language, although it’s far from perfect (shameless plug incoming): GitHub - DanielGronau/kopama