Comment by 411111111111111
5 years ago
I use java8 at my dayjob.
It's been years since I did any of that, as Lombok and spring boot generate that code for you.
Immutable classes get a @Value and maybe @Builder annotation, muteable ones get @Setters etc.
Springs auto wiring for beans is sadly magical however, so much harder to figure out what went wrong if you have any issues...
It's weird to me how you find the magic of spring sad while you find the magic of Lombok acceptable.
Lombok requires that you use a supported build system and IDE and while all the currently relevant ones are supported that is no guarantee. Needs plugins and agents that support your various tools' versions including the JVM itself. I've been in that hell before with AspectJ and the aspectJ compiler vs eclipse plugin (version incompatibilities that made it impossible to work efficiently until they fixed it all up).
Disclaimer: last company we used Lombok. Current company we are switching certain things to Kotlin instead. data classes FTW for example. I do miss magic builders. Builders are awesome. Building the builder is tedious ;)
Lombok magic doesn’t span across files. Look at the class, see the annotations, and as long as you have even a trivial understanding of what Lombok is, you can grok it. It’s basically like a syntax extension.
Spring on the other hand... autowired values everywhere, and at least for me (who doesn’t work with Spring day in and day out) it’s very difficult to understand where they come from.
Don't get me wrong, I've used Lombok and liked it from the working with it and what it saves you aspect.
We do use spring and I've used it for a very long time now. Nothing is magic and not understandable about wiring if you do it right. Unfortunately there are a lot of projects out there that use it in exactly the wrong way if you ask me and then I'd agree with you.
I used to be in a company where we used XML config and everything was wired explicitly. The XML part sucked but with SpringIDE (eclipse at the time) it was Ctrl-clickable to find what's what.
We use Java config with Spring at my current company and I can Ctrl-click my way through it all and find what's what. There's a small corner of 'package-scan'ed stuff that is evil but we are cleaning that up.
Java already has records, better than Kotlin's data classes.
How exactly are they better from Kotlin's data classes?
Aside from the fact Java only released non-preview support for records one month ago, they:
While Java records are nice, Kotlin data classes are strictly more capable than Java records.
7 replies →
Lombok is great, but Immutables is even better! https://github.com/immutables/immutables