Fair enough. Your position is different to mine. You are the one of the stewards of the language/sdk/compiler and Lombok's behavior perhaps makes your job really hard to refactor and update the compiler without breaking it and having thousands of developers come at you with pitchforks. Not an enviable position to be in and I certainly wouldn't want to be in that.
For me, I am an app developer and I really find value in what Lombok offers. It closes some real gaps that I as a user find in the language - not everyone agrees and that's fine. I also acknowledge I am completely oblivious to the effort it perhaps takes on your team's part every 6 months to add stuff the compiler without breaking Lombok.
However, your chosen example shows, I think, why some dislike Lombok's feature. At the very best, RequiredArgsConstructor saves you a few trivial lines. But then it makes it hard to add validation and preprocessing and it hides what validation, if any, is being done.
In most cases, these are all *Service, *Manager classes and the only validation I do is a null check. For that, all I need to do is add a @Nonnull annotation to those fields and I am done. Still don't have to write the full constructor. If I do want to add more validation, I can remove the annotation and write the real constructor with validation.
And here is why I prefer that model - when I see the annotation, I know there is nothing special going on in the constructor but if I see a real constructor, it is at least an initial signal that some extra things might be happening. This is just like a record where the presence of an explicit constructor or an equals method signals some additional things that I might need to pay attention to. If I have to write that constructor for every single class (with or without validations), I lose that distinction. For data classes, I stick to records where if I want to ensure any invariants, I have the flexibility.
So if you like that feature so much that it makes you pick Lombok over Java - great.
From my viewpoint, I am picking Java with an additional tool that lets me skip some of the boilerplate that I don't need to write or more importantly read. I definitely don't see it as picking Lombok over Java; the Lombok stuff is so miniscule compared to Java that I would not consider it a different language at all. The language architects may disagree from their POV and both can be true.
Here is what I hope happens in the future:
Just like how Records was a semantic feature but it incidentally also solved the data class boilerplate problem thus making Lombok's @Value annotation obsolete. I am hoping newer features can keep doing the same to some degree and chip away at the boilerplate. For instance, the feature that Brian showed where regular classes can have headers - may be if that feature can be used for a non-data regular classes, may be it will incidentally alleviate the need to write a dumb constructor when used and I wont need @RequiredArgsConstructor ever again.
View all comments
Show parent comment
3
u/Enough-Ad-5528 Apr 27 '26 edited Apr 27 '26
Fair enough. Your position is different to mine. You are the one of the stewards of the language/sdk/compiler and Lombok's behavior perhaps makes your job really hard to refactor and update the compiler without breaking it and having thousands of developers come at you with pitchforks. Not an enviable position to be in and I certainly wouldn't want to be in that.
For me, I am an app developer and I really find value in what Lombok offers. It closes some real gaps that I as a user find in the language - not everyone agrees and that's fine. I also acknowledge I am completely oblivious to the effort it perhaps takes on your team's part every 6 months to add stuff the compiler without breaking Lombok.
In most cases, these are all *Service, *Manager classes and the only validation I do is a null check. For that, all I need to do is add a @Nonnull annotation to those fields and I am done. Still don't have to write the full constructor. If I do want to add more validation, I can remove the annotation and write the real constructor with validation.
And here is why I prefer that model - when I see the annotation, I know there is nothing special going on in the constructor but if I see a real constructor, it is at least an initial signal that some extra things might be happening. This is just like a record where the presence of an explicit constructor or an equals method signals some additional things that I might need to pay attention to. If I have to write that constructor for every single class (with or without validations), I lose that distinction. For data classes, I stick to records where if I want to ensure any invariants, I have the flexibility.
From my viewpoint, I am picking Java with an additional tool that lets me skip some of the boilerplate that I don't need to write or more importantly read. I definitely don't see it as picking Lombok over Java; the Lombok stuff is so miniscule compared to Java that I would not consider it a different language at all. The language architects may disagree from their POV and both can be true.
Here is what I hope happens in the future:
Just like how Records was a semantic feature but it incidentally also solved the data class boilerplate problem thus making Lombok's @Value annotation obsolete. I am hoping newer features can keep doing the same to some degree and chip away at the boilerplate. For instance, the feature that Brian showed where regular classes can have headers - may be if that feature can be used for a non-data regular classes, may be it will incidentally alleviate the need to write a dumb constructor when used and I wont need @RequiredArgsConstructor ever again.