News for hackers. Stuff that matters.
Re:New Features in Java 14 by sa46 on Wednesday March 04, 2020 @12:11AM (#22481368)
I don't understand what you mean by provably. The Java example does the exact same thing as the JS version: create a shallow clone with a different age. Do you mean the builder might do something different?

    // Java
    val emily2 = emily1.toBuilder().age(30).build()
As far as adding the spread operator to Java, I think you'd have to require a Spreadable interface to use it or limit usage of the spread operators to records. It's not clear to me that the expressive power is worth it over a builder.
Re:New Features in Java 14 by jeswin on Wednesday March 04, 2020 @03:33AM (#22482085)
If a tool analyzed the JS AST, it could conclude (with fairly trivial analysis) that emily2 is a shallow clone of emily1. No such guarantee is possible with the Java version.