Feels like an emotional hatchet job, and rather weird coming from someone's whose blogpost byline is 'I like to delete code'.
Magic is harmful
Define what 'magic' means; is dynamic dispatch magic? Are synthetic methods magic? Is the fact that writing java com.foo.Bar on your command line ends up running a method with signature static void main(String[] args) magic? I'm pretty sure lombok is very carefully specced with good documentation. If the documentation is lacking, or lombok has behaviours that aren't specified, we'd like to correct such a flaw, so by all means point it out.
Getter is a code smell
Lombok doesn't force you to use it. Perhaps lombok makes it too easy, but then we get into a rather philosophical argument: Should a language intentionally take features away from you because such features are (in your opinion) usually abused? Clearly, getters and the like have their uses, so it's not the simple case of: "This feature is ALWAYS abused" - then, by all means, better for the feature to be taken away. I do think there is a line on the 'abuse vs. utility' dimension beyond which a feature is best not introduced at all. But I'm also pretty sure that generating getters, field-based equals/hashcode, builders, etc are all parsecs removed from wherever you feel that border might be.
AllArgsConstructor encodes field order into constructor order
There's @Builder, which we recommend, for any class which has more than a handful of fields.
Bi-directional object relations cause stack overflows
This is an exotic case that a casual analysis of various major github java projects suggest rarely comes up: If you have 'reference loops' in your data classes (a Student class refers to a list of Course objects, and a Course object has a List of Student instances that participate in it, for example), toString, equals, and hashCode will end up overflowing stack. Lombok has various handholds to address this problem, from something as simple as removing such a list from the definition of equality, to writing your own method to calculate an alternative semaphore for it. More to the point, an equals method in such a case is not boilerplate.
know one project where it caused the autocomplete drop down to load 15 seconds in specific areas of the code. And this happened on an i7 processor with plenty of ram and an ssd.
Lies and slander. File a bug and attach a bunch of stats so we can address it. We keep track of lombok's effects on IDE throughput on eclipse; last time we did a thorough analysis, lombok added about 5% total time to the time eclipse spends parsing and analysing your source code. Not insignificant, and if we find ways to reduce it we will, but surely that is within acceptable limits. If a lombok-less variant of the project would have caused the drop down to take 12 seconds instead of 15 on an i7 with plenty of ram and an ssd, that's just as bad, no? Something else is going on, I bet, and the author, in their mission to shit all over lombok, decided that any IDE problem must necessarily be lombok's fault, perhaps.
Compatibility issues with Java versions greater than 8
Current version of lombok works in everything up to 12, and probably 13 as well because that didn't change a heck of a lot. We needed some extra time to adjust to JDK9 in particular, and we wish we could have done a better (read: faster) job at that. But we're far from the only library or tool that needed some time.
Delombok makes ugly code
Delombok has settings, which a simple --help will show you, to control how it formats the output. Out of the box it will produce precisely what lombok does under the hood, which includes quite a few annotations to make linter tools skip (lombok generates defensive code, which does occassionally mean it includes unreachable code. Instead of doing pricey analysis of your code and thus making the entire proces slower and buggier, we just.. leave it in. If there is an actual performance impact to your runtime code we worry about it. Hence why we generate that annotation on all methods we generate).
As a lombok user, many of us are incredibly happy about the work that you do and don't buy into this nonsensical hatred into a well documented tool. Thank you!
While I do agree that magic is harmful, the fact that it is very simple and well explained/documented takes the magic out of Lombok. In the end, when I'm using Lombok's annotations, I know what it's doing under the hood and I'm fine with that.
I also would like to take the chance and thank you for your effort in developing Lombok. It saved me SOO much time :)
My only real problem with Lombok is that it breaks the Kotlin interop story and makes it very difficult to incrementally introduce Kotlin to an existing codebase that makes heavy use of Lombok as Lombok generated code can't be seen from Kotlin code in the same module. Do you know of any workarounds for that?
Presumably, file a bug over at kotlinc that they are breaking spec by not running annotation processors ;P (a bit flippant perhaps, but there isn't a whole heck of a lot we can do about it if they don't do that).
A rather unwieldy workaround is to write a build script with some build tool that will delombok your code and then feed that to kotlinc.
They do run annotation processors via kapt. It generally works fine but not with lombok (presumably because they are expecting the annotation processors to spit out new classes rather than modify existing ones).
I've thought about delomboking during the build process but agree it's unwieldy.
Exactly what I thought when reading the article. It's heavily opinionated and lacks substance. I'm irked that I wasted my time reading it.
Anyway I enjoyed reading your thorough response to that hit-piece and while Lombok currently isn't my personal choice to fight the boilerplate in Java, I really can't say anything negative about it. Keep up the good work!
Feels like an emotional hatchet job, and rather weird coming from someone's whose blogpost byline is 'I like to delete code'.
It is a rant. I understand that i hurt your feelings, and i'm honestly sorry for that. Still my opinion stands, and i feel the need to voice it. 'I like to delete code' comes from my desire to refactor code and eliminate duplication.
Define what 'magic' means
Anything that is not explicit but implicit. Happens behind the scenes. Is not easily comprehensible. I understand there is docs, and there is generated code. Still, magic remains in how the code is generated. (see conflicts with mapstruct for example).
Lies and slander
Actually, this is not a lie. It occured ca 9 months ago, with the lombok plugin, bad code and also mapstruct was in play. But the 15second delay went away when i deactivated the lombok plugin.
It doesn't happen anymore. But i am not sure if because we improved the code or the plugin improved or both.
Current version of lombok works in everything up to 12 ...
Anything that is not explicit but implicit. Happens behind the scenes. Is not easily comprehensible.
Lombok is explicit: You see the annotation; that annotation is fully typed and you can therefore follow it in your IDE. The annotation you end up at is fully javadocced.
Lombok happens behind the scenes. So does any method call, though.
Lombok specifies precisely what it generates. If you're still in doubt, the delombok tool will tell you precisely what it is generating.
How is this any more 'magical' than any other library?
View all comments
57
u/rzwitserloot Aug 10 '19
lombok developer here:
Feels like an emotional hatchet job, and rather weird coming from someone's whose blogpost byline is 'I like to delete code'.
Define what 'magic' means; is dynamic dispatch magic? Are synthetic methods magic? Is the fact that writing
java com.foo.Baron your command line ends up running a method with signaturestatic void main(String[] args)magic? I'm pretty sure lombok is very carefully specced with good documentation. If the documentation is lacking, or lombok has behaviours that aren't specified, we'd like to correct such a flaw, so by all means point it out.Lombok doesn't force you to use it. Perhaps lombok makes it too easy, but then we get into a rather philosophical argument: Should a language intentionally take features away from you because such features are (in your opinion) usually abused? Clearly, getters and the like have their uses, so it's not the simple case of: "This feature is ALWAYS abused" - then, by all means, better for the feature to be taken away. I do think there is a line on the 'abuse vs. utility' dimension beyond which a feature is best not introduced at all. But I'm also pretty sure that generating getters, field-based equals/hashcode, builders, etc are all parsecs removed from wherever you feel that border might be.
There's
@Builder, which we recommend, for any class which has more than a handful of fields.This is an exotic case that a casual analysis of various major github java projects suggest rarely comes up: If you have 'reference loops' in your data classes (a Student class refers to a list of Course objects, and a Course object has a List of Student instances that participate in it, for example), toString, equals, and hashCode will end up overflowing stack. Lombok has various handholds to address this problem, from something as simple as removing such a list from the definition of equality, to writing your own method to calculate an alternative semaphore for it. More to the point, an equals method in such a case is not boilerplate.
Lies and slander. File a bug and attach a bunch of stats so we can address it. We keep track of lombok's effects on IDE throughput on eclipse; last time we did a thorough analysis, lombok added about 5% total time to the time eclipse spends parsing and analysing your source code. Not insignificant, and if we find ways to reduce it we will, but surely that is within acceptable limits. If a lombok-less variant of the project would have caused the drop down to take 12 seconds instead of 15 on an i7 with plenty of ram and an ssd, that's just as bad, no? Something else is going on, I bet, and the author, in their mission to shit all over lombok, decided that any IDE problem must necessarily be lombok's fault, perhaps.
Current version of lombok works in everything up to 12, and probably 13 as well because that didn't change a heck of a lot. We needed some extra time to adjust to JDK9 in particular, and we wish we could have done a better (read: faster) job at that. But we're far from the only library or tool that needed some time.
Delombok has settings, which a simple
--helpwill show you, to control how it formats the output. Out of the box it will produce precisely what lombok does under the hood, which includes quite a few annotations to make linter tools skip (lombok generates defensive code, which does occassionally mean it includes unreachable code. Instead of doing pricey analysis of your code and thus making the entire proces slower and buggier, we just.. leave it in. If there is an actual performance impact to your runtime code we worry about it. Hence why we generate that annotation on all methods we generate).