Java libraries you can't miss in 2017
blog.jevsejev.io
blog.jevsejev.io
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.
Speaking of frameworks that Google uses, I'd have to recommend Dagger over Guice: 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.
And as all prior versions of Java are EOL there's no reason not to be using Java 8.
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.
That's not just for just dates or timestamps either. That's for data period.
It makes a whole lot of things that ought to be simple a lot harder.
I wish. When life (or rather a vendor) gives you java 6 libs which barely work on java 7, you make java7 lemonade.
The only thing I can see breaking would be reflection based invocations of new methods on existing interfaces (ex: Foo has a .bar() in Java 7 but not Java 6). You'd have to be doing something pretty unusual for that to bite you.
Oracle middleware libraries (to be fair, mostly acquired)...
I believe the problem was that in Java 8, something related to StringBuilder or string parsing was breaking hard. With Java7 it was ok, so we went with that.
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.
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.
http://omaritech.blogspot.com/2014/03/why-google-guice-is-ev...
Am I in the minority here? Do most people really think that the Guice framework approach is a good idea?
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.
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.
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.
It happens all the time if you test your code with mocks and stubs.
Manually wiring dependencies by calling constructors is still dependency injection. This also has the upside that the compiler will check you have satisfied all dependencies, and you can more easily trace execution.
Frameworks like Guice/Spring are often used to hide lots of wiring boilerplate but come at a price of losing typesafety, adding more magic, and hiding some code smells. If your wiring is getting complex perhaps you need more modularity.
What's more, Dagger gives you (compile-time) insights into the graph of dependencies.
For example, we've hooked up our internal code-search tool to give you Dagger cross-references, so if you (e.g.) click on a parameter to an @Inject constructor, you'll see the place that provides that object.
Also, if you click on the @Component, you'll see a visualization of the entire graph.
We're working on surfacing these hooks in the open source repo, which would allow IDEs like Eclipse to gain this functionality as well.
BillingService billingService = new BillingService(new BillingModule());
...which looks fine with just a couple layers of depth but becomes pathological with hundreds of objects, especially when they have different lifecycles. At some point the extra transparency you get from manual injection is overwhelmed by the sheer quantity of boilerplate.To compensate, DI-less solutions end up with service discovery or "bag" classes like DropWizard's io.dropwizard.setup.Environment. Aside from the loss of encapsulation, what if you want to extend the framework with new components? You end up exposing services by setting attributes with text keys...
Having a messy Guice-based project doesn't mean it would be pretty without Guice.
It seems that vanilla Guice does not need to fire up an annotation scanner that hits every jar, so that's good. It's been years for me, but I seem to recall Spring Framework does a brutal amount of jar crawling/annotation scanning by default. Unfortunately, it's very easy to corrupt Guice with annotation scanning - Netflix Governator will introduce a scanner for its magic annotations, for example.
As far as annotation magic is concerned, I think having an agreed-upon convention for DI can really help to keep things manageable and easy while still being able to unit test/inject mocks. For example, my team tries to only inject on constructor args. This makes it a no-nonsense affair to factor out features for a unit under test by passing in mocks for injected dependencies.
Testing complex systems, for me, is the killer app for DI - if I am writing something I need to test, I abhor the new keyword and FactoryFactories in my production code.
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
Here is an aeron microbenchmark: 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
We will be using it for RPC and distributed deep learning: http://engineering.skymind.io/interview-with-adam-gibson-cre...
CompletableFuture is becoming supported in a bunch of other libraries: https://github.com/AsyncHttpClient/async-http-client/, https://github.com/ben-manes/caffeine , https://github.com/mp911de/lettuce .
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.
As a Scala developer, this is a life saver.
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.
This is actually a negative. Java can be great if you have half-way decent people who make good choices with regards to libraries and frameworks and application servers and whatnot, but the choices that come from "nobody ever gets fired for" thinking are by far the worst ones.
Example: IBM WebSphere. "Nobody ever got fired for choosing IBM," but they absolutely should be if they choose this giant shitpile. Anyone who has chosen this shit should be thrown into a wood chipper, unless they specifically chose it waste the maximum amount of time possible. Or, if it was invented to set Soviet computing back 30 years like the IBM 360, except that joke doesn't work anymore because the Cold War ended before Java was even a thing.
I would add to that open source libraries which are (1) of high quality and (2) easy to pull in, e.g. Maven. The C++ ecosystem has no package manager, and people write header only libraries blowing up compilation times. With Maven, I can add Guava, Ehcahe, AWS SDK, etc. and their transitive department in about 60 seconds in a simple, consistent way.
I think the whole eco-system (including dependency management with maven) is definitely worth acknowledging the value of.
As far as I remember C# came out in 2000.
https://blogs.msdn.microsoft.com/dotnet/2017/02/13/happy-15t...
Fast build times. Removal of problematic/abused features like automatic type conversion and operator overloading. Never having to hunt down a segfault. Good reflection facilities. Well-structured exceptions (despite the 'checked' misfeature). Compiler error messages are almost always intelligible and obvious - when you see them, which is rare, because the IDE just underlines bad code. Add opensource libraries to do almost anything with just a line of xml.
You can work around checked exceptions by not using them, and Lombok eliminates most of the really annoying boilerplate (including checked exceptions with @SneakyThrows). The generics implementation isn't perfect but at least it doesn't require hours of parsing header files on every single build.
I don't miss C++ at all.
https://software.intel.com/en-us/articles/the-ultimate-quest...
I estimate that 70% of those errors just cannot happen in Java.
1 - Language agnostic
2 - Agnostic - Java doesn't have memcmp but the same issue returning (-1, or < 0) could happen
3 - Agnostic (with the exception that java would throw for out of bounds)
4 - Agnostic
5 - Agnostic - Its a windows complication (you can write C++ without DllMain even in windows)
6 - C++
7 - C++
8 - C++
9 - C++
10 - C++
11 - C++
12 - Agnostic
13 - Agnostic
14 - Agnostic
15 - C++
16 - Agnostic
17 - Agnostic (java has similar optimizations)
18 - Agnostic (inefficient code happens in any language)
19 - C++
20 - C++ (maybe java would throw instead?)
... This is longer than I thought.
9 of the first 20 are C++ only.
6. Languages with pointer arithmetic, especially that the cast that losses information is explicit.
8. It not at all obvious that silently ignoring the case failure is correct fix for this, or if there is any issue here at all. Generally common to languages with some kind of destructor and exceptions, though harmful in varying degrees.
11. Other languages generally make it impossible to write, or define order of operations.
I think the most interesting observation you can make is how much of those problems are caused by some form of implicit conversion between types (also stopped after 20):
4. int -> bool
9. char -> *char
13. int -> bool
14. bool -> size_t
15. different enums
16. bool -> int
This generally agrees with bug log that I keep. Implicit conversions being one
of the most common source of problems in C/C++. When possible I just treat all
implicit conversions as errors using compiler flags and make all casts
explicit. Unfortunately this is something you can only do when working on new
projects, and hard to enforce in templates.Other than Android Studio and Gradle, Java build times are actually quite fast. Just yesterday I gave up on compiling Cocos2d-x, after around one hour.
In Java I get to use the full language, not fighting with others about enabling RTTI and exceptions, or making proper use of C++ best practices instead of "C with C++ compiler".
Also unless one is stuck with one OS and one C++ compiler, writing portable C++ code across multiple OSes and compilers is either #ifdefs everywhere or constraining ourselves to the subset of common features.
Right now most commercial compilers for embedded systems are still on C++98.
I recently saw presentations from BMW and Sony, where they mention moving into C++11. Who knows when they will allow C++14 on their codebase, maybe when C++20 gets released, most likely.
If the code needs to be AOT compiled to native code, many third party JDKs do offer support for it, although they are mostly commercial.
Also, the use of header files were already outdated in the 80's, versus what languages like Modula-2 and Object Pascal supported. We will need to wait for C++20 to have proper modules, hopefully.
And best of all, no UB or compiler specific semantics, or change of language semantics between ISO revisions (auto vs decltype).
I still look forward to see value types and the new FFI in Java 10.
When I went back to C++ from Java (for a while), I just pretended it was Java, restricting myself to a rough subset of Java design idioms.
C++ (circa 2000) had too much latitude, too many sharp edges. Java's constrained design vocabulary allows you to focus more on the problem, less on the implementation. I blazed. My code was super maintainable.
I have no idea what C++ is like today.
I eschew meta programming. Huge distraction. Very difficult to grok other people's code. Java's progressive incorporation of declarative, dynamic features is regrettable.
My production code is a mix of Java and Scala, and I found Groovy to hit sweet spot for testing.
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)
}?utm_source=ycombinator
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.
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) so it's easy to learn based on my experience.
Anyone here who also experienced using Vert.x?
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.
From an ease-of-use perspective, the closest I've found for the Java7 hell I currently inhabit is Ninja (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.
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.
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
Keras API for Deeplearning4j (WIP) https://github.com/crockpotveggies/dl4j-examples/tree/keras-...
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.
[1] https://github.com/google/guava/wiki/ListenableFutureExplain...
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 Also clumsy api, but performant for the required workloads.
Most Android applications that rely on both Retrofit and RxJava use them together in this manner.
As for too many requests pending, I'm not sure if OkHttp (which Retrofit uses for making requests and is again on that list) is configurable in that regard. If you want to handle it at the application level, you could maybe model the request queue to the network layer as an Observable<Request> and use RxJava's backpressure operators.
For more information on functional reactive programming (which I would call promises or CompletableFuture done better), see http://reactivex.io/
And for more information on RxJava, see https://github.com/ReactiveX/RxJava
Apache's client doesn't have CompletableFuture, but it was easy to add one: https://gist.github.com/tomfitzhenry/4bb032f6a9f56d95f6fb544...
async-http-client is the HTTP client used by Gatling (same developer, in fact).
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.