Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

191–200 of 777 posts

Re: Java 21 makes me like Java again

#191

The problems with Java can't be fixed by adding new things, you can't undo decades of ecosystem development, training, and ideology built on top of the idea that inheritance is really good idea and belongs everywhere. edit: I will say that as a Java developer I am grateful every day for the improvements to the language. Java is a very impressive language and I have a lot of respect for the people working on it.

I rarely see inheritance used in practice in java code bases. Except where I would use a union type or sealed class in other languages anyways. I don't feel what youre describing is a real issue.

HtmlElement. AST. Socket. Stream. Window. Closable. Runnable.

Re: Java 21 makes me like Java again

#192

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.

`Executor.newVirtualThreadPerTaskExecutor` versus `go` really gets to the heart of why I think that Go developers aren't going to be switching. edit: Sorry, it's actually: try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { executor.submit(...) ) instead of `go`

Starting a virtual thread in Java isn't that clumsy:

   Thread.ofVirtual().start(() -> System.out.println("Hello"))

Re: Java 21 makes me like Java again

#193
post #189

Earlier quoted context omitted.

AWS Lambda is the once place where you should never use Java. You have specific thresholds for how fast your function responds, jvm prevents that and requires more memory. AWS Lambda’s documentation shows how to accept a Request and send a response. You don’t need a package for that. For making zips from s3, again, AWS’s sdk. It’s one of the most commonly asked questions on SO. Here’s one implementation for you that…

A minimal Java app can easily start up in 0.1 seconds, which might just as well be good enough, but if not, there is also GraalVM that can output a native binary.

I’ll just leave this with you. 0.1 difference may not seem like a lot until you start hitting 100M invocations.

https://mikhail.io/serverless/coldstarts/aws/languages/

Re: Java 21 makes me like Java again

#194
post #190

Earlier quoted context omitted.

> they use a so-called thread-local allocation buffer, which can be used to allocate new objects in, without expensive synchronization, and the GC can quickly scan it, moving still alive objects out of it yeah, all these logics still have significant overhead, especially memory wise, it is hard to reason when JVM decides to kick that or another optimization or not kick anything at all. With value objects you have ful…

> you have full control and bare-metal-native performance without compromises. Not even you believe that, right? Especially with regards to Go.. Go is closer to JS than to Rust/C++.

as soon as you copy your struct by value around, it is easy task for escape analysis to decide to put struct on stack.

also, golang has arena API now, and it also makes heap allocations super cheap if you manage to integrate it into app life cycle.

Re: Java 21 makes me like Java again

#195

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.

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 mostly because applications and libraries are so hard to reason about and understand due to inheritance, packaging, OOP, build tools ect compared to Go.

You are just at the early phase of the project.

> Go is simple. It's easy to understand, read, and maintain

My opinion is that Go is too simple, to the point that it hinders understanding and readability. 4 nested loops with random mutability is much worse than a clear Stream api "pipeline". The 31st if err check will not be actually handling the underlying problem, while you can't forget about Exceptions -- even if they do bubble up to the main app, you will clearly get an actionable stacktrace.

> The tooling is built into the language

This has benefits, I will give you that. At the same time, I think all these new build tools are anemic and can't be used for anything more complex than interacting with the same language's standard dependencies. Gradle is not sexy, but is actually capable of doing any kind of build.

Re: Java 21 makes me like Java again

#196

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.

`Executor.newVirtualThreadPerTaskExecutor` versus `go` really gets to the heart of why I think that Go developers aren't going to be switching. edit: Sorry, it's actually: try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { executor.submit(...) ) instead of `go`

The go example is missing the channels, select, wait group, context, cancellation

Doesn’t sound like a fair comparison thou the Java version is missing things

Re: Java 21 makes me like Java again

#197

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.

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…

Exception handling and generics are missing key pieces from go. But adding them will make go look like java.

I just wish java would add null safety in the type system in a first citizen way.

For enterprise use java has no competitors. You have c# which is microsoft trying to estabilish nash equilibrium fu*ing the developers. I am a bit worried about ever increasing complexity and a steep learning curve, but seems like this is a problem on all fronts.

Re: Java 21 makes me like Java again

#198
post #163

Earlier quoted context omitted.

and during last 20 years consensus has converged to the view point that generics are essential.

Huh. Guess I'm heterodox, then. I mean, don't get me wrong. It's quite useful once in a while, especially when working with containers, but I don't think of it as essential. But I'm fine with it as long as people don't overdo it.

Rolling your own containers really really sucks. Sucks enough to the point that it is essential, in my books.

Re: Java 21 makes me like Java again

#199
post #197

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…

Exception handling and generics are missing key pieces from go. But adding them will make go look like java. I just wish java would add null safety in the type system in a first citizen way. For enterprise use java has no competitors. You have c# which is microsoft trying to estabilish nash equilibrium fu*ing the developers. I am a bit worried about ever increasing complexity and a steep learning curve, but seems lik…

> I just wish java would add null safety in the type system in a first citizen way

With valhalla (value types), it might just come!

Re: Java 21 makes me like Java again

#200
post #61

[flagged]

As someone writing code on Java since v1.0 and making tech strategy decisions on the C-level, I consider myself sane and experienced enough to say that Java is something that will do the job well and can be the primary choice for startups and new projects. Kotlin as a platform is not mature enough to deserve the same qualification.

I'm sure you have done great work in Java, as have many of us, and for many of those years, Java really was the best tool for many jobs. But that was then, now is now.

I'm not saying Java doesn't work, even for greenfield projects today. It works fine. But me and many others also think it's not enough for something to merely work, especially not when there are other much better and more modern tools. (which Java is demonstrably playing catch-up with)

You and every other C or higher level exec need to get a grip, get with the times and realize that continuing to insist on Java is only going to make (or, by now, keep, more like) your organization stale and attract more and more mediocre engineers for every year that passes. I know because I've worked with the kind of engineers who are still doing Java + Spring like it's still the 90s, and they're not the ones you want on your projects. The best talent don't even want to consider working with Java if they can help it.

Post reply on HN