r/programming • • Feb 22 '15

Java Makes Programmers Want To Do Absolutely Anything Else With Their Time

http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35 Upvotes

636 comments sorted by

View all comments

Show parent comments

15

u/depressiown Feb 22 '15

This bit of code annoys me for several reasons:

  • Unless you're using something specific to the implementation type, you could use the interface: Map<String,Set> depMap = new HashMap();

  • He's not using the diamond for the generic types: Map<String,Set> depMap = new HashMap<>();

  • He's not typing the Set: Map<String,Set<String>> depMap = HashMap<>();

  • Could use Guava to abstract the inner collection: Multimap<String,String> depMap = HashMultimap.create();

Articles/comments like these constantly annoy me. They're written by people who really aren't that familiar with clean, modern Java. Lambdas, ORM, libraries of annotations... there's so much stuff out there to simply how much Java you write and make it much cleaner than all these examples people use of why Java is bad.

-4

u/[deleted] Feb 22 '15

There needs to be a Poe's Law for Java, because it is impossible for me to tell when people who comment about the 'right way' to express Java aren't just trolling with things like Map<String,Set<String>> depMap = HashMap<>();

Sort of the same way there's very little difference between code in this library: https://github.com/goldmansachs/gs-collections

And this one: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

2

u/[deleted] Feb 22 '15

Remember that this

Map<String, Set<String>> depMap = new HashMap<>();

Replaces this

Map<String, Set<String>> depMap = new HashMap<String, Set<String>>();

So it is obviously perceived as an improvement.

2

u/uprislng Feb 22 '15

looking at that FizzBuzzEnterpriseEdition repo gave me cancer, thanks a lot.

I know plenty of people like it, but I think I'd rather find another profession if I could only ever program in Java for the rest of my life.

1

u/s73v3r Feb 22 '15

Keep in mind that the Enterprise FizzBuzz is a product of a certain environment, which does happen to favor Java (and C#). There are plenty of other environments which do use these languages without needing that huge, over engineered cruft.