5 ms·
Other than Effective Java, I recommend looking at some of the Google libraries, specifically Guava [1] and Guice [2] for dependency injection. Java is fundamen
by lchengify 6y ago
Other than Effective Java, I recommend looking at some of the Google libraries, specifically Guava [1] and Guice [2] for dependency injection.
Java is fundamentally a slow adopter of new techniques (it just got lambdas in JDK 8), but a lot of the Google libraries fill in the gaps.
Note that if you are learning Java for Android development, that's a whole different sub-discipline. In that case I recommend the Android tutorials since most of the work is dealing with the Android SDK.
[1] https://www.tutorialspoint.com/guava/index.htm https://www.tutorialspoint.com/guava/index.htm
[2] https://www.baeldung.com/guice https://www.baeldung.com/guice
- dcminter 6y agoBroadly I agree, but JDK 8 was released in 2014, so while Java is certainly conservative you're overplaying it there. The relatively recent adoption of the 6 monthly release cadence is helping a lot - particularly with the small feature additions that used to get stuck behind the release train.
- rzwitserloot 6y ago> (it just got lambdas in JDK 8) Interesting use of the word 'just'. At the risk of making readers feel old... Java 8 was released _6 and a half years ago_.
- bird_monster 6y agoJava got lambdas in the most recent quarter of its development.
- ThePadawan 6y agoMaybe as a point of comparison (I wondered): C# got them in C# 3.0 in 2007.
- lchengify 6y agoPoint taken. For some reason, a lot of the code work i've encountered is tied to JDK 8. Might be due to it having LTS until 2018 [1]. It could be anecdotal, but I've found in practice vendors and companies are conservative about their JDK upgrades. I haven't seen anything prior to JDK 6 in a while, but I don't think the upgrade cycle is as fast as say, python minor version upgrades. [1] https://en.wikipedia.org/wiki/Java_version_history https://en.wikipedia.org/wiki/Java_version_history
- saagarjha 6y agoYou're making me feel old, and I'm not even old. Or perhaps I should blame codebases that are still trying to be Java SE 1.6 compatible…
- billyjobob 6y agoMany Java shops are only just upgrading to JDK 8 though.
- ako 6y agoJDK 8 was released march 2014, so "just got lambdas" should be read as over 6 years ago...
- tomc1985 6y agoYeah, it is up to JDK 15 now
- vips7L 6y agoI would recommend against guava in any modern form of Java. It doesn't provide much over the standard library. As for guice, my preference for reflective runtime injection is Weld since it's the standard reference implementation.
- bsoft16385 6y agoI would still recommend Guava for immutable collections, and for the caching classes, both of which are much better than trying to piece things together on your own. There are a lot of features that have been subsumed into the JDK, and you should usually prefer the JDK implementation where available. Guava has deprecated the redundant functionality, so if you pay attention to your IDE you will be fine.
- vips7L 6y agoI'm not really obsessed with immutability. Does Collections.unmodifiable{List,Set,Map,Collection} not do it for you? I did forget about the cache's though! Good call.
- hilbertseries 6y agoGuava's immutable collections are superior to Collections.unmodifiable which just wraps the collection in a delegating class that will throw an exception if any of the modifying methods are called. Guava's classes are their own implementations, this is particularly notable for Guava's ImmutableSet which has significantly better memory usage than HashSet. Partially owing to how lazily Java's HashSet is defined, which is a wrapper around Java's HashMap. Meaning that for each element in a HashSet you get an unnecessary Map.Entry wrapper, along with its references. The difference is quite noticeable if you have a set with ~400k Integers. At a certain point, you should also move on to something like Trove, but the guava immutable classes are nice in that you still get the collections interfaces.
- dehrmann 6y agoKnowing what Guava offers is useful, but I try to avoid it, especially in libraries, because it has a history of breaking changes. The Apache Commons libraries are versioned better and a little more focused. Protobuf (another Google Java product) also made big breaking changes in libraries between 2 and 3.