Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

721–730 of 777 posts

Re: Java 21 makes me like Java again

#721

Earlier quoted context omitted.

The ergonomics of checked exceptions may be debatable but compared to golangs explicit error handling at essentially each function call is definitely worse.

Yeah, I've got a lot of Java experience and a wee bit of Go language experience and I agree with you. I like Go in almost every way except for it's error handling. It's just wrong to have to check every goddam function one by one

I guess that's the reason why most Java programs I use cannot do proper user-facing error messages. Because it is so easy to just ignore error handling. The exception will be caught by the top-level, right? This is how almost every Java cli tool prints a stacktrace on even most trivial user errors like file not found.

Having to deal with errors and forcing the developer to do proper error handling is a good thing.

Re: Java 21 makes me like Java again

#722
post #553

Earlier quoted context omitted.

> JVM (especially paired with Kotlin) I agree the Go lang compiler/runtime needs "a Kotlin", with more null-safey build in, proper sum types, a std lib that makes heavy use of null-safety and sum types, better story for polymorphism, better ergonomics for writing stream pipelines, and additional compilation targets (like JS, WASM). This all while proving stellar interop with all Go code, obviously. Kotlin is quite a…

Curious to understand what you are suggesting here. What’s a better story for polymorphism than duck typing? What would (better?) null-safety look like in Go?

I'm saying that we need an XYZ to Go what Kotlin is to Java. The I name some ways that Kotlin improved upon Java that Go would also benefit from.

> What’s a better story for polymorphism than duck typing?

Something that give compiletime guarantees and has not runtime overhead.

> What would (better?) null-safety look like in Go?

https://kotlinlang.org/docs/java-to-kotlin-nullability-guide...

Re: Java 21 makes me like Java again

#723

Earlier quoted context omitted.

That was true in 2005. Modern Java UI can look pretty great. Two examples: 1. Start IntelliJ and check it out. It's Swing but it feels modern and fresh. 2. Go to https://www.jfx-central.com/ ... JavaFX was introduced years ago to add far better support for modern visuals. JFX Central is a website written with JavaFX itself - it runs server side and streams drawing instructions to the client (implemented using a mix o…

how is jfx-central different from https://openjfx.io ?

Different websites run by different people, I think. The former is more of a news site.

But yeah, arguably they should be unified.

Re: Java 21 makes me like Java again

#724

Earlier quoted context omitted.

Java is an inferior language to C#. To get a superior language you would likely have to go for Kotlin. There is no comparison, because Java gets features today that C# had for years. Not even mentioning having to retrofit green threads because adopting async/await (used by TS, Rust, Swift and other languages) is impossible at this point.

C# is a better language, but the JVM is a significantly better ecosystem. Java will always be behind (and type erasure for generics is annoying enough as someone who started in C# that I don't think it will ever catch up) but between hotspot and being the preferred language of 2/3rds of the clouds I think it clearly wins.

   type erasure for generics is annoying
I too have spent significant time programming in both C# and Java. This complaint about type erasure in Java: When does it affect your daily life? There are so many craft workarounds available now that it hardly comes up anymore.

Also, would your opinion of Java significantly change if type erasure was removed or never existed?

Re: Java 21 makes me like Java again

#725
post #246

Earlier quoted context omitted.

Kubernetes is what I would call very advanced use case. But that's the thing with Java, yes there are libraries for everything and one could see that as a problem actually. Spring was mentioned before, but it's the perfect example of an overengineered/ heavy library that does a lot of black magic.

Java is strange because it can be both verbose and magical at the same time. Just the other day I ran across an issue where spring was wiring things up correctly on Linux but not Windows.

I too dislike dependency injection frameworks. I try to always wire manually myself. I'm tired of debugging old SpringFramework apps where changing the JVM by a patch level or changing one JAR dependency breaks the wiring. I have seen it too many times to count.

Re: Java 21 makes me like Java again

#726

Earlier quoted context omitted.

If all you have is spring boot, everything looks like a spring boot problem.

Plus Spring is honestly quite badly programmed. The pagination object is bulky and unnecessarily complex, where a simple offset/limit is enough (and a nextUrl for cursor-based access). When we looked into cluster locks, they’re not even released if one node goes down. I mean, who would need a lock implementation that just stores a line in a DB? And the doc doesn’t even warn about it. Apache contributors were much bet…

    Apache contributors were much better-skilled.
That is quite a broad statement. Two negative points about Apache Java libraries I can think of: The original "lang" libraries have not aged well at all. Also: The HTTP client libs are a fiasco. Very challenging APIs and weak documentation.

Re: Java 21 makes me like Java again

#727

Earlier quoted context omitted.

I don't think any existing Go developer is going back to Java. I worked with Java for 10 years and switched to Go and I will never go back. This is mostly because applications and libraries are so hard to reason about and understand due to inheritance, packaging, OOP, build tools ect compared to Go. Go is simple. It's easy to understand, read, and maintain. The packaging is like how you would package files on your co…

This is correct. It is about culture too. Java is the kind of language that attracts some mediocre programmers who produce mediocre code based on the wrong ideas of object oriented programming. of course, there are great Java programmers. It is just that a better programming language would help average programmers like us to achieve more

This generalisation is easy to explain. On the server-side, Java "won" the enterprise battle. In the last 20 years, big corporates re-wrote their server-side C/C++ stack in pure Java (and thick desktop clients in C#). It is so much easier to maintain than C/C++. As a result, they can hire mediocre Java developers to maintain their "new" legacy services.

    who produce mediocre code based on the wrong ideas of object oriented programming
This overlooks this history of OOP. Each decade, lots of new ideas have emerged so that skilled programmers continue to use the same languages (Java, C#, C++, C), but change how they use them. C++ in 1996? Let's fight about diamond inheritance! C++ in 2006? C++ in 2016? C++ in 2026? Repeat for all four languages that I mentioned. The story will look similar. Anyone good writing new code in these four languages isn't using many levels of inheritance. It is gone. Sure, it exists in the language for historical reasons, but it is hardly used in new code. "Prefer composition over inheritance."

Re: Java 21 makes me like Java again

#728

The biggest feature in Java 21 is the release of Virtual Threads: https://openjdk.org/jeps/444 For some reason, this is missing from the article. If there was any feature that would sway existing Golang developers to switch to Java, it would be this. It would perhaps also convince the haters of the reactive-style concurrency patterns.

> If there was any feature that would sway existing Golang developers to switch to Java, it would be this. Not sure about this, but a trajectory question: why does the Go community have so few concurrent containers but Java community does? I mean, even `sync.Map` is specialized for two specific use cases instead of like Java's ConcurrentMap that is of general purpose. And In Java there are concurrent sets, queues, ba…

What concurrent data structures that Google Guava offer than the standard library does not?

Re: Java 21 makes me like Java again

#729
post #329

Earlier quoted context omitted.

Go almost instant build time is a huge productivity boost when compared to Java. You get both the solidity of a typed language, and the development speed of interpreted languages (py, js).

Java's build times are very fast. Java's build tools are anything but. And I'm surprised no one is doing anything about it.

If you avoid pre-Java 11 modules in Apache Maven, it is very fast to build. Plus, IntelliJ is auto-magically incremental build. Can you give some specific examples where Java build tools are slow? Most Java developers spend their whole day in an IDE that is doing incremental build, jumping in and out of a debugger to fix bugs or broken unit tests.

Re: Java 21 makes me like Java again

#730
post #616

Earlier quoted context omitted.

Gradle is steaming pile of garbage. But since the zoomers are allergic to XML, Maven (actually fast) is slowly dying.

Gradle is much faster than maven as it can properly parallelize the workloads. Sure, it won’t be visible on a hello world, though.

There seems to be some disagreement to your statement. Can you provide some concrete examples?
Post reply on HN