4 ms·
Java "withers" are on the way! I am very excited for this feature and has been a long time coming. This will make immutable transformation code much easier to
by davidalayachew 3y ago
Java "withers" are on the way!
I am very excited for this feature and has been a long time coming. This will make immutable transformation code much easier to write and reason about.
That said, I'm a little uneasy with the idea that we don't even have the option to write out our deconstruction pattern. That feels like a foot gun. I know that records come pre-baked with a deconstructor, I'm not asking to be able to choose. I am more asking for the ability to see the variable that I am overwriting. And I am not asking that every Java developer should have to shoulder that burden -- keep it implicit for those who want it. But I feel uneasy that I don't even have the option to write out the variables in my deconstructor.
I will try it out before taking issue with it, but these are my initial, uninformed feelings from looking at it. Regardless, even if my fears become true, this feature is well worth it, and I'm very happy to have it!
- DarkNova6 3y agoJust recently, talks in the java amber mailing list emerged talking precisely about deconstruction of arbitrary classes.
- davidalayachew 3y agoYes, I think I was participating in those talks. That does raise a good point -- If this concept might one day go over to the every day class, it sounds like they might be forced to list the deconstruction pattern used to do "reconstruction". Either way, my main point is that -- the implicitness of this feature is appreciated, but I don't know if I want to be forced between implicit or just not using this feature, since my uninformed gut feels like I would appreciate the explicit clarity of seeing the variables I am working with. It might feel like a step back, but again, this is my opinion before having a chance to try this thing.
- eweise 3y agoWhy wasn't this included in the initial records implementation? I tried records and quickly gave up after realizing there was no copy method. There's plenty of prior art. Scala has had this for twenty years. Java needs to stop shipping features that don't work as well as in other languages.
- pjmlp 3y agoOne step at a time, that is why. Scala is also on the edge of turning into Coffee Script, its relevance wanning. 20 years is pushing it, by the way.
- eweise 3y agoOh yes, 18 years. Guess that's not enough time. And yes, Scala's relevance is waining but not sure what that has to do with this topic. Kotlin also has a copy method if you need an example of a language doing well.
- pjmlp 3y agoKotlin is only doing well on Android, because mama Google tells so to all the kids targeting Android that they have to eat Kotlin no matter what. Java is doing quite well on the Java Virtual Machine, it isn't going anywhere for not adopting every feature from Beanshell, Groovy, jTcl, jython, Frege, Ruby, Scala, Kotlin, and whatever else comes that needs to implement on top of Java to exist in first place.
- eweise 3y agoNo need to get defensive about Java. I developed with it for over 20 years. But personally, I left it because I find it too painful to code in. Every once in a while I try the latest version and it continues to disappoint, records are a good example. I've also been working in fintech for the past 7 years and the companies I worked for, don't want to use Java. Its either been Kotlin/Spring because the syntax is much nicer, or Go because it doesn't have all the JVM baggage. Maybe Java is still really popular but fortunately, its also easy to avoid now.
- pjmlp 3y agoIf they are doing Kotlin/Spring, they are using Java no matter what. It is like using Web and avoiding JavaScript, or UNIX and avoiding C/C++. Sure it is possible to pretend it isn't there, until one needs to do serious stuff that requires understanding the platform and its ecosystem. By the way, once upon a time Spring was also all hot on Groovy, then it was Scala, now it is Kotlin. There is a certain irony complaining about Java programming language features and them going into Go, the epitome of programming language design.