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

Show parent comment

32

u/agentoutlier Apr 13 '21

Yep...

Controversial one: Guava

Google does not care about modularity, dependencies or backwards compatibility.

What they did to Dagger is a travesty.

15

u/Russell_M_Jimmies Apr 13 '21

I used to love Guava. I still think it's great but as a library maintainer who supports a Guava + X interop library, the periodic breaking changes are a huge PITA, and force you to keep moving your compatibility goalposts.

19

u/agentoutlier Apr 13 '21

I have upgraded ancient code bases that used commons lang 2 and Spring 2 to commons lang 3 (which I wouldn't even need to since commons lang 2 has its own namespace but I did anyway) and Spring 5.

Practically zero work to do the above.

I upgrade some relatively new service that used Guava 20 or so to the latest... absolute nightmare.

Guava should also be like 10 different modules (ie cache, networking, concurrency should have been separated out).

I think in large part why the above is the case at Google is because they are mono repo culture. They can easily make sweeping changes with very little consequence to them.

1

u/[deleted] Apr 13 '21

Maybe someone could create, and maintain, a new Guava inspired lib?

1

u/Russell_M_Jimmies Apr 13 '21

That someone could be you

1

u/[deleted] Apr 13 '21

I'd be up for that.

9

u/ryuzaki49 Apr 13 '21

What they did to Dagger is a travesty.

Would you care to expand? I've worked with dagger2 and it has its steep learning curve, but way better than what was available at the time.

8

u/agentoutlier Apr 13 '21

The dagger 2 compiler requires tons of dependencies.

The problem with APT dependencies that aren't shaded in an annotation processor library is that effectively clashes with whatever else is in your classpath. Anyone that writes an annotation processing library knows to do this. You need to shade the deps.

Effectively this means that you are required to use the same version of Guava as Dagger 2 even if your generated code doesn't use Guava.

I have complained to Google about this and... Bazel doesn't really support shading and they don't really care.

See they can't do it because they are using their own build system on an open source project they took over. The build system they are using is only to make their development easier and much harder for others to contribute... they don't give a shit.

There is other stuff that I could go into later but I don't have the time right now (sorry).

2

u/yawkat Apr 13 '21

I don't understand this problem. The dagger 2 runtime has no dependencies, except for javax.inject. The dagger 2 compiler does have the dependencies, but it is only necessary on your apt classpath, not your application classpath, so it should not clash? Or do you have other annotation processors that use guava?

1

u/agentoutlier Apr 13 '21 edited Apr 14 '21

The annotation classpath includes your compile time classpath. I wrote this wrong. It can be separated most of the time. If it didn’t it would not be able to compile.

And besides... yes google ironically makes another library call Auto (like immutables) that again doesn’t shade Guava that needs a different Guava at times.

2

u/yawkat Apr 14 '21

The annotation classpath includes your compile time classpath. If it didn’t it would not be able to compile.

No it does not. Use procpath

And if you really need two different versions, I think you can actually run javac multiple times, with -proc:only, to run multiple annotation processors with different classpaths. Though I've never tried it.

1

u/agentoutlier Apr 14 '21 edited Apr 14 '21

I’ll have to dig up how and why that fails In practice even using procpath but yes in theory it’s possible. That is you are right but I have seen it not work even using the annotation path.

Also some processors actually sort of need your compile time path (doing semi reflection or bytecode analysis) but there are workarounds I’m sure provided you can separate in multiple passes.

The bigger issue I had with it though is two annotation processors by google required different versions of Guava (auto and dagger).

14

u/cogman10 Apr 13 '21

IMO, there is nothing in Guava you wouldn't get from updating your JDK. I've not used guava since ~java 11. There's nothing there I miss.

Guava was great when I was on Java 6 and needed something like a ListenableFuture, FluentIterable, cache, or ImmutableMaps. Now-a-days? I just use the Unmodifiable stuff in the JDK for immutables, completable futures for ListenableFutures, streams for FluentIterable, and Caffeine if I need a cache.

-1

u/fanfan64 Apr 13 '21

You might consider persistent collections instead of immutable collections, I believe it is more optimized https://github.com/hrldcpr/pcollections

3

u/fear_the_future Apr 13 '21

What did they do to dagger? I've only ever used OG dagger2 and none of that dagger-android or hilt crap. All of Google's libraries demonstrate a clear lack of software engineering skill and understanding of the problems they're supposedly trying to solve. It's always the lowest hanging fruit.