News for hackers. Stuff that matters.
Re:Kotlin becomes second most popular language on the JVM by lmm on Friday February 07, 2020 @07:11PM (#22272588)
Things like builders no longer make sense if you have named arguments. Transforming or filtering a collection is more idiomatic than mutating it in-place. Factories don't make sense when first-class functions do the job better. Basically everything that's frowned on in Scala is also frowned on in Kotlin, in my experience.
Re:Kotlin becomes second most popular language on the JVM by thu2111 on Saturday February 08, 2020 @09:31AM (#22275870)
Good points. It'd be great if the kotlin compiler could produce builders or "withers" automatically.
Re:Kotlin becomes second most popular language on the JVM by lmm on Saturday February 08, 2020 @07:35PM (#22279630)
Would you really want them? If you write code in that style then you're giving up a lot of the advantages of Kotlin.

IMO there's a contradiction at the heart of Kotlin's positioning. As the quote goes, a language that doesn't affect the way you think about programming, is not worth knowing. If programming Kotlin is just like programming Java, why not just keep programming Java? If you want to switch to Kotlin because it's going to unlock a better way of programming, then that's going to have to mean changing how you program. It may work as a trick to get users on board at the start, but ultimately the language will have to find its own idioms and patterns, or else go the way of CoffeeScript.

Re:Kotlin becomes second most popular language on the JVM by thu2111 on Monday February 10, 2020 @08:59AM (#22289115)
I'm talking about what it compiles down to. Kotlin routinely generates bytecode that uses Java idioms either for its own ABI or in addition to it. So yeah, if some builder classes were produced behind the scenes for an immutable data class, why not, that'd be cool. You could always disable that feature with a flag if for some reason the bytecode size was an issue.