
Java libraries you can't miss in 2017 - sergejjevsejev
http://blog.jevsejev.io/2017/02/19/java-libraries-you-cannot-miss-in-2017/?utm_source=ycombinator
======
niftich
The slides which inspired this listing include Guava -- omitted from this list
-- an invaluable utility toolbelt that I think is a spiritual re-imagining of
Apache Commons (... don't read too much into my phrasing, a lot of Apache
Commons also quite good, even if API tastes have changed since then).

I'll also note that Dropwizard, the framework, came about as an quickstart
around an opinionated bundling of quality libraries. Dropwizard's appearance
has resulted [1] in the development of Spring Boot, which lowered the barrier
to generating Spring applications, arguably finally delivering on the
'convention over configuration' promise that Spring has long suggested it
could do, but never quite found the sweet spot.

[1]
[https://news.ycombinator.com/item?id=12283230#12286948](https://news.ycombinator.com/item?id=12283230#12286948)

~~~
CydeWeys
Guava is a notable absence to me. We use it all day every day at work.

Speaking of frameworks that Google uses, I'd have to recommend Dagger over
Guice: [https://google.github.io/dagger/](https://google.github.io/dagger/)
People tend to like it more, and it's gaining traction for the kinds of things
that people used to default to Guice for.

Oh, and the JODA DateTime/Money libraries.

~~~
koolba
There's no need for Joda for datetime with Java 8 as it has sane (immutable!)
classes inspired by Joda.

And as all prior versions of Java are EOL there's no reason not to be using
Java 8.

~~~
CydeWeys
Java 8 isn't supported quite yet on App Engine :-( Support is in beta, and
should hopefully be available "for real" within months, but until it is, we're
stuck with the old stuff.

I also wonder what kind of data migration we'll be facing, since all of our
persisted data is from Joda DateTimes, not Java 8 ones. Hopefully none.

~~~
niftich
If your datetime is persisted ISO 8601 form, RFC 3339 form, some other
unambiguously parseable string form, in epoch form, or as some database-native
reliable datetime type, you'll be fine. But if by any chance it's Java-
serialized Joda-Time objects, you're going to want to get them out of that
form, as the Java-serialized forms are not compatible.

~~~
koolba
If you're data is persisted in Java-serialized form you should be fired.

That's not just for just dates or timestamps either. That's for data period.

~~~
Twirrim
I've horrible memories of WordPress and their obsession with storing PHP
serialised objects in the database.

It makes a whole lot of things that ought to be simple a lot harder.

~~~
h1d
It was saving different blog data on different tables prefixed by index
numbers. It's a mess.

------
abraae
Its so incredibly refreshing when technologies are positioned by saying what
they __don 't __do.

When we describe our cool stuff to the world, its natural to go on and on
about all the cool stuff it can do. But I'm more inclined to trust
technologies that state clearly what they can't or don't do, or are not
intended for.

I don't know if there is a name for this effect, but having only nodded at
SL4J from a distance, I feel much happier about using it (or choosing not to)
after reading this:

> In short, libraries and other embedded components should consider SLF4J for
> their logging needs because libraries cannot afford to impose their choice
> of logging framework on the end-user. On the other hand, it does not
> necessarily make sense for stand-alone applications to use SLF4J. Stand-
> alone applications can invoke the logging framework of their choice
> directly.

~~~
niftich
SLF4J is quality software, but it's quite ironic that it needs to exist at
all, considering how much of both the Java mentality and the commercially
significant Java EE platform is about coding against a well-defined interface
that defines basic contract and semantics and allows the
developer/customer/etc to supply their favorite and most-appropriate
implementation of choice.

In the case of SLF4J, it was the community (or rather, Ceki Gülcü, the author
of now-several logging frameworks, in response to his dissatisfaction with the
community-led Apache Commons Logging) who stepped in to provide the 'generic'
API, while Sun went and developed an actual 'hardcoded' implementation
deliberately different from the popular third-party logging frameworks of the
time instead and shipped it with Java 1.4.

------
whack
As someone who has to use Guice at work, and not by choice, the following
critique best sums up my thoughts on Guice.

[http://omaritech.blogspot.com/2014/03/why-google-guice-is-
ev...](http://omaritech.blogspot.com/2014/03/why-google-guice-is-evil.html)

Am I in the minority here? Do most people really think that the Guice
framework approach is a good idea?

~~~
niftich
The linked post is framed as a criticism of Guice but it's actually a
criticism of Dependency Injection.

DI is one of those architectural tradeoffs that makes one thing easier
(swapping out an alternate implementation) while making another thing harder
(following execution paths), and trades imperative, prescriptive, top-down
style with declarative, "loosely coupled", componentized, bottom-up style made
possible by an overarching helper and externalized decision points that kinda-
sorta act like configuration.

~~~
umanwizard
In my experience "swapping out an alternate implementation" happens so rarely
that it isn't really worth the additional architectural complexity and making
debugging harder.

Seems to me like DI (at least the heavy-handed Spring XML style of it) is a
solution looking for a problem, but I've only worked at one company that used
it heavily so I'd be happy for people to try to change my view.

~~~
niftich
"Swapping out an alternate implementation" sometimes means you shipped a bunch
of components and the customer (who is not you, and doesn't necessarily have a
direct line to you) can configure their software to enable or disable
features.

By having externalized some of the tight coupling into some config file (like
Spring's XMLs), they can go in and say that the AuthorizationFilter is
OAuth20Filter instead of OAuth10Filter, or maybe their CookieParser is
StrictRFCCompiantCookieParser instead of the WhateverGoesCookieParser.

The same would be doable if you compiled all this into code and only exposed
some different config parameter that says "enforceRFC6265Cookies=true/false",
but then the customer couldn't use some consultant company's
SuperSpecialCustomCookieParser class in its stead, whereas with Spring they
can.

But say none of this applies; DI is often used in testing. You can inject a
mock class with next-to-no effort without having to figure out what to do
about all of those StorageManagers whose hardcoded dependency is your
ActuallyRealDatabaseStorageManagerImpl.

------
zokat
Worth checking out are Java libraries made by Real Logic guys:

[https://github.com/real-logic](https://github.com/real-logic)

Aeron - Efficient reliable UDP unicast, UDP multicast, and IPC message
transport

Simple Binary Encoding (SBE) - High Performance Message Codec

Agrona - High Performance data structures and utility methods for Java

~~~
agibsonccc
We use all 3 for network communications.

Here is an aeron microbenchmark: [https://github.com/benalexau/rpc-
bench](https://github.com/benalexau/rpc-bench)

Of note is akka uses it for its internal remoting:
[http://blog.akka.io/artery/2016/12/05/aeron-in-
artery](http://blog.akka.io/artery/2016/12/05/aeron-in-artery)

We will be using it for RPC and distributed deep learning:
[http://engineering.skymind.io/interview-with-adam-gibson-
cre...](http://engineering.skymind.io/interview-with-adam-gibson-creator-of-
dl4j-why-aeron-matters)

------
tomfitz
JDeferred, a promises library, is what CompletableFuture does, a recent
addition to Java's standard library in Java 8.

CompletableFuture is becoming supported in a bunch of other libraries:
[https://github.com/AsyncHttpClient/async-http-
client/](https://github.com/AsyncHttpClient/async-http-client/),
[https://github.com/ben-manes/caffeine](https://github.com/ben-manes/caffeine)
, [https://github.com/mp911de/lettuce](https://github.com/mp911de/lettuce) .

------
dlandis
To me Guava is still the most essential, general purpose Java library. Not
just for its collection package but because of the caching stuff, graph API,
and well written general purpose utilities.

But I would also mention Spring 5 which I assume will be released soon, even
though many people probably consider it too heavy or opaque at this point. But
their major adoption and push towards reactive programming is interesting. And
it will be interesting to see if java programmers embrace it. I'm a little
skeptical that it provides enough tangible value to justify a more complex
mental model, but maybe I'm wrong.

~~~
CydeWeys
I just recently had to use a bloom filter to speed up a caching issue. It was
so easy to do with Guava that it took all the fun out of it.

------
amenghra
Jooq is a really good type-safe library to talk to databases. I personally
prefer jooq over hibernate.

~~~
ar0b
The Jooq blog is pretty great as well.
[https://blog.jooq.org/](https://blog.jooq.org/)

------
hermitdev
Not trying to be an asshole here, but can a Java evangelist try to convince me
to use it over C++ on linux - without invoking the garbage collector. (I've
+17 years experience in C++ & Python on Linux & Windows + 18 years C#
experience on Windows). In my experience, Java has made a number of poor
decisions in the language (i.e. requiring exception specifications,
disallowing value types, and the generics implementation is shit). Why use it
other than "cross platform?" Build times are crap, almost (but not quite) as
bad as C++. Why use it? I'll admit I've zero experience using other JVM hosted
languages, so part of why I differentiate the JVM versus Java, the language.

~~~
SakiWatanabe
Java is very good for enterprise development where the code has to be
maintained. It's easier to read and contains less gotchas than C++. It is
especially good when the team consists of people of varying coding
competencies. Also nobody ever gets fired for choosing to develop using Java.

~~~
hermitdev
> Java is very good for enterprise development where the code has to be
> maintained. I often hear this, but I've yet to see an example of "good"
> enterprise java. Instead, I oft see a pile of shit built on top of some java
> framework, claiming to be maintainable. C++ may not be the best choice for
> web development (probably wouldn't be my first choice), but Java hasn't
> proven great, either.

~~~
thehardsphere
> C++ may not be the best choice for web development (probably wouldn't be my
> first choice), but Java hasn't proven great, either.

Really? I feel like Java and the JVM are great for developing web apps with
complex requirements, especially if they need to scale. Very few decent web
development choices perform as well as the JVM does.

I mean, part of the reason that "enterprises" have "shitty enterprise Java" is
because "enterprises" will create "shitty enterprise anything," and the Java
implementation often performs better than the alternatives.

------
wiradikusuma
If possible, write tests in Groovy and use Spock Framework.

My production code is a mix of Java and Scala, and I found Groovy to hit sweet
spot for testing.

~~~
vorg
Using the collections syntax and closures from Apache Groovy makes glue code,
testing, and build scripts for the JVM easy to write, but the more recent
features like those used in Spock are confusing. The Spock example in the post
has the | operator overloaded so a function is called, a function name made up
of 6 words separated by spaces (rather than using camelCase), and the label
syntax triggering AST transformations to provide a new semantic context...

    
    
      class HelloSpockSpec extends spock.lang.Specification {
        def "length of Spock's and his friends' names"() {
          expect:
          name.size() == length
    
          where:
          name     | length
          "Spock"  | 5
          "Kirk"   | 4
          "Scotty" | 6
        }
      }
    

Wouldn't this be more straightforward and readable, without needing to rely on
any of the confusing post-Strachan features added to Apache Groovy?...

    
    
      def HelloSpockSpec () { //length of Spock's and his friends' names
        def f = {name, length -> name.size() == length}
        assert f("Spock",  5)
        assert f("Kirk",   4)
        assert f("Scotty", 6)
      }

------
jontro
Should analytics tagging really be used when submitting urls to hn?

?utm_source=ycombinator

~~~
niftich
I have no problem with this. At least this style of analytics makes it clear
to both the reader of the URL and a casual observer that their visit is going
to be catalogued as such, and for a careful clicker, easy to bypass.

I find this much more palatable than, say, Medium's pseudorandom tracking hash
fragments that are spawned on each link share (harder to grok and recognize,
but easy to bypass), or indecipherable URLs where it's impossible to tell
where the substantive, deterministic portion ends and the tracking garbage
begins.

------
donretag
I have been using Google's AutoValue [1] instead of Project Lombok. It does
not have as many features, but it makes creating model classes much easier.

[1]
[https://github.com/google/auto/tree/master/value](https://github.com/google/auto/tree/master/value)

------
mjohnre
Have you considered Vert.x?

[http://vertx.io/](http://vertx.io/)

Vert.x lets you do most of those stuff such as HTTP, futures, P2P, pub-sub and
more. It's event-driven and made for concurrency but you can easily run
blocking code in it if you want to. I think you can integrate it with existing
projects to get those capabilities. It also has tools for testing. It's well
documented and with great examples ([https://github.com/vert-x3/vertx-
examples](https://github.com/vert-x3/vertx-examples)) so it's easy to learn
based on my experience.

Anyone here who also experienced using Vert.x?

~~~
niftich
In casual parlance of terminology, Vert.x isn't really a library in the sense
a dependency you pull in because it implements some specific functionality
with a handful of method calls.

Vert.x "feels" more like a framework in the sense of giving your thought
process and your application an architectural template and invites you to code
in a style that it supports; but I also don't think 'framework' is a bad word.
Realistically, Vert.x blurs the lines between a runtime, an event bus, a
library, a framework, and a platform -- it's quite enjoyable to use, but
despite their insistence to the contrary I don't think it's something that one
should grab off the shelf and sprinkle into a larger product.

~~~
mjohnre
That's a better explanation clarifying its distinction between being a
framework and library. Yeah, substantial amount of consideration should be
taken before including it in a project. It's good though to have an option
when you need it.

------
blawson
Spark framework is pretty awesome, in a "all I know is Java but want to write
a web application simply anyway" kind of way.

[http://sparkjava.com](http://sparkjava.com)

~~~
toyg
I've recently had to reacquaint with Java after 15 years, and Spark was a
godsend. It's basically Flask for Java.

From an ease-of-use perspective, the closest I've found for the Java7 hell I
currently inhabit is Ninja
([http://www.ninjaframework.org](http://www.ninjaframework.org)), but it packs
a lot of stuff that I don't necessarily need - it's more of a Django, let's
say.

------
gravypod
Lombok is something I've been working with for a long time and I can say it's
the only library I enjoy pulling in because of just how much it has to offer.
Everything and two kitchen sinks.

------
vonnik
Don't forget Deeplearning4j!
[https://deeplearning4j.org/](https://deeplearning4j.org/)

~~~
mindcrime
I've been doing a lot of stuff with DL4J lately and I have to say, I'm pretty
impressed. The API seems very sane, it's very flexible, but yet it's easy to
get a basic network up and running. The documentation is pretty good and there
are a lot of videos from Adam up on Youtube showing off aspects of it. And it
has native support for running on Spark with iterative parameter averaging,
etc.

I honestly wonder why DL4J doesn't get more love... I'm guessing it's just the
halo effect of being associated with "Java" which is no longer cool with the
hipster crowd.

~~~
vonnik
Thanks for the kind words. Please let us know if there's anything we can
improve. The community's active here:

[https://gitter.im/deeplearning4j/deeplearning4j](https://gitter.im/deeplearning4j/deeplearning4j)

Why doesn't DL4J get more love? It's partially a Java/Python thing. A lot of
research, maybe most, is being done in Python, even if that isn't ideal when
you scale on a cluster. So we built a couple ways to smooth the workflow
between Python and the JVM:

Model Import from Keras (and TensorFlow and Theano)
[https://deeplearning4j.org/model-import-
keras](https://deeplearning4j.org/model-import-keras)

Keras API for Deeplearning4j (WIP)
[https://github.com/crockpotveggies/dl4j-examples/tree/keras-...](https://github.com/crockpotveggies/dl4j-examples/tree/keras-
examples/dl4j-keras-examples)

DL4J is the only DL library built by a startup without the backing of a major
tech company or university. Google's pouring many millions of dollars into
TensorFlow marketing, Udacity, etc. Microsoft and Amazon are backing CNTK and
MxNet respectively. All those libs are loss leaders to get companies onto a
vendor's public cloud, where they'll charge for the DL workloads.

------
chillaxtian
if you need to do high performance networking, netty is a must have.

[http://netty.io/](http://netty.io/)

------
JensRantil
Guava's `ListenableFuture` can be used as an alternative to `JDeferred`. See
[1].

[1]
[https://github.com/google/guava/wiki/ListenableFutureExplain...](https://github.com/google/guava/wiki/ListenableFutureExplained)

------
rajdinx20
AssertJ ([http://joel-costigliola.github.io/assertj/](http://joel-
costigliola.github.io/assertj/)) deserves a mention. Great support for
collections, guava, jodatime and IDE autocomplete friendly to boot

------
JensRantil
Guava's `EventBus` can be used as an alternative to `MBassador`. See [1].

[1]
[https://github.com/google/guava/wiki/EventBusExplained](https://github.com/google/guava/wiki/EventBusExplained)

------
LeanderK
does anybody know some http client libraries that have scalable, performant
asynchronous support (including transparent handling of various issues, like
too many requests pending etc.). A big plus would be if it would implement the
CompletableFuture-interface (idk what it was called). Ideally with an easy,
fluent api. I started with using unirest
([http://unirest.io/java.html](http://unirest.io/java.html)), but it behaved
poorly under load (also no CompletableFuture-interface implementation).

~~~
charleslmunger
What's the interest in CompleteableFuture? It's probably my least favorite JDK
addition...

~~~
LeanderK
yeah, i feel like they messed up the api.

easy integration into ratpack[1] non-blocking system. Propagation of the
async-functionality through various classes without hardcoding an custom
library-solution.

[1] [https://ratpack.io](https://ratpack.io) Also clumsy api, but performant
for the required workloads.

~~~
charleslmunger
My biggest gripe isn't the massive API, it's the existence of the obtrude*
methods - allowing a Future to change its completion result after it completes
undermines the whole thing.

------
TheHiddenSun
Or just use Scala. Scala is like Java 13 in a consistent / elegant manner with
functionality / features of half of the libraries listened.

------
dajohnson89
Nice list. It would be super cool and useful to see less trivial examples of
each library. Or at least links to examples in GitHub.

------
leastangle
Great list, but I am surprised that guice is a recommendation for DI in 2017.

~~~
stickfigure
The only really comparable replacement is Dagger, which does not provide AOP
or any kind of web integration.

Dagger is cool, but Guice is still a better choice for most server-side apps.
Maybe that will change in the future? They're pretty similar, so if Dagger
"catches up" it won't be too hard to switch.

------
zhuzhu
I only need Java 9

------
lewich
are you kidding me? this is worst java library list for 2017

~~~
jpitz
Can you defend that, or are you trolling?

