Mikhail Backend’s Post

Kotlin’s 'when' construct used to feel like a “modern” alternative to Java’s switch in the beginning... But since new 'switch' in Java since v17 - not true anymore. On the pattern matching, Kotlin has been behind Scala for over a decade - and now it’s arguably behind Java too ( Java’s pattern matching has turned switch into a real data-oriented branching tool, especially with: - type patterns - record deconstruction patterns - guards (when) Kotlin still shines with exhaustive when over sealed hierarchies. But Java is currently ahead on first-class deconstruction + guards directly in the lang. And honestly, it’s a bit sad for Kotlin. It was positioned as a bold “next-gen JVM language”, backed not only by JetBrains but also a huge community, yet this specific area feels like it is not moving fast enough. Timeline for context: - Pattern matching for switch started as preview (JDK 17 era) and is a standard feature in modern Java releases (see JEP history). - Record patterns are part of Java 21 (JEP 440). #java #kotlin #scala #jvm #patternmatching #softwareengineering

  • graphical user interface, text, application

Why not mention the unnamed variables that are the star of the show?

To view or add a comment, sign in

Explore content categories