What are the big improvements between guava and apache equivalent libraries?

后端 未结 3 1644
栀梦
栀梦 2020-12-07 06:54

We currently use apache collections, string utils, etc. I need to decide if we should switch from the apache foundations implementation.

The important criteria is ea

3条回答
  •  囚心锁ツ
    2020-12-07 07:11

    I've been using guava since Aug 2010, starting with the r06 release. Basically, I had a greenfield java library to develop, so I looked around for the best adjunct library for the J2SE API. Traditionally, we'd used the Apache Commons libraries, but I wanted to see what was out there and began using Guava.

    Pros

    1. Java 5.0 language constructs. The library takes most of its design cues from Bloch's "Effective Java: 2nd Edition": Immutability, builder pattern, factories instead of constructors, Generics, etc. This makes your code tighter and more expressive.
    2. Functional programming support, in particular with the top-level Function and Predicate interfaces.

    Cons

    1. It's not a sufficient replacement for Apache Commons, in particular commons-codec.
    2. There's not a 'guava cookbook'. The library is both minimalistic and orthogonal. Thus, there's a definite learning curve to take full advantage of it. As mentioned, the Javadoc is excellent, but some longer source code case studies would be helpful.
    3. If you're in an environment requiring Java 1.3 or 1.4, you're out of luck.

    To me, Guava makes Java feel closer to a terse, expressive scripting language, and that's great.

提交回复
热议问题