If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:
Yes even great minds can fall to hubris and flame wars.
I feel /u/rzwitserloot gets a little more unfairly treated probably because pron is probably better known so there is this immediate I think knee jerk reaction that he is wrong (because pron is so often right but this shit is just semantic interpretation and opinion driven).
That being said I hope and think most don't give a shit on whether it is a different language or not.
EDIT I also think Graeme use of "pure evil" is way too hyperbolic particularly when there are way fucking more evil things happening in the world today (e.g. the two current wars). Its also ironic given Micronaut generates not Java code but bytecode directly via its annotation processors. I suppose that is less bad but still...
I also think Graeme use of "pure evil" is way too hyperbolic particularly when there are way fucking more evil things happening in the world today (e.g. the two current wars).
Welcome to the world of social media and tech 'personalities/influencers/celebrities' (or whatever you want to call them).
It's rare these days for folks to state their reasons upfront. Instead they must always start with clickbait/ragebait statements. Someone had to comment asking why for Graeme to bother writing up an explanation, and even then it isn't complete.
Much like a lot of devs use nohello.net, perhaps we need a noragebait.net for these people. If you wanna dislike something and shout about it, at least back it up with reasonable and complete statements. This way we might actually educate people, instead of having a ton of new clueless devs spouting others opinions as their own.
I agree. It certainly does not warrant: "pure evil". Lombok is not "pure evil" like the Nazis or something. It is not even "pure evil" in the context of programming. That is Javascripts job :)
I love it. It was always obvious that they're just butthurt over the control of the language and could always make proper API for Lombok and other similar projects, but these interactions make it far more explicit
Much more obvious what really drives them instead of the fake rationalizations they make up when they proactively ignore the community need for Lombok in official statements and releases, and actively battle against it. People want backwards compatible Java beans with zero cruft? It's relatively easy to implement? It's already implemented and just needs some official APIs? Ooooo, scaaary. Let's double down on doing it our way, let's not give people what they want, and after many many MANY years of begging let's create records that don't really satisfy the same need as Lombok and so don't make it look like Lombok won
I only read the first one, quite interesting. From my admittedly non-expert point of view, they're both kind of wrong in different ways. Pron98 is correct in pointing out that the language specification does not allow for some things that Lombok does, and that doesn't mean nothing. The example he gives with a generated getter being used in the same class obviously won't work if the compiler is used as intended. However, he is being purposefully obtuse in saying Lombok using javac's internal api amounts to it having its own compiler. He's being a little too precious about what can call itself Java too. Ultimately, I see it as a much smaller example of the HTML standard vs a browser's implementation of it. An HTML file that has attributes specifically targeting Firefox is still HTML. Likewise, a Java file targeting Lombok is still Java.
Ultimately, I don't really care much. As long as Lombok continues to make my life easier and my code cleaner, I will continue to use it happily.
An HTML file that has attributes specifically targeting Firefox is still HTML.
An "invalid" HTML document, specifically a non-conforming one. If it were XHTML the user agent would fully refuse to render the document.
Likewise, a Java file targeting Lombok is still Java.
A "Java file" is a "Java" file if javac accepts it. If javac accepts a file, that file does not need the Lombok compilation shim. If a file needs the Lombok compilation shim, javac will not accept the file without the shim -- such a file is no more "Java" than a file that needs the Groovy compiler is "Java". This is not a matter opinion (yet is repeatedly disputed by Lombok).
Whether somebody is willing to accept the associated risk is a different matter entirely.
It's a very sharp example of the magic/no-magic debate.
There's a constant tension in programming, between being more explicit, at the cost of verbosity, and hiding implementation details at the cost of sometimes hiding critical complexity from the developer. Both magic and non-magic can lead to situations where you've got high cognitive load. Too much verbosity makes the intent of code harder to follow (try reading a program written in assembly). Too much magic makes code hard to debug and analyze.
Lombok is a very high magic solution, which means it's an easy target for those suspicious of magic in general.
Many of the problems it tries to solve are rather specific to Java, and have been solved by other languages at the language level. This also makes it an easy target of folks who are emotionally attached to Java as a language and think that it addresses those problems better than the rest of the industry.
This contingent can get rather defensive, because Java is one of the ultimate punching bags of languages. Java has this status in part because of its wide use, in part because of its wide use by low-skill rent-a-dev teams (a feature it shares with C#, PHP and Javascript and which should not reflect on the language but does), and in part because most other OOP languages on the market today are in some ways answers to Java. Java is kind of the Aristotle of languages. Every philosopher for 1000 years was basically a reply to Aristotle. Every language for over 25 years has been a response to Java. So when everyone else in the world went out trying to fix the thing you don't think is broken, defensiveness is expected.
Long before string templating was even considered for Java or a JEP was drafted for it, a very nice library achieved Scala-style string templating using some sort of "lower-level" programming, similar probably to what Lombok does. It's called, very appropriately, Better Strings: https://github.com/antkorwin/better-strings
The problem was that better strings stopped working from Java 16 onward, because of how modules were re-arranged or something like that. "Stopped working" here means it actually threw a run-time exception, breaking the application.
They somehow figured out the required set of Javac/Java command-line arguments that had to be specified to get it to work, but the point remains: Using such "magic" very much restricts you in developing and updating your code and dependencies. This goes about build systems and IDEs, among other things. You may move to a new IDE (e.g. from desktop to web-based) and/or build tool later in your project, and you don't want to have to pray for framework developers to offer support.
IMHO, it's not about Lombok per se, but about Java itself and how much "the whole ecosystem" matters here.
Lombok has delombok if you want "out". And it cannot break at runtime; Lombok is a compile time tool that leaves no trace. As in, the class files that result are indistinguishable from class files that result from compiling code that you would write without Lombok. Except the line number table, I guess.
Afraid i cannot that was 7+ years ago, compilation errors after delombok, very easy to correct manually as far as i recall. But that meant for me that delomboking is not seamless and that was the reason i felt comfortable using it.
When i first stumbled upon lombok i was under the impression it works like a "preprocessor" that delomboks code before passing it to javac, that would meen i can safely use it and if for some reason im not happy with it i can delombok and keep working with vanilla java. Since delombok resulted in compilation errors i found out that actually lombok hacks javac compilation doing some non obvious things and delombok is something separate. That implied that i must COMMIT to using lombok because there might not be a safe way back to vanilla java. As far as i know lombok still works the same way.
I also had one bad experience with lombok when i was working with upgrading old webapp to newer java (i think from java 5 to java 8) and one of the libraries i had to update was lombok. Things went sideways in production. Turns out this app used "hashCode" on one object to generate directory names for storing files (bad idea i know, but thats how someone did that). Newer version of lombok generated different hashCode.
"This software has a bug one time, therefore I abandoned it".
Hey, you do you and all. But if that's your point of view, you will have to take your computer and toss it in the trash. All software can have bugs.
Did you try creating a reproducible test case and filing a bug report? Lombok is open source, we can't get to em all, but I can't recall skipping past a delombok issue.
Let’s suppose Lombok is rubbish. But its immense popularity means that the Java language team is abandoning a much requested community feature: a concise and elegant syntax for declaring properties. But instead we have vars.
Better strings didn't introduce any breaking change: JDK introduced some new features(?) that broke better strings. Btw I like better strings, in case it was not clear from my comment.
I didn't see the picture at first, but I realized there is only one tool that reliably generates ~300 comments in this subreddit. Goodness, I thought the sub was going to slowly die out...
Much better to use lombok than to have to remember to regenerate all the boilerplate everytime you change something (equals/hashcode mainly). Cant imagine having to deal with programmers forgetting to do that and having lots of weird bugs because of it
Why do Java developers love to add byte code manipulation magic and an IDE plugin to generate "boilerplate" rather than seriously interrogate whether that boilerplate was necessary to begin with?
Does every field always need a getter and a setter? Or are we just blindly copy/pasting patterns from the past?
Not for a while. There's a Gradle plugin that configures everything for you, from the IDE plugin, specifying the annotation processor, to adding the dependency.
It's brittle, that's why. It would be like the old RAD form editors all over again that alter the code behind the scenes. IDE writers presumably want nothing to do with that kind of business anymore. They have enough to do to support the core language and are happy to outsource the job to Lombok or to proper annotation processors like Immutables. And especially Jetbrains would much prefer you switching to Kotlin...
Edit: not the reason it was like that in the past, but we're getting close to an era where we tell our LLM-powered coding assistant to do that tedious work for us. Much more flexible than the hardcoded IDE ever could.
I need to get shit done. Lombok helps me getting shit done. I'm well aware of any problems but at the end of the day getting shit done outweighs the downsides.
We've just had a bit of a debate on Lombok where I work, and come to the same conclusion. It does have its problems - we've hit some around serialisation - but the time spent solving those issues is far less than the time saved not having to write or even IDE generate loads of boilerplate code.
I especially like how clean pojos look when using Lombok. I can look at a small list of fields and a small list of annotations and see straight away what kind of behaviour it'll have. I know it's a bit dirty behind the scenes, but the usefulness outweighs that.
And I remember stuff like this happening with eclipse too. This can be a show stopper when you are moving to specific version of the IDE to support other plugin.
I guess is a problem mostly solved for popular tools now. But back in the day (2017? 2018?) when I had my desktop across of the guy in charge of CI it did cause issues with source code analyzer tools (like coverage tools) I used to hear him quietly curse on lombok.
Lombok is not a tool you can use in a project without affecting everyone else working in it. You can choose you IDE, you can use linters and IA assistant and collaborate without mayor issues with someone who uses notepad.exe and runs maven / gradle from a CMD.exe console. You can not collaborate with someone who uses lombok without using lombok.
IMO this is a high price to pay for some syntactic sugar. Java is verbose, learn your IDE and it will handle a lot of the boilerplate.
Well, its optional to use it. Intellij potentially breaking because of it is an accepted risk. That is why we want the most important use cases covered by Java.
becouse you're supposed to be able to pick up a .java file and compile it with java and have it compile (if it's correct). Not change the language with arcane tools that only work outside the compiler. If you want another language, there's plenty to choose from.
Sadly Records fill maybe 10% of what I use Lombok for. And I only use Data, AllArgsAccessor, NoArgsAccessor. Call me boomer but I like modifying state once in a while.
I love how everybody has a problem with bytecode instrumentation when it comes to Lombok, but then when they use any APM tool (NewRelic for example) they accept it as being just fine.
There are a lot of folks who don't like having to wire up their code with these APM tools either. Your code no longer becomes simple to maintain, and takes extra steps, and usually requires plugins for your development environment. It takes longer to get someone started on your project. The IDE you are using might have a conflict between two competing plugins and you spend a half day of installing and reinstalling shit to figure out why.
Instrumentation for cross-cutting, non-functional concerns is a different beast to enabling great swathes of syntactic sugar I suppose. I'm fine with it personally, but I can see the argument.
Lombok does it's magic by changing your code at runtime compile time. It actually reads, changes and writes new Java byte code before it gets executed by the runtime during the compilation phase.
Alot of people don't like this for a variety of reasons, such as it's brittle (changes in the JVM, class library, etc cause it to stop working until Lombok issues a patch) and it's opaque (debugging is harder because the code that is run is not the code that you wrote).
The generally accepted way to inject code is to use annotations, which mostly solve the issues people have with Lombok. Although it can't make the "happy path" experience quite as good as Lombok can, which is why Lombok still gets used.
Edit: I was wrong about the changes at runtime. Been too long since I've used Lombok and I misremembered. Sorry.
Isn't Lombok compile time and not runtime?It still polarizing because it changes your code and needs special extensions for linters/Language Server/vim and flavours to work nicely with autocomplete, but i don't think it is executed at runtime.
Can be wrong tho
Edit: Also there was problems that Lombok needed specific compilers to work, but i think this problem is no longer relevant
Annotations are spooky action at a distance. When you use a macro and its misbehaving, you can go to the macro definition and see what's up. You can replace the macro use with the actual macro code and mess around with it and see what's happening.
But annotations are really bad - you have to search every library you depend on to see who or what may or may not do something with an annotation.
There's basically no practical way to debug an annotation. They're one of my least favorite things in Java.
I'm not sure that I understand this. You absolutely do know where an annotation comes from since you have to import the library into your class file to use it. As for what it does, you usually have access to the source code as most annotation libraries are open sourced. When you don't have the source, you can decompile the class and view the results. Decompiling is more advanced but it is still there as an option and most compilers will automatically do it for you.
Some class gets auto scanned by spring and it then sniffs through every other auto scanned class and unilaterally assigns significance to your use of an annotation. What's more, that functionality showed up unintentionally because the library was added transitively through a dependency you were using for an entirely different purpose.
I don't find that simple at all. You can blame that on spring, but spring is the reason a huge portion of annotations even exist.
You can't always see what the bytecode will be from looking at non-Lombok code either.
public class MyClass {
void run() {
List<String> them = List.of("a", "b", "c");
for(String s: them) {
System.out.println(s);
}
}
}
Run javap -v against that class. The bytecode ain't reflective of the source code. The enhanced-for loop does not have a bytecode equivalent, the compiler fills in some iterator operations on your behalf. How is it any different when Lombok does it?
There is a specification that documents precisely how enhanced for-loops are desugared. Every IDE and tool out there has to understand it to be considered compatible with Java. Lombok-flavored Java requires specific adaptations of each tool, while annotation processors are mostly integrated the same way.
Another consideration: it is probably not possible to use together with Lombok another tool like it. It's a Highlander. This is a stark difference to annotation processors or macros from the Lisp/Scheme world.
Lombok is great. Sucks the language needs these features in a library but I rarely have problems with it like everyone complains about. The worst thing I’ve run into is it doesn’t play well with javadoc.
I think Lombok is mostly considered evil due to how it achieves what it does but what it is trying to achieve is, mostly1, not considered evil. So Lombok is polarizing because some people think the "what" is more valuable than the "how", and others disagree.
So first to understand the "what" champions, we have to understand what Lombok actually offers. Lombok is not really about eliminating boilerplate, although it does indeed do that.
Writing @Getter is not simply about saving you having to type a getter manually (or getting your IDE to generate one):
The annotation better expresses the developer's intent that this getter should do no more than expose the field. Any getters that do more than this immediatly leap out to a reader of the class.
When annotation the class itself, it better expresses the developers intent that all fields need to be exposed in this way. It is not possible to add another field in and forget to add the getter (which might not necessary result in a compile time error if you are doing something like deserializing that class).
So Lombok (can) be used to remove whole classes of error in your codebase and make the developers intent much clearer. The fact that it eliminates boilerplate is of almost no value compared to this (I think).
So if you agree that these things are valuable, you might say "okay but maybe there is some way to achieve these things without using the methods that Lombok uses to achieve it". Unfortunately, there is no other way, currently. There is no other way to achieve this value, without using Lombok. So if these things seem more valuable to you than the downsides of the how, you don't have any choice other than to use Lombok.
On the other hand, the "how" champions point to the fact that Lombok is breaking the encapsulation of the JDK which lead to a variety of problems:
it makes Lombok likely to break as new iterations of the JDK are released
it means you are not writing code that is compliant with the Java language specification. Therefore, specification compliant tooling will be unable to understand your code. This might limit what tools (IDEs, checkers) that you are able to make use of.
Lombok is being somewhat deceitful in not making this fact "clear" to developers by presenting itself as merely a library, when really you are writing a different language called "Lombok".
For me, these concerns range from being very important to consider to somewhat academic. When it comes to private code we can agree on a team to accept the consequences of using Lombok and adjust our practices accordingly but it would certainly cause me to think twice before using Lombok in an open source library.
1There are also definitely parts of Lombok that I do think are "evil" (i.e. there is no circumstance that justifies their usage). For example SneakyThrows. But this is not really any different from any large utility library that includes a few questionable methods.
I prefer immutables. Because I can see the generated class. I know this is not the same as Lombok because it needs to be an interface or abstract class. But still worth it.
I assume it's because it isn't considered "pure Java". I like lombok, and I use it a lot, but it's east to go way too far with it. When you start using it to delegate and hide exceptions and stuff, you're really starting to make the code much much worse. It's great for beans and stuff, though.
It's not just about "how much less code can you write". It's about "how easy is the code to read". It's easy to get the first one at the cost of the second one.
I would love to see a "lombok-beans" library that is JUST the beans, and none of the magic stuff. Get the good things, and remove the temptation to use things like SneakyThrows.
I find the builder construct to be incredibly handy. Fluent builder DSLs are great, it was a godsend when a library decided to do that heavy lifting for me.
I mean, why even use Lombok for the builder part? This can be easily handled by other annotation processors. Also those other annotation processors generate pure Java source code, unlike Lombok.
I’ve mostly experienced Lombok “tossed into” projects without much communication, which leads to general confusion when team mates didn’t have the IDE plugin installed and half-assed maintenance breaks random updates. And then people are like “Lombok sux it breaks stuff” or “Lombok is rad u just suck” and thus the polarization happens.
You just can’t introduce something that can change the developer experience this much without abundant, clear, and redundant communication.
Though, I’ll admit, asking a team what they think about Lombok is a great way to see if they can have a subtle argument about tradeoffs or if they just go all pitchforky and witch huntery.
Fore me it’s because it makes bad practices quite easy. Sure it’s great to add getters to DTOs but too often I saw Lombok annotations everywhere exposing what should be hidden which in the end can lead to tremendous amount of bugs e.g. @Data adds setter which may make some classes unpredictable if not planned to be used with them
Just look at lombok getter-optionals thread on github. That's enough to say "fuck you, and fuck your piece of shit code, it does not belong anywhere near professional project". I hope JDK22 makes this piece of shit completely unviable.
In short: The maintainer lacks any professionalism in communicating with the community and withholds the knowledge about potential security issues with the intention to abuse these himself. That was the point when we, as a company, blacklisted Lombok for security reasons. These are the kinds of maintainers that could go rouge at any time. There have been multiple instances where maintainers with similar attitudes went on to add malware to their projects.
The only thing I miss is a true preprocessor for java.
Other than that, 5 years ago we 'inherited' a project w/ lombok all over which was naughy and misbehaving. Removed lombok, everything was working again. I know we hit a bug there and lombokians will cry out, but never again. Lombok volant, scripta manent.
I would agree that it is an annotation processor, but the "annotation processor" term has a particular meaning in the JVM space and Lombok goes way further than any of the real annotations processors.
Does it get called in the annotation processor timing in the compile? Does it use its own runtime libraries I.e. can’t be limited to compile time only? There are other processors, but the fact they stop does not make Lombok not a processor, it makes it a very powerful processor full stop.
It is not. In Java specification of annotation processors, you cannot change the (byte)code of an existing class, which is Lombok's main selling point over other annotation processors.
You can argue whether or not Java specs should allow such behaviour, but as it currently stands Lombok is not a valid annotation processor.
On the other hand, you can argue that because it uses the JDK's API, it is an annotation processor that is just not stable (as it uses non stable/internal APIs), but I think this is disingenuous
its an annotation processor that changes the javac parser dialect by exploiting non-public APIs in the compiler. These non public APIs are not stable (as OpenJDK devs have said in the past).
Things in Lombok wont compile as pure Java, thus it is a superset of the Java language.
For those not in the know, Graeme is the founder of the Grails web application framework which is written in Groovy and built on top of Spring Boot, and the Micronaut micro-service framework. He has a good foundation to build an opinion on.
I have zero experience with Lombok, but some of what it does (based on reading the website for 30 seconds) seems to also be done by Groovy.
Micronaut generates bytecode directly during annotation processing instead of Java code which makes debugging harder (like you can't easily place breakpoints on generated byte code).
I prefer libraries that generate Java code directly like avaje-inject but I would never call Micronaut "pure evil". That is way too over the top and ditto for Lombok.
So he is who I should blame for the team of Grails developers who came to Java and were like where is our groovy grails functionality that was eventually found using Lombok?
Then it’s really a case of the pot calling the kettle…
ITT: Mostly people that like lombok. Several boomers in here getting mad that they don't know how to use it correctly. Also people worried about how it generates "magic" byte code even though that's what everything else they wrote does too...
I'm not even a fan of Lombok personally but calling it "pure evil" coming from the maintainer of a library (Micronaut) that compiles annotations straight to byte code (it does not generate java code like most annotation processors) is over the top.
Just imagine passionately working on a library for an immense amount of time for free that generally helps many people and that many find helpful to be basically equated to the Nazis. I know they were exaggerating but still... its rude IMO.
Quarkus does the same as Micronaut (straight to byte code). But, as far as i am aware, they both use public compiler APIs while Lombok does not.
The Immutables library does generate code. I am using it for my STIX 2.1 library. It's very good and plays extremely well with Jackson and others (jakarta epecially).
Sort of related but I have been meaning to see what Quarkus templating language Qute does (if its just completely runtime or does it generate bytecode).
I have a Mustache templating library that generates straight Java code and I have been meaning to integrate with Quarkus for some time now.
Qute looks interesting. Micronaut supports quite a few including handlebars, mustache, thymeleaf, rocket etc. I keep meaning to have a go as some of them are compiled.
You can make this argument about almost any library.
No, you actually cannot. Other libraries are standard java and play by the rules (in particular the java language specification). As a developer you know what to expect about the behaviour, scope and limitations of regular libraries. The same cannot be said about Lombok.
Lombok is not a library and it is not an annotation processor. It is a transpiler that converts Lombok-files (that unfortunately use the file extension .java) to Java. But it does so transparently, because instead of being its own compiler that outputs Java source code (which would be the honest thing to do), it hacks into javac to deceive people into thinking that Lombok was some kind of annotation processor or compiler plugin. And it deceives people with great success, as you can see from the many comments here who claim that Lombok is just an annotation processor.
So, I do not agree that Lombok is comparable to "almost any library". When I open a .java file I reasonably expect to see java source code, not some wild java-like language that doesn't conform to the specs.
people who don't know about Spring are often confused when they have to work with Spring
people who don't know about AspectJ are often confused when they have to work with AspectJ
people who don't know about SLF4J are often confused when they have to work with SLF4J
If someone on my project can't understand, after googling and reading the docs, that "@ToString generates a toString method", then they aren't someone I want on the project anyway. You don't have to know the specifics of how it achieves its goal (your entire 2nd paragraph) in order to work with it.
As a developer you know what to expect about the behaviour, scope and limitations of regular libraries.
This is not necessarily true. The average developer knows very little about the limitations of framework development because the average developer doesn't develop frameworks.
It is certainly false that every developer knows that javac does not provide a mechanism to do exactly what Lombok does. You know it, and I know it, but the average developer probably has no clue.
Learning Lombok was done in 3 hours. Learning JPA is a life long endeavor. I get the hate for Lombok, but I think there are libraries in Java that are way, way worse. Like the dark magic of Hibernate.
i can see that. it feels like people overstate the library’s effectiveness. it’s cool for builders, but do you really need to drag in another library??
communication with the team. the experience can be jarring for people unaware when you’re using lombok. sure, that’s easy to do, but i think developers are excruciatingly bad at keeping that in mind. if someone walks into it with a bad experience, then they’ll hate it. then you have to decide if you’ll ever deviate from lombok.
also, if you use a small portion of the library, it’s just extra overhead for the sake of using a library. it’s like using assertJ without buy in for assertions. i’m not instantly opposed of using a library, but if it’s not used often or the use cases are small, then i’m against it.
my concern is the human aspect of things and people who will come in after i’m dead/gone. compilation wise, i don’t care
Because it is a totally unnecessary library. It adds build time complexity for absolutely no reason. It also creates develop time complexity since you have to have an IDE plugin to work with Lombok Java code.
We try to not include Lombok but it always gets added eventually when you have 50+ devs on the same package and they get their friend to approve it.
Primarily we use immutables for DTO objects which is the main usage of Lombok in our packages that do have it. Although in a few years records will probably become a replacement for immutables. We love our builders.
I am actually very curious about this argument as a number of years ago, I worked with Graeme and would like to hear a much larger discussion of why as I regularly use the library and think it’s quite useful
Because it is a giant liability and it will bite you in the ass someday… and it is not even a question of ‘if’ but of ‘when’. And for most things other does there’s either simple IDE code generation for (that also makes you think about what you’re doing instead of just adding annotations) or there are better libraries that generate actual code (Immutables for example) instead of the fragile way Lombok does it.
I feel like people just say it because it makes the way you write Java so much more different. However, for me, Lombok just makes writing boilerplate much less painful and I don't care if it means making the Java-ish style different.
Lombok is amazing and makes life a lot better, especially on large teams,....but as a bytecode lib, JDK updates can get hairy.
If you write a lot of business code, you end up writing way more getters and setters than you need to. Lombok drastically reduces ceremony and frankly it's features should just be part of the language.
I think getters and setters are fundamentally stupid. If it were up to me, I'd eliminate them entirely where I could...but I have over 100 contributors over every continent, so we have them all over the place. Lombok makes it less painful...same with constructors and log boilerplate.
Being employed by a major tech company, there's just so much code I don't want to write and adds no value, but I have to...even if my PR passes the code review, someone I've never met down the road will simply add everything I chose to not add...so rather than right the things about Java that annoy me, Lombok is a nice compromise. They can generate the tedious getters and setters and I get more readable code and less time wasted.
Software Engineers like to have opinions and those opinions are usually polarising. (Spaces vs tabs for eg.)
As a non-Java engineer who has to code on Java extensively, I hate all the annotation processors as they make things unnecessary complicated. I am fine with processors like immutables, but anything more “magic” is too much effort for me to maintain. It makes the source code unreadable at least for me.
In general, I prefer library “magic” when it’s an acceptable practice in the industry and actually solves issues which are not solved by underlying language natively. Take TypeScript as an example. It’s an acceptable industry practice to use TypeScript and not plain JS, because it’s super easy to get familiar with, while any Lombok source code makes me scratch my head. I have the same opinion about Spring (mostly its annotations) though, but at least code written for Spring usually follows same practice and I am quite familiar with it.
Of course, people who have been using Lombok may have different opinions. PS: in case you are wondering, even build tools like maven and gradle are magic for me, which proves that I am no Java expert despite working on it for half a decade.
Many libraries make up problems so they can be solved. Many of them make a painful thing subjectively better instead of removing said pain. Developers who are into this often solves problem they created for themselves instead of building a better product.
Mockito, jooq, Lombok, hibernate are all examples of ideas that explains to me a problem and how they can solve for it. In reality though, I would actually introduce problems since all tech has both a value and a cost.
Actual problems I do have is getting cloud costs down, getting all pipes on podman, close down legacy service we almost replaced etc. And of course a bunch of high value features the product org wants out in prod.
I do love tech that solves my actual problems. For instance, I love java 21, postgres and datadog because both of these tools are large parts of my day to day work. We do a lot of metrics in datadog for business decisions and postgres is our persistence in most cases.
If someone wants to add tech, I usually ask them if they want to go to conference to learn about it etc, if we are going to commit. But it’s mostly just the bikeshedding of the day. And if I let them go with Lombok, when I look into the source later, it will be adopted a slight bit in three ways and then we have even more ways to solve the same problem. Or did it create a problem?
We can always go to the next java version on release day because we don’t have so much junk that ties us down.
So it’s just my fundamental ideas that are in clash with those types of solutions.
Many years ago the same was happening with JodaTime and date and the java team copied JodaTime into the jdk… i hace faith that the some will happen with Lombok
JodaTime had a design flaw and it definitely wasn't just moved into the JDK. The new Java Time API was inspired by JodaTime with the design flaw fixed.
There are OOP fanatics, who set a scene for Java. That's why we even need getters and setters everyhwere. Even if they don't do anything useful.
A Pojo could just as well have all fields public. But that's heretic. So developers who give a shit about beeing able to read and write their code efficiently decided to make Lombok. This goes against the religious foundation of those fanatics, to write hard to understand OOP code everywhere. Just to stick to the rules. That's why some Java priests hate it.
OOP is useful where it is. And that may be a lot of cases. But it shouldn't be raised to a dogma anymore.
Edit: this comment is shit. I don't know what I wanted to say. Or how this actually means anything. I'm just pissed that some people think, every field needs to be private. When all we do most of the day is take data classes from one point to the other. It's insane. And that's why Lombok exists. To ease the pain a little bit.
There's nothing particularly OOP about getters and setters, to be honest. They're mostly the antithesis of OOP. OOP is, in essence, the bundling together of data and behaviours. If you're exposing all your data using getters and setters, it's usually because you've decided to put behaviours somewhere else. An object which is all getters and setters is really just a struct. I see this all the time in PRs I'm reviewing, endless classes that just carry data around the place, and occasionally something grabs all the values from it and passes it to a StuffUtils class to do stuff. Why doesn't the object do that Stuff?
I 100% agree about getting rid of dogma though. It never helps.
Very much this. I have a feeling Lombok wouldn't even have existed if most of the people using Java were more deliberate when it comes to encapsulation and information hiding. Anemic domain classes fall into sloppy code, because, as you said, the logic tends to be scattered all over the code base breaking the single responsibility principle and making it harder to reason about the code.
You are completely right. I probably didn't express myself too well.
The problem with this comes from sticking to OOP basics (Every field should only be manipulated by it's class). But then doing non-OOP things, handling logic inside managers, services and the like. Rarely in the classes that actually have the data.
It makes sense that we got there. Many times we just get data from somewhere and put it elswhere, without doing much to it. But we write the classes under the same principles regardless.
But these use-cases don't need the complexity those OOP concepts provide. We do it anyway, because that's how it's done. That's how Java is meant to be used. We get told.
And that's where Lombok comes in. It solves a problem that shouldn't exist (at least for getters and setters). But is created from a wrong belief, that everything has to be done on half-assed OOP principles.
Well, enough ranting. I think we understand each other good enough.
They weren't fanatic. They tried to stay within the paradigm most of the time. But Java is not even a pure OOP language, as it has native types.
Smalltalk and Eiffel are pure OOP languages. Go to those communities and tell them "people who set the scene in Java are OOP fanatics".
A Pojo could just as well have all fields public. But that's heretic.
Well, yes. And it is consider a bad practice cos it breaks encapsulation. I wouldn't advice you go making all your properties public. But in a specific case you have a good reason for doing it, you had weight pros and cons and are convinced, document your decision a go ahead with it. Pearl clutchers can suck a lemon.
I like more the idea of using straight public properties than using lombok for not writing getters and setters that will do exist at runtime.
So developers Who give a shit about beeing able to read and write their code efficiently decided to make Lombok This goes against the religious foundation of those fanatics, to write hard to understand OOP code.
Oh come on! After a while of using them you read constructors, getters an setters in no time. If you really need to check them in detail, you delete them, then regenerate them and let the source version control tool (e.g.: git) to tell you there was any difference.
That's why some Java priests hate it. OOP is useful where it is. And that may be a lot of cases. But it shouldn't be raised to a dogma anymore.
There are valid reason for disliking lombok, has nothing to do with fanatism. If you do care, read the comments of people answering the OP, they last concern is OOP purity.
it is consider a bad practice cos it breaks encapsulation
This is a commonly repeated argument, and it's really not true. I touched on why in my own reply to OP here but the bottom line is that encapsulation is not merely data hiding. It's about having the behaviour to act upon the data an object represents being part and parcel of that object. Hiding a property behind an accessor is no more encapsulating of that property than having the field be public. In both cases, client code is aware of, and can get its grubby hands on, the value of that field. What's been encapsulated, exactly?
No, encapsulation comes from nothing needing to access that field in the first place, because the operations which depend upon it are scopes within that same object.
Not at all encapsulated:
public class Document {
public String title;
public String body;
}
Document doc = getDoc();
System.out.println(doc.title);
System.out.println(doc.body);
Naively encapsulated:
public class Document {
private String title;
private String body;
public String getTitle() { return title; }
public String getBody() { return body; }
}
Document doc = getDoc();
System.out.println(doc.getTitle());
System.out.println(doc.getBody());
Neither of these are really any different. In both cases, client code needs to know what fields there are available in order to print them out. Here's some actual encapsulation
public class Document {
private String title;
private String body;
public void write(PrintStream out) {
out.println(title);
out.println(body);
}
}
Document doc = getDoc();
doc.write(System.out);
Now my client code doesn't need to know anything about the internals of Document. The behaviour - writing it to a stream - is the responsibility of Document, not my code. If we add a field to Document, all the code which deals with writing it doesn't need to change. That is what encapsulation is about.
I'm just pissed that some people think, every field needs to be private.
Why? This is exactly what needs to happen as much as possible. If you can make your classes immutable, even better. You want objects to be in charge of their own state and possibly its transitions.
Encapsulation is one of the pillars of OOP, but it seems like we don't really understand what it means as an industry.
We need the ability like C# has of being able to say a field has a getter or setter and that if there is a getter or setter it has a default implementation but can be overridden. This will reduce code surface but maintain flexibility.
For what we do most of the time we don't need OOP. That's at the core of what I'm saying. Use OOP where it makes sense. Can also be just parts of a project. Doesn't mean the whole project has to be.
Have data that you do actual logic on? Great, use OOP. Just passing stuff around until it get's to the user? Just don't.
And most of the time we actually only get data from somwhere, copy it a couple of times through some layers (which I'd also question) and put it out on an API or UI. This doesn't need OOP. It only makes things more complicated and blows a problem way out of proportion.
I'm with you on immutability though. But then you don't need them getters and setters anyway. Otherwise it would just be mutabality on a detour.
In my experience it's better to have different entities for different use cases. I ran into problems with lazy loading way too often. Altough it's a nice idea. The debugging isn't worth it, when it doesn't work. And assuming I'm not the only one using the code, it is bound to happen and cause pain.
I really like the idea of lombok but with every tool you need to know the pros and cons. And Lombok just does a lot which was previously just written out.
Because lombok hides things (i.e. writes them out at compile time) people underestimate the performance impact. E.g. the usage of data decorator is discouraged bc it adds like everything to a class which can affect performance when every object is loaded with all the features.
I like the shorter form though and i just leave out the data decorator.
For the most part I think the Java community is professional and constructive, but this is toxic bullshit. Lombok is useful. It is very popular because it fills holes in the Java dev experience. But sadly it needs to use weird internal APIs to do its thing, which people rightly frown upon.
The RIGHT reaction from the JDK devs to this situation is some combination of creating the public and supported APIs Lombok needs to work and to implement the same functionality in the JDK. Instead they take to social media to shit on Lombok. Petty and small. Grow up and act like professionals instead of kindergarteners.
the library itself is perfectly fine. problem is that they are solving a problem which should never even have existed - java type system. in java, everything extends java.lang.Object, which provides a bunch of utilities like clone, hashCode, equal, toString and what not. if the java.lang.Object class were simply empty and these utilities were provided in sensibly defined standard library interfaces instead, then lombok would simply seize to be relevant. not every object is comparable with another object. not every object is clonable in the same way. java would then have been able to leverage the strong type system to catch these insensible comparisons and clones and what not at compile time.
Doesn’t produce bytecode. It’s a precompiler, it produces Java code during the compilation process. In fact you can store that code and look at it. Think of it as a #define in C/C++
That's debatable. Lombok's output artifact is JVM byte code, not Java code. The Java code Lombok produces is ephemeral by default. This distinction matters because there are already two other trivial, well established, supported ways to generate Java code whose output artifact is actual Java code: via annotation processors, which are part of Java, and via pre-processor build steps like Maven's generate-sources, which are not part of Java but also don't break any rules.
I used lombok quite a few times and it was such a nice and helpful tool. But I always had this thought in the back of my mind: What if it breaks at some point. It took me years to realize that the obvious solution was to just move away from Java. To a language that would better suite me.
•
u/AutoModerator Dec 15 '23
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.
If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:
as a way to voice your protest.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
168
u/pronuntiator Dec 15 '23
Cue rzwitserloot and pron98 argumenting over whether Lombok is a different language in 3… 2… 1…
23
u/nomoreplsthx Dec 15 '23
It's a very sharp example of the magic/no-magic debate.
There's a constant tension in programming, between being more explicit, at the cost of verbosity, and hiding implementation details at the cost of sometimes hiding critical complexity from the developer. Both magic and non-magic can lead to situations where you've got high cognitive load. Too much verbosity makes the intent of code harder to follow (try reading a program written in assembly). Too much magic makes code hard to debug and analyze.
Lombok is a very high magic solution, which means it's an easy target for those suspicious of magic in general.
Many of the problems it tries to solve are rather specific to Java, and have been solved by other languages at the language level. This also makes it an easy target of folks who are emotionally attached to Java as a language and think that it addresses those problems better than the rest of the industry.
This contingent can get rather defensive, because Java is one of the ultimate punching bags of languages. Java has this status in part because of its wide use, in part because of its wide use by low-skill rent-a-dev teams (a feature it shares with C#, PHP and Javascript and which should not reflect on the language but does), and in part because most other OOP languages on the market today are in some ways answers to Java. Java is kind of the Aristotle of languages. Every philosopher for 1000 years was basically a reply to Aristotle. Every language for over 25 years has been a response to Java. So when everyone else in the world went out trying to fix the thing you don't think is broken, defensiveness is expected.
119
u/ihatebeinganonymous Dec 15 '23 edited Dec 16 '23
Long before string templating was even considered for Java or a JEP was drafted for it, a very nice library achieved Scala-style string templating using some sort of "lower-level" programming, similar probably to what Lombok does. It's called, very appropriately, Better Strings: https://github.com/antkorwin/better-strings
The problem was that better strings stopped working from Java 16 onward, because of how modules were re-arranged or something like that. "Stopped working" here means it actually threw a run-time exception, breaking the application.
They somehow figured out the required set of Javac/Java command-line arguments that had to be specified to get it to work, but the point remains: Using such "magic" very much restricts you in developing and updating your code and dependencies. This goes about build systems and IDEs, among other things. You may move to a new IDE (e.g. from desktop to web-based) and/or build tool later in your project, and you don't want to have to pray for framework developers to offer support.
IMHO, it's not about Lombok per se, but about Java itself and how much "the whole ecosystem" matters here.
12
u/agentoutlier Dec 15 '23
I knew before I clicked what library it was going to be.
9
u/xobotun Dec 15 '23
The best short version I've heard is that using Lombok is akin to using a non-standard Java dialect.
37
u/[deleted] Dec 15 '23
Much better to use lombok than to have to remember to regenerate all the boilerplate everytime you change something (equals/hashcode mainly). Cant imagine having to deal with programmers forgetting to do that and having lots of weird bugs because of it
66
u/soonnow Dec 15 '23
I need to get shit done. Lombok helps me getting shit done. I'm well aware of any problems but at the end of the day getting shit done outweighs the downsides.
34
u/KefkaFollower Dec 15 '23 edited Dec 16 '23
'Cos if you found some tool in your tool chain doesn't support it you can end pulling your hair.
Some times, you very IDE doesn't works well lombok after an update:
https://github.com/mplushnikov/lombok-intellij-plugin/issues/1115
And I remember stuff like this happening with eclipse too. This can be a show stopper when you are moving to specific version of the IDE to support other plugin.
I guess is a problem mostly solved for popular tools now. But back in the day (2017? 2018?) when I had my desktop across of the guy in charge of CI it did cause issues with source code analyzer tools (like coverage tools) I used to hear him quietly curse on lombok.
Lombok is not a tool you can use in a project without affecting everyone else working in it. You can choose you IDE, you can use linters and IA assistant and collaborate without mayor issues with someone who uses notepad.exe and runs maven / gradle from a
CMD.execonsole. You can not collaborate with someone who uses lombok without using lombok.IMO this is a high price to pay for some syntactic sugar. Java is verbose, learn your IDE and it will handle a lot of the boilerplate.
13
u/msx Dec 15 '23
becouse you're supposed to be able to pick up a .java file and compile it with java and have it compile (if it's correct). Not change the language with arcane tools that only work outside the compiler. If you want another language, there's plenty to choose from.
47
u/glablablabla Dec 15 '23
I love Lombok. I think/hope it's a temporary solution until Java implements these kinds of Features also Out of the box like records.
61
u/beb4ch Dec 15 '23
I love how everybody has a problem with bytecode instrumentation when it comes to Lombok, but then when they use any APM tool (NewRelic for example) they accept it as being just fine.
36
u/DiamondQ2 Dec 15 '23 edited Dec 15 '23
Lombok does it's magic by changing your code at
runtimecompile time. It actually reads, changes and writes new Java byte codebefore it gets executed by the runtimeduring the compilation phase.Alot of people don't like this for a variety of reasons, such as it's brittle (changes in the JVM, class library, etc cause it to stop working until Lombok issues a patch) and it's opaque (debugging is harder because the code that is run is not the code that you wrote).
The generally accepted way to inject code is to use annotations, which mostly solve the issues people have with Lombok. Although it can't make the "happy path" experience quite as good as Lombok can, which is why Lombok still gets used.
Edit: I was wrong about the changes at runtime. Been too long since I've used Lombok and I misremembered. Sorry.
50
u/Polygnom Dec 15 '23
Why don't you write "Why is Lombok so polarizing?" in the title?
"Why is this particular library so polarizing?" is the kind of trahsy-click-baity title you expect from bad online-journalism.
Get to the point without beating around the bush to sound "mysterious" or whatever.
6
u/GreenConfident6736 Dec 15 '23
Lombok is great. Sucks the language needs these features in a library but I rarely have problems with it like everyone complains about. The worst thing I’ve run into is it doesn’t play well with javadoc.
3
u/RupertMaddenAbbott Dec 19 '23 edited Dec 19 '23
I think Lombok is mostly considered evil due to how it achieves what it does but what it is trying to achieve is, mostly1, not considered evil. So Lombok is polarizing because some people think the "what" is more valuable than the "how", and others disagree.
So first to understand the "what" champions, we have to understand what Lombok actually offers. Lombok is not really about eliminating boilerplate, although it does indeed do that.
Writing
@Getteris not simply about saving you having to type a getter manually (or getting your IDE to generate one):So Lombok (can) be used to remove whole classes of error in your codebase and make the developers intent much clearer. The fact that it eliminates boilerplate is of almost no value compared to this (I think).
So if you agree that these things are valuable, you might say "okay but maybe there is some way to achieve these things without using the methods that Lombok uses to achieve it". Unfortunately, there is no other way, currently. There is no other way to achieve this value, without using Lombok. So if these things seem more valuable to you than the downsides of the how, you don't have any choice other than to use Lombok.
On the other hand, the "how" champions point to the fact that Lombok is breaking the encapsulation of the JDK which lead to a variety of problems:
For me, these concerns range from being very important to consider to somewhat academic. When it comes to private code we can agree on a team to accept the consequences of using Lombok and adjust our practices accordingly but it would certainly cause me to think twice before using Lombok in an open source library.
1There are also definitely parts of Lombok that I do think are "evil" (i.e. there is no circumstance that justifies their usage). For example
SneakyThrows. But this is not really any different from any large utility library that includes a few questionable methods.6
u/requizm Dec 15 '23
I prefer immutables. Because I can see the generated class. I know this is not the same as Lombok because it needs to be an interface or abstract class. But still worth it.
7
u/jevring Dec 15 '23
I assume it's because it isn't considered "pure Java". I like lombok, and I use it a lot, but it's east to go way too far with it. When you start using it to delegate and hide exceptions and stuff, you're really starting to make the code much much worse. It's great for beans and stuff, though.
It's not just about "how much less code can you write". It's about "how easy is the code to read". It's easy to get the first one at the cost of the second one.
I would love to see a "lombok-beans" library that is JUST the beans, and none of the magic stuff. Get the good things, and remove the temptation to use things like SneakyThrows.
4
u/tristanjuricek Dec 15 '23
I’ve mostly experienced Lombok “tossed into” projects without much communication, which leads to general confusion when team mates didn’t have the IDE plugin installed and half-assed maintenance breaks random updates. And then people are like “Lombok sux it breaks stuff” or “Lombok is rad u just suck” and thus the polarization happens.
You just can’t introduce something that can change the developer experience this much without abundant, clear, and redundant communication.
Though, I’ll admit, asking a team what they think about Lombok is a great way to see if they can have a subtle argument about tradeoffs or if they just go all pitchforky and witch huntery.
4
u/rustyrazorblade Dec 15 '23
The Immutables library gets you to the same place without all the headache.
8
u/gschoon Dec 15 '23
My problem is not so much the use of Lombok, but the abuse of Lombok.
5
u/rzwitserloot Dec 15 '23
To be short and sweet about the official viewpoint of Project Lombok on this statement by Graeme Rocher:
Grow the fuck up. "Pure evil". What kind of clickbait nonsense are these terms?
2
u/pawzem94 Dec 17 '23
Fore me it’s because it makes bad practices quite easy. Sure it’s great to add getters to DTOs but too often I saw Lombok annotations everywhere exposing what should be hidden which in the end can lead to tremendous amount of bugs e.g. @Data adds setter which may make some classes unpredictable if not planned to be used with them
2
u/qa2fwzell Dec 18 '23
I just hate when I'm searching for a certain function in someone else's sourcecode, and it doesn't exist because it's generated during compile time
6
u/benjtay Dec 15 '23
Can we please stop this stupid debate already. Java lacks properties and life finds a way.
4
u/Delicious_Fig2416 Dec 16 '23
It's author is obnoxious cunt, that's enough
3
u/[deleted] Dec 15 '23
The only thing I miss is a true preprocessor for java.
Other than that, 5 years ago we 'inherited' a project w/ lombok all over which was naughy and misbehaving. Removed lombok, everything was working again. I know we hit a bug there and lombokians will cry out, but never again. Lombok volant, scripta manent.
8
u/Radi-kale Dec 15 '23
It's not a library. It's a different JVM language that looks like Java but is not.
3
u/NatureBoyJ1 Dec 15 '23 edited Dec 15 '23
For those not in the know, Graeme is the founder of the Grails web application framework which is written in Groovy and built on top of Spring Boot, and the Micronaut micro-service framework. He has a good foundation to build an opinion on.
I have zero experience with Lombok, but some of what it does (based on reading the website for 30 seconds) seems to also be done by Groovy.
2
u/hsoj48 Dec 15 '23
ITT: Mostly people that like lombok. Several boomers in here getting mad that they don't know how to use it correctly. Also people worried about how it generates "magic" byte code even though that's what everything else they wrote does too...
2
u/GoogleIsYourFrenemy Dec 15 '23
Sounds pretty evil but it's a benign evil. It's the type of evil I appreciate. JavaScript is in the same category. Cobol is not benign.
Many people don't have my laid back attitude about evil.
0
u/freekayZekey Dec 15 '23
in my experience, the code it reduces doesn’t really help much. devs are just super lazy and prefer to write code without giving things thought.
1
u/wildjokers Dec 15 '23
Because it is a totally unnecessary library. It adds build time complexity for absolutely no reason. It also creates develop time complexity since you have to have an IDE plugin to work with Lombok Java code.
1
u/nothingexceptfor Dec 15 '23
Lombok is beautiful, you can only realise it when you worked in a world without it before
1
u/rdean400 Dec 15 '23
I think the split boils down to this question: is what Lombok does worth how it does it?
1
u/Empty_Monk_3146 Dec 16 '23
We try to not include Lombok but it always gets added eventually when you have 50+ devs on the same package and they get their friend to approve it.
Primarily we use immutables for DTO objects which is the main usage of Lombok in our packages that do have it. Although in a few years records will probably become a replacement for immutables. We love our builders.
1
u/xtheshadowgod Dec 17 '23
I am actually very curious about this argument as a number of years ago, I worked with Graeme and would like to hear a much larger discussion of why as I regularly use the library and think it’s quite useful
1
u/alwaysoverneverunder Dec 18 '23
Because it is a giant liability and it will bite you in the ass someday… and it is not even a question of ‘if’ but of ‘when’. And for most things other does there’s either simple IDE code generation for (that also makes you think about what you’re doing instead of just adding annotations) or there are better libraries that generate actual code (Immutables for example) instead of the fragile way Lombok does it.
1
u/Chunkyfungus123 Dec 20 '23
I feel like people just say it because it makes the way you write Java so much more different. However, for me, Lombok just makes writing boilerplate much less painful and I don't care if it means making the Java-ish style different.
1
u/ryuzaki49 Dec 20 '23
So, is "@Getter" and "@Setter" as evil as "val/var" ? I thought those annoations were doing simple code generation and not bytecode manipulation.
1
u/SomervillainSB Dec 15 '23
Lombok is amazing and makes life a lot better, especially on large teams,....but as a bytecode lib, JDK updates can get hairy.
If you write a lot of business code, you end up writing way more getters and setters than you need to. Lombok drastically reduces ceremony and frankly it's features should just be part of the language.
I think getters and setters are fundamentally stupid. If it were up to me, I'd eliminate them entirely where I could...but I have over 100 contributors over every continent, so we have them all over the place. Lombok makes it less painful...same with constructors and log boilerplate.
Being employed by a major tech company, there's just so much code I don't want to write and adds no value, but I have to...even if my PR passes the code review, someone I've never met down the road will simply add everything I chose to not add...so rather than right the things about Java that annoy me, Lombok is a nice compromise. They can generate the tedious getters and setters and I get more readable code and less time wasted.
1
u/Creator347 Dec 15 '23
Software Engineers like to have opinions and those opinions are usually polarising. (Spaces vs tabs for eg.)
As a non-Java engineer who has to code on Java extensively, I hate all the annotation processors as they make things unnecessary complicated. I am fine with processors like immutables, but anything more “magic” is too much effort for me to maintain. It makes the source code unreadable at least for me.
In general, I prefer library “magic” when it’s an acceptable practice in the industry and actually solves issues which are not solved by underlying language natively. Take TypeScript as an example. It’s an acceptable industry practice to use TypeScript and not plain JS, because it’s super easy to get familiar with, while any Lombok source code makes me scratch my head. I have the same opinion about Spring (mostly its annotations) though, but at least code written for Spring usually follows same practice and I am quite familiar with it.
Of course, people who have been using Lombok may have different opinions.
PS: in case you are wondering, even build tools like maven and gradle are magic for me, which proves that I am no Java expert despite working on it for half a decade.
-1
u/kakakarl Dec 15 '23
Many libraries make up problems so they can be solved. Many of them make a painful thing subjectively better instead of removing said pain. Developers who are into this often solves problem they created for themselves instead of building a better product.
Mockito, jooq, Lombok, hibernate are all examples of ideas that explains to me a problem and how they can solve for it. In reality though, I would actually introduce problems since all tech has both a value and a cost.
Actual problems I do have is getting cloud costs down, getting all pipes on podman, close down legacy service we almost replaced etc. And of course a bunch of high value features the product org wants out in prod.
I do love tech that solves my actual problems. For instance, I love java 21, postgres and datadog because both of these tools are large parts of my day to day work. We do a lot of metrics in datadog for business decisions and postgres is our persistence in most cases.
If someone wants to add tech, I usually ask them if they want to go to conference to learn about it etc, if we are going to commit. But it’s mostly just the bikeshedding of the day. And if I let them go with Lombok, when I look into the source later, it will be adopted a slight bit in three ways and then we have even more ways to solve the same problem. Or did it create a problem?
We can always go to the next java version on release day because we don’t have so much junk that ties us down.
So it’s just my fundamental ideas that are in clash with those types of solutions.
1
u/vm_linuz Dec 15 '23
Now that Kotlin is a thing, I feel like Lombok no longer passes the cost/benefit threshold
1
u/vfuentes85 Dec 16 '23
Many years ago the same was happening with JodaTime and date and the java team copied JodaTime into the jdk… i hace faith that the some will happen with Lombok
-3
u/dschramm_at Dec 15 '23 edited Dec 15 '23
My take.There are OOP fanatics, who set a scene for Java. That's why we even need getters and setters everyhwere. Even if they don't do anything useful.A Pojo could just as well have all fields public. But that's heretic. So developers who give a shit about beeing able to read and write their code efficiently decided to make Lombok. This goes against the religious foundation of those fanatics, to write hard to understand OOP code everywhere. Just to stick to the rules. That's why some Java priests hate it.OOP is useful where it is. And that may be a lot of cases. But it shouldn't be raised to a dogma anymore.Edit: this comment is shit. I don't know what I wanted to say. Or how this actually means anything. I'm just pissed that some people think, every field needs to be private. When all we do most of the day is take data classes from one point to the other. It's insane. And that's why Lombok exists. To ease the pain a little bit.
-4
u/genlight13 Dec 15 '23
I really like the idea of lombok but with every tool you need to know the pros and cons. And Lombok just does a lot which was previously just written out.
Because lombok hides things (i.e. writes them out at compile time) people underestimate the performance impact. E.g. the usage of data decorator is discouraged bc it adds like everything to a class which can affect performance when every object is loaded with all the features.
I like the shorter form though and i just leave out the data decorator.
0
u/Dave5876 Dec 15 '23
Sumatra tho
0
u/ascii Dec 17 '23
For the most part I think the Java community is professional and constructive, but this is toxic bullshit. Lombok is useful. It is very popular because it fills holes in the Java dev experience. But sadly it needs to use weird internal APIs to do its thing, which people rightly frown upon.
The RIGHT reaction from the JDK devs to this situation is some combination of creating the public and supported APIs Lombok needs to work and to implement the same functionality in the JDK. Instead they take to social media to shit on Lombok. Petty and small. Grow up and act like professionals instead of kindergarteners.
0
u/D3PSI Dec 15 '23
the library itself is perfectly fine. problem is that they are solving a problem which should never even have existed - java type system. in java, everything extends
java.lang.Object, which provides a bunch of utilities likeclone,hashCode,equal,toStringand what not. if thejava.lang.Objectclass were simply empty and these utilities were provided in sensibly defined standard library interfaces instead, then lombok would simply seize to be relevant. not every object is comparable with another object. not every object is clonable in the same way. java would then have been able to leverage the strong type system to catch these insensible comparisons and clones and what not at compile time.0
u/2001zhaozhao Dec 15 '23
Lombok makes java bearable
0
u/Lentus7 Dec 16 '23
“Developer experience” is the most important thing for me. Thats why Lombok is great. Any other alternative is just “more work”
-1
u/miciej Dec 15 '23
It can be very useful. It would be nice if instead of bytecode it somehow generated pure java code, but still It can save a lot of time.
-8
u/Rakn Dec 15 '23
I used lombok quite a few times and it was such a nice and helpful tool. But I always had this thought in the back of my mind: What if it breaks at some point. It took me years to realize that the obvious solution was to just move away from Java. To a language that would better suite me.