News for hackers. Stuff that matters.
Re:Java 1.0 Turns 25 by nsxwolf on Saturday January 23, 2021 @11:31AM (#25883521)
Is anyone not using Lombok these days? I haven’t written a getter or a setter in years.
Re:Java 1.0 Turns 25 by JackFr on Saturday January 23, 2021 @07:29PM (#25887538)
Working with java for 20 years. Have never used Lombok, and honestly don’t personally know anyone who has. (Same with Kotlin.)

It’s a big world.

(Another weird thing for the first 25 years of my career never used anything but Sybase as a relational database — across 5 different firms. Never used Oracle or SQL Server.)

Re:Java 1.0 Turns 25 by pjmlp on Saturday January 23, 2021 @11:54AM (#25883816)
I never used and never plan to. Don't need bytecode magic that my IDE can do for me.
Re:Java 1.0 Turns 25 by marvy on Saturday January 23, 2021 @01:16PM (#25884713)
Consider the following two cases:

1. MyClass has 10 private fields, each with a trivial getter and setter.

2. YourClass has 10 private fields, of which 9 have a trivial getter and setter. The last one has a trivial getter but the setter is non-trivial.

If you use your IDE to write your getters and setters, than the two classes above will look the same at glance.

If you use Lombok, the "special" field will stick out at once.

Personally, I prefer to avoid Lombok and just use public fields. That way, the field with a nontrivial setter will also stick out, and no need for bytecode magic.

Re:Java 1.0 Turns 25 by pjmlp on Saturday January 23, 2021 @03:27PM (#25885732)
When I use my IDE, I use its code navigation features to my profit.
Re:Java 1.0 Turns 25 by marvy on Saturday January 23, 2021 @06:23PM (#25887071)
Okay now I'm curious: what IDE do you use that makes this a non-issue?
Re:Java 1.0 Turns 25 by pjmlp on Sunday January 24, 2021 @02:14AM (#25890024)
Eclipse, here are some tips.

- Ctrl + shift + T => search for types

- Ctrl + O => search for methods

- Ctrl + T => switch between classes

- Filters, https://help.eclipse.org/2020-12/index.jsp?topic=%2Forg.ecli...

Re:Java 1.0 Turns 25 by nsxwolf on Saturday January 23, 2021 @12:47PM (#25884440)
A bean with nothing but fields and a couple annotations is much cleaner and smaller than one full of generated getter/setter code. And I can rename a field without having to fumble around with the IDE to regenerate them.
Re:Java 1.0 Turns 25 by pjmlp on Saturday January 23, 2021 @01:11PM (#25884667)
Never learned to use code navigation tools and respective IDE filters?
Re:Java 1.0 Turns 25 by nsxwolf on Saturday January 23, 2021 @01:18PM (#25884736)
Those aren’t as good as just using Lombok.
Re:Java 1.0 Turns 25 by pjmlp on Saturday January 23, 2021 @01:30PM (#25884846)
Indeed, they don't provide the pleasure to dig out bugs caused by mishandling bytecodes or the verifier.
Re:Java 1.0 Turns 25 by petersellers on Sunday January 24, 2021 @12:47AM (#25889650)
Are you referring to code folding? Stuff like that helps but it's still not as good as Lombok just generating the getters and setters for you. I'm not sure if IntelliJ can filter out some of the other stuff Lombok can generate (builders, value objects, constructors, etc.)
Re:Java 1.0 Turns 25 by pjmlp on Sunday January 24, 2021 @02:06AM (#25889987)
Lombok generates too much for its own good.
Re:Java 1.0 Turns 25 by diroussel on Saturday January 23, 2021 @04:32PM (#25886320)
There is no magic. You have source code and when you compile you get byte code.

In the early versions of Lombok it was a bit dodgy as it used private APIs, but now the compiler has the public hooks and its all good honest compiler plugins.

Re:Java 1.0 Turns 25 by rufus_foreman on Saturday January 23, 2021 @12:12PM (#25884061)
I'm not a fan but the place where I work now uses it and it doesn't bother me as much as I thought it would. IDEs are smart enough to work with it. Although I still wouldn't use it on a project of my own.
Re:Java 1.0 Turns 25 by u678u on Saturday January 23, 2021 @05:19PM (#25886681)
Agreed Lombok is nice, but why can't they just put that in the runtime? You have to be suspicious of every extra package.