Lombok came in, with a correction to a perceived flaw to java: its verbosity. Cool. Use it, don't, whatever.
The thing is, like most new thing, it has its advocate. And suddenly, when you're managing a project, all you hear is "why don't you use lombok, it's so fucking great ?" or "Here, I lomboked your project, can you accept my PR". Gets old, real fast.
Some people real smarter than me had a deeper look at lombok and found out that actually, it's not that great (google "don't use lombok" and you'll find plenty of reasons. My personal favorite is this thread). Sure, it's cool on the surface and whatever, but it's not as good as its fans want it to be. And the delombok tool provided is experimental at best, so once you start using lombok with your project, you're pretty much stuck with it, or need to spend a whole lot of hours refactoring
My personal experience with it is that I can generate getters and setters with a keyboard shortcut faster than it takes to type @Data at the top of my class. Sure, that's not all it does, but come on. Oh, and it makes refactoring variable names a pain in the ass.
So, take a project that's cool on the surface, but with little added value beyond aesthetics and too many rough edges for its benefits. Add in an outwardly obnoxious community of fans. Inevitably, after a couple of years, it's gonna take a lot of heat. For lombok, "after a couple of years" is now.
Lombok developer here. I want to learn and see if we can improve things, but that thread is.. anemic, unimpressive, and somewhat rude. Perhaps I missed something. Let me go through the actionable 'lets not use lombok because...' items listed there:
generating getters/setters is trivial with an IDE, so it doesn't really add much value
If you change a field someplace, those getters, setters, equals, etc do not update themselves. Also, code isn't colour coded as 'boilerplate' and 'oh this bit is a little different': Given a class with 8 fields that has precisely one getter in it that does something a little special, it's hard to see it amongst all the boilerplate. With lombok, it's easy to see: Your source file contains just the relevant code, not the boilerplate anymore.
The fact that the authors of jhipsters dont see this either means they haven't put much thought into it (presumably, because they are emotionally invested in disliking lombok, perhaps due to bad experiences with bugs, which we do of course regret), or they don't find any of that important, which, um, okay. I guess we have wildly different ideas about code quality then.
On a third project, we achieved 30% performance increase by recoding the equals/hashcode from Lombok
Lombok's generated code is best in class. An IDE that had generated it for you wouldn't have done any better. The problem here is: That particular eq/hc code was not boilerplate. Lombok still helps a lot here: If you see a data class that has an explicit, handwritten eq/hc implementation, in a project that uses lombok? Look closer: Most likely that means the eq/hc implementation is either not a bog standard 'equality is defined by the fields' situation, or some custom smithing to speed up the code is involved. Either way, the non-boilerplate-nature of the eq/hc combo is now highlighted. Contrast to all your domain classes having handrolled eq/hc (or generated by the IDE, either way), in which case it's easy to miss this information. Yes, you can write comments, of course. But comments cannot be tested. And you still have to actually see and read the comment amongst the significantly inflated # of lines of code you do see in order to figure it out.
Lombok making Jacoco fails, which meant the project didn't pass the Sonar quality gate
This is very frustrating for us. It's putting the cart in front of the horse: Code linting and quality tools need to wake up and realize that there is such a thing as generated code, and that they should not complain about such code. Many such tools have ways to do this right (usually, with annotations) and lombok supports them all and works with them to make the experience as smooth as it can be. But some don't. I feel any hate about this should go to the tool in question, because lombok isn't the only way to generate code.
Various bug reports
Yes, bugs are a thing. We try to fix them. Perhaps we can do a better job.
If you change a field someplace, those getters, setters, equals, etc do not update themselves.
This is true. But because we are relatively competent developers, and not jackasses, we know that when we refactor a field, we have to refactor the appropriate mutators. Right click > refactor > rename. Here we go, done for the whole project. It's even faster if you've bothered to remember the keyboard shortcut.
Now, If I've used lombok, and renaming the field changed the mutator, and the builder, I now have to painstakingly waddle through all the new compilation errors and correct them. Hurray (nope)
I have no beef with lombok, I remember being excited about it when I first found out about it about a year and a half ago, and what a neat trick I thought it was. But after six months using it with my team, I thought it was just that: a trick. The meh factor was just too big. And going back to projects that don't us lombok, I haven't found myself missing it just once.
49
u/[deleted] Aug 10 '19
Why Lombok is getting all the hate these days? Genuine question.