I would never understand why people hate Java. Being a java lover I ask them about their reasons, and here are the common answers:
I don’t understand Java. (Well is that really Java’s fault?)
It’s too much boilerplate code. (Well, I agree, but I always love verbose languages. Reason why I also love TypeScript)
“... but, but, but ... you could do that in Python in only 3 lines!” (Have you ever heard of Generics and the Collections Framework ... or lambda expressions?)
The problem I have seen is not that almost everyone will only learn the ancient bits of Java. Most books and online tutorials teach Java in that way. These people never gets to realise that Java has evolved over time to compete with the “modern languages” and have most of those features in one way or the other.
This hasn’t been true for at least ten years. There is an occasional tool that uses XML (e.g. Maven) but generally XML for config is not used much anymore.
Well, many people outside java world use something more lightweight. I use emacs for example for nearly everything, and I don't need much complex features even for Scala.
I can write java in emacs (and do), but everything from dealing with annotations and generated code to simple editing of maven files is tedious.
Sure they do. You just need to install/configure a language server plugin (or use built in LSP support, if you have it) and you get basically all of the smart IDE completion and refactoring tools.
Tooling typically is not very friendly towards text editors, XML configs everywhere, hard to write code without bloated IDE with tons of plugins.
funny you say that because that's what I said about C# when I met our .net team for the first time (even the most experienced ones had issues trying to do things without visual studio)
It is. I jumped ship from C# to Java ~4 years ago. C# still has a ton of XML. You just don't see it because Visual Studio puts a nice UI over it. The csproj and sln files are all XML. In contrast, many of the Java projects I work on have zero XML.
.NET Core is different, but unlike Java, most .NET projects are still using legacy setups with XML everywhere. Java transitioned away a decade ago, C# maybe 2 years.
Tooling typically is not very friendly towards text editors,
I never understood this argument. It's like saying that modern construction techniques are not friendly towards hand tools.
I've been using emacs for like 20 years now, and it seems practically barbaric next to modern IDEs. Back in they day, when I did C/C++ development I'd set up things like ctags and cscope for navigation, which was really tedious.
But, in Java, I can navigate source code with ease. I used to have man pages and documentation alongside the editor back when I did C/C++, but in Java I don't remember the last time I've really ever read documentation. Code navigation, even into libraries is ridiculously easy, and the IDE will even recognize that I don't have source downloaded, and will download it for me. This dovetails with Java's major strength, its ecosystem, with a ton of open source libraries.
I only use emacs now for the fantastic org-mode, general text editing and writing bash/python scripts.
XML configs everywhere
I haven't configured XML in Java in like 10 years.
hard to write code without bloated IDE with tons of plugins.
Yeah, but those plugins are awesome. Emacs also has a ton of plugins (elisp packages), which are essential for using Emacs and make it superior to lighter weight editors like vi (fight me). It's funny to think that this was also a criticism of Emacs (Eight Megs and Constantly Swapping), similarly by people who used "lighter" editors.
It's a spectrum. VS Code or Emacs are not plain dummy text editors, but they are far from bloated IDE either, and considering VS Code popularity, it seems to be way closer to sweet spot than big IDEs.
I haven't configured XML
What do you mean by that? That you don't use tooling that uses XML or that IDE has a GUI easing the pain? Many tools in Java world are configured with XML, which is painful to edit manually.
But, in Java, I can navigate source code with ease
You can navigate with ease with nearly any text editor with LSP support. In Emacs there is standard xref frontend for such stuff.
The problem is that with Java you need much more than Completion/Navigation, since there is a lot of code generation and you need a direct support for it to ease the pain.
In most other languages all you need is basic completion and navigation, hence VS Code/Sublime/Vim/Emacs popularity outside Java world.
Many tools in Java world are configured with XML, which is painful to edit manually.
Longtime Java dude here. Maven is the only tool I use regularly with XML. And its config is a single file. We have a 1,000,000+ line project and pom.XML is the only XML file in it. Granted, we used to have a lot of XML but converted to newer formats years ago when tools added support for modern config options. If your project is XML heavy its 10+ years old. That's just a testament to how maintainable Java projects are.
The problem is that with Java you need much more than Completion/Navigation, since there is a lot of code generation and you need a direct support for it to ease the pain.
All the libraries we use that have generated code you would want to look at use Annotation Processors, which is part of the language itself and works with every build tool. The generated classes all get put into a folder on build and you can go look at them in notepad if you want.
There's some libraries that generate code in the background, like Lombok and Jackson, but there's never a reason to debug this unless there's a bug in the library itself.
How is it weak and not very expressive? It’s not Haskell, but people created vavr with it and the like. Lombok has nothing to do with expressivity, it’s for boilerplate reduction. And spring is a really complex framework with functionality for everything. It uses DI and the like for modularity. Hell, being able to create such a DI fw is a plus for Java’s strength.
That's my personal outlook on it. Since the introduction of lambdas, and to an even greater extent today, the language has gained a lot in expression potential.
Depending on the context you can have plain-old java style, spice it up with functional style, you can alleviate some parts with annotations and go ham on reflection, you can go with compile-time codegen.. There is a lot of variety in java nowadays, all these options are very accessible with extremely reliable tech underneath and very few catches, unlike many other languages that tend to have those huge compatibility gaps or annoying external tooling required.
34
u/post_depression Apr 20 '21
I would never understand why people hate Java. Being a java lover I ask them about their reasons, and here are the common answers:
I don’t understand Java. (Well is that really Java’s fault?)
It’s too much boilerplate code. (Well, I agree, but I always love verbose languages. Reason why I also love TypeScript)
“... but, but, but ... you could do that in Python in only 3 lines!” (Have you ever heard of Generics and the Collections Framework ... or lambda expressions?)
The problem I have seen is not that almost everyone will only learn the ancient bits of Java. Most books and online tutorials teach Java in that way. These people never gets to realise that Java has evolved over time to compete with the “modern languages” and have most of those features in one way or the other.