Hacker News new | ask | show | jobs
by tombert 1 day ago
I've said this before but I'll say it again: The worst part of Java is Java programmers.

For most of my career, I thought I hated Java, primarily because every piece of Java code I had ever worked with was overly verbose across a million different files to do things that would take like ten lines of code in any other language.

Then I actually started looking at all the features for Java 8, 11, 17, and 21, and realized: NO! Java actually gives lots of really great tools and language features that allow you to write relatively pretty, terse, performant code. Record types help cut down on a lot of boilerplate stuff, the streams API allows for pretty work over lists, sealed interfaces mostly solve my itch for ADTs, virtual threads are genuinely pretty impressive bits of engineering, and for the stuff that isn't built in, Vert.x and Disruptor do a pretty good job filling in the gaps.

Once I learned all that, I was kind of mad at people still writing code like it was 1999, but also started to enjoy writing Java. It helps that by this time I was already senior and staff level, meaning I was given much more leeway in how code was written (so the poor junior engineers are stuck/blessed dealing with my code using all the shiny new features).

2 comments

> The worst part of Java is Java programmers.

For companies that deployed Java this is the best part. Growth of Java from 1995-2015 and enterprise IT outsourcing was almost in lockstep. It was not for programmers with taste or interest in coding. It was J2EE 1000 page manual printed and distributed in bulk at IT vendors describing things in hugely verbose details with dummy pet-store project to use all facets of Java/J2EE that ingrained into overall Java culture.

It could be business or politeness reasons that well meaning Java language authors rarely spoke a word against this wider Java culture. So it was just assumed that overtly verbose code and organization of Java projects have official stamp to it.

Yeah, I guess I always just found it miserable to work on.

When I worked at a BigCo [1], our project was a big monorepo in Java which had 60,000 folders, and I don't remember how many files. It was decidedly no fun to work on, because everything was spread across a million files and so doing anything required sifting through dozens or even hundreds of files. I hated it.

I've worked on giant projects since then, but they've been written in more modern Java and they are less painful.

[1] It's not hard to find the specific one through my history but I politely ask you do not post it in reply to this post.

I'd say a lot of verbosity comes from generalization -- when you want the code to be reusable and moddable (pluginable). No wonder two widely moddable games (Minecraft and Kerbal Space Program) are written in Java and C# respectively, makes it very easy to create mods. Once I tried to make a Go project at least build-time moddable and found myself creating a lot of java-esque Factories and Builders.

Whether that generalization is premature -- I don't know, just my observation on why.

I don't agree with that though.

I've written plugin systems for stuff I've worked on, and it didn't require nearly the same level of verbosity. Granted, I usually have done this with sockets instead of directly using JVM and reflection. To each their own, but I like using sockets (usually ZeroMQ) for this stuff because then it's completely language independent.

Even if I granted that you needed to use all this factory and builder glue stuff, I don't agree with the typical Java developer's strategy of breaking things up across a million files, which Java at least greatly encourages.

> No wonder two widely moddable games (Minecraft and Kerbal Space Program) are written in Java and C# respectively, makes it very easy to create mods.

It's more that it's easy to write code that links directly into the game. Easy to do because you can decompile them and make changes easily without having source code. Sure, Minecraft was obfuscated for a long time, but people put a lot of effort into deobfuscation and obfuscation removes a lot less than native compilation.

(You also don't need an official modding API this way)