Hacker News new | ask | show | jobs
by bccdee 34 days ago
> Only reference types, the same as in golang

Everything's a reference in Java except primitives, and even primitives get object wrappers. In Java, String, Long, and Bool can all be null. Go isn't like that—only explicit pointer types and interfaces can be nil. In practice it really cuts down on NPEs.

> https://dev.java/learn/modules/

Ok, granted, but I have never seen these in actual use. Java's ecosystem is big enough that you can use Java for years and not even know it has modules. I find this profusion of features unboring for the same reason that C++ is unboring.

In Go, everything's already in modules. It's just simpler. And when they did add generics, it was backwards-compatible, so there was no Java 8/Java 11 thing.

> Furthermore, any non-trivial project is better served with an IDE

In any other language, I can get by fine with vim + LSP regardless of project size. Java has a uniquely bad LSP story.

1 comments

> Everything's a reference in Java except primitives

Value types will have the ability not to be nullable, which is the same as golang.

Primitive wrappers are used to denote nullability, which golang also has in its sql package for example.

> I can get by fine with vim + LSP regardless of project size

Getting by is one thing, having strong introspection offered by sophisticated IDEs is another.

> Getting by is one thing

Yeah, and it shouldn't be too much to ask for. So it drives me crazy that I can't get by in Java without a full IDE. All I want is "show docs" + "jump to definition" + "show references" + "show implementations". I should not need IntelliJ for this.

> Primitive wrappers are used to denote nullability, which golang also has in its sql package for example.

The nullability wrappers in go's sql package are one of my least favourite parts of the langauge, haha. I really wish Go had proper sum types.

> Value types will have the ability not to be nullable, which is the same as golang.

It's good that Java will eventually add that feature, but I was critical of Go for lacking generics all the way up until they added them. Java's backwards compatibility story isn't as strong as Go's, either. Generics, Go's biggest change ever, were fully non-breaking; meanwhile, some people are still using Java 8.

Go's attitude toward adding features is, "we don't have that & it's fine." If you want to dynamically load code in Java, you have the power to do all kinds of custom class loader magic. If you want to dynamically link code in Go, too bad. Now, I don't love this approach. My favourite language is Rust, which has features out the wazoo. It is beautiful and powerful and complicated. Go is none of those things, but it is austere and minimal and that has its own advantages. Java lacks the advantages of either.

Of course, Java is widely used no matter what I think of it, and it is boring (in the complimentary sense). At the end of the day, it's a fine choice for a project. But as I said earlier, thank god Go is boring enough that I don't have to write Java anymore.