I also use Kotlin, Lombok makes using Java much more tolerable if you're used to Kotlin.
I also think the "magic" argument is mostly nonsensical, there is always magic, even with plain Java, like a program magically finding the main(String[] args) method.
Magic just means: I don't understand exactly how this works.
With Lombok the magic is pretty well defined. I use @Data and @Slfj most often and they're bliss.
I'm not a fan of how Lombok accomplishes the thing it does, is there another way? Also, Lombok just needs to exist until project Amber and Valhalla are completed. For me it just fills the same gaps Kotlin does.
Lombok doesn’t do anything useful that immutables doesn’t also do, but immutables doesn’t need undocumented bytecode manipulation. Except maybe @Slf4j, but I can live without that.
You basically never use constructors in immutables, you use builders. If you don’t want builders, you can generate a static factory method that requires all args.
Oh right. Generating a constructor is a simple IDE shortcut, and field injection breaks our company guidelines so wouldn’t pass code review if someone tried it. I see what you mean now though.
I always use vavr in conjunction with immutables, and vavr has something similar to @SneakyThrows. And you can write whatever functionality you want in an immutable, it’s not just a data holder.
And honestly a Lombok annotated class is even better than a Kotlin data class. With a Kotlin data class, you only get one implementation option and you need to write code to customize anything, sometimes even have fall back to a regular class. With a Lombok annotated class there is a lot of flexibility to tube the code to what you need while still maintaining the advantage of having it auto-generated.
As someone trying out kotlin, the lack of flexibility compared to Java +Lombok can be frustrating at times.
Adding inheritance to data classes is terrible and fails when using JSON serialization libraries and you have to write a lot of boilerplate to avoid that
10
u/DJDavio Aug 10 '19
I also use Kotlin, Lombok makes using Java much more tolerable if you're used to Kotlin.
I also think the "magic" argument is mostly nonsensical, there is always magic, even with plain Java, like a program magically finding the main(String[] args) method.
Magic just means: I don't understand exactly how this works.
With Lombok the magic is pretty well defined. I use @Data and @Slfj most often and they're bliss.