Live data from Hacker News

Better Java – Resources for Writing Modern Java

github.com

1–10 of 192 posts

Re: Better Java – Resources for Writing Modern Java

#2
Streams are questionable in performance vs non-stream approaches. I haven't found an article that details performance differences, but I will say that I personally tried doing things using streams and doing the same things using non-streams and have had mixed results, one being faster than the other in some cases.

Re: Better Java – Resources for Writing Modern Java

#3
"If you're using Java 8, you can use the excellent new Optional type. If a value may or may not be present, wrap it in an Optional class like this"

While I agree with most things, overuse of Optional like this is an antipattern IMO. Having done a lot of Java 8 development, I find Optional is best for return types, but otherwise forcing callers to wrap values in Optional is unnecessary as opposed to something like Scala. Those that work on the JDK feel the same [1][2] and I think [2] is even overuse with the prevalence of static analysis tools and @Nullable.

Although a tad dated, I find [3] to be a good guide to modern Java all around.

1 - http://stackoverflow.com/questions/26327957/should-java-8-ge... 2 - http://blog.joda.org/2015/08/java-se-8-optional-pragmatic-ap... 3 - http://blog.paralleluniverse.co/2014/05/01/modern-java/

Re: Better Java – Resources for Writing Modern Java

#6
I'm in agreement with the first few comments already - at least some parts of this advice is dubious.

For one - some performance examples (specifically, integer array iteration) is 15 times slower with streams.

Angelika Langer's analysis:

https://jaxenter.com/java-performance-tutorial-how-fast-are-...

Re: Better Java – Resources for Writing Modern Java

#8
>> Good alternatives to using Spring is Google and Square's Dagger library or Google's Guice. They don't use Spring's XML configuration file format, and instead they put the injection logic in annotations and in code

Spring has had code-based configurations since 2009[1]; seems a little disingenuous to recommend Guice/Dagger due to this non-existent limitation.

[1] http://spring.io/blog/2009/12/22/configuration-simplificatio...

Re: Better Java – Resources for Writing Modern Java

#9
post #6

I'm in agreement with the first few comments already - at least some parts of this advice is dubious. For one - some performance examples (specifically, integer array iteration) is 15 times slower with streams. Angelika Langer's analysis: https://jaxenter.com/java-performance-tutorial-how-fast-are-...

>For one - some performance examples (specifically, integer array iteration) is 15 times slower with streams.

That's a very misleading example, and even the linked post itself explains why it is so (e.g. not much is done with the integers in the first place).

Re: Better Java – Resources for Writing Modern Java

#10
The only way it seems you can be effective with Java is with an IDE to do most of the heavy lifting. What would be better is if Java shipped with more focused command-line tools and better defaults that allow me to productive immediately without the need to learn something as hefty as IntelliJ / Eclipse. This could lessen the barrier of entry to Java and widen community adoption.
Post reply on HN