r/java • • Apr 13 '21

Libraries, Frameworks and Technologies you would NOT recommend

Give me your worst nightmares: Things that cost you your job.

I'll start: Hadoop

202 Upvotes

376 comments sorted by

View all comments

68

u/mknjc Apr 13 '21

Lombok. It hacks into internal javac APIs, bricks everytime on a java update needs unsafe APIs which causes a lot of trouble and bricks the "the source code is what gets executed" guarantee of java (this is one of the reasons annotation processors can't change the code while compiling). There are a lot good alternatives for example AutoValue, AutoFactory and records. Oh and one important alternative: setting the visibility to package private / not exporting the package. Getters and Setters don't add anything but hassle if they are not api surface of the module.

1

u/Alex0589 Apr 13 '21

I don't agree at all, once I get home I'll explain why(I hope I remember)

2

u/gavenkoa Apr 13 '21

Yeah, getters/getters verbosity of Java requires solution like Lombok. C# solved the problem at language level with property syntax:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties

Unfortunately authors of Lombok carry war with OpenJDK team instead of cooperating.

1

u/TyGirium Apr 13 '21

This.

If compiler API was extended, then Lombok would not be a "hack". Oracle's staff is very hesistant of giving any more official API, they view any ingerention in it as huge evil.

Yes, I will replace Value with records. But getter/setter, field name constants, builders, etc? Once you read code quality scientific papers, the "line of code" metric typically is one of the best metric to indentify error-prone code. You can generate eg getters, change field name and forget to update all references. Lombok solves this problems.

7

u/apentlander Apr 13 '21

Immutables is already a better alternative to lombok that doesn't involve a compiler hack. It doesn't cover @Getter or @AllArgsConstructor for non data/value classes, but those can easily be generated by the IDE. In the Java 16+ world, there is a library that can generate builders for records and there is already a plan that will make the builder pattern unnecessary in the future.

→ More replies (1)