Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

361–370 of 777 posts

Re: Java 21 makes me like Java again

#362

Earlier quoted context omitted.

C# does not have virtual threads. What C# has is async/await. Which was nice for its time, but at the same time it's an error prone design, as computations should never start async by accident, blocking should be the default. C# also has no useful interruption model. Java's interruption model is error prone, but at least you can work with it. Async/await also splits the standard library and the ecosystem in 2 (blocki…

Do give async/await in C# a try, it has all the structured concurrency features other languages have to invent APIs and special syntax for :) (if you want to take a look at good structured concurrency, you might be interested in Swift implementation)

I worked with C# professionally.

The async/await syntax works with the language's other statements, but for a long time it had gotchas. It doesn't qualify as "structured concurrency", and it has the aforementioned issues — it's (accidentally) error-prone, it splits the ecosystem in two, and has no interruption model.

I am not familiar with Swift, but I think you can hardly beat Kotlin's implementation. This is a good introduction from Kotlin's lead:

https://www.youtube.com/watch?v=Mj5P47F6nJg

Re: Java 21 makes me like Java again

#363

Earlier quoted context omitted.

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.

The job of software engineers is to translate a business domain into software. Different languages are better or worse at modeling different domains of problems. I have seen the same problem solved in different languages take 2-3x the amount of work and have a large difference in ongoing maintenance costs. Java's reliance on traditional OO means that only a small subset of business domains naturally map to the langua…

> Java's reliance on traditional OO means that only a small subset of business domains naturally map to the language's constructs.

In my career I worked on a really wide range of business domains and have not even noticed the problems you are talking about.

The problem of mapping certain types like unsigned int that you mentioned is rather rare integration scenario. There’s not that many domains where numbers with the most significant bit are important, but MAX+1 size numbers are not.

Re: Java 21 makes me like Java again

#364
post #277
post #3

In other news, we have an upgrade path at work to go from Java 8 to Java 11 pretty soon.

What were the backward incompatibilities preventing that move? I thought Java was pretty backward compatible, but I've heard this a lot.

Java has in recent times actually removed some apis from the standard library, and made some inaccessible (undocumented internal apis especially) so any advanced frameworks that use them would have been affected.

Re: Java 21 makes me like Java again

#365
post #148
post #121

Earlier quoted context omitted.

I have not used Go generics, but it's viability as a business logic language would depend on that.

Wait, what? Generic programming is a perfectly valid style, but are you saying it's essential to implement business logic? Because, like, the last 3 languages that got adopted as the default business logic language didn't have them (Java pre 1.5, C, and Cobol).

It is not essential, but without it, it is much more cumbersome. I programmed it with Java so I know it can be done but I would not choose a language without it if I could.

Re: Java 21 makes me like Java again

#366

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.

> The biggest feature in Java 21 is the release of Virtual Threads

Is there a good honest writeup on why is this interesting? Very curious.

The earliest JVMs had this, green threads. Performance was terrible so it was eventually dropped.

I want to fully utilize every CPU and every core I have, why do I want green/virtual threads again?

Re: Java 21 makes me like Java again

#367

Can you convince me to use Java? I’ve never used it (only C++, Python, CL) but it feels bloated and dirty.

Id rather say use kotlin. It comes with a better type system with explicit nullable types, proper closures, and syntactic sugar to easily enavle beneficial programming patterns.

Nd it is very compatible with Java itself, interop is dead simple

Re: Java 21 makes me like Java again

#368

Earlier quoted context omitted.

Do give async/await in C# a try, it has all the structured concurrency features other languages have to invent APIs and special syntax for :) (if you want to take a look at good structured concurrency, you might be interested in Swift implementation)

I worked with C# professionally. The async/await syntax works with the language's other statements, but for a long time it had gotchas. It doesn't qualify as "structured concurrency", and it has the aforementioned issues — it's (accidentally) error-prone, it splits the ecosystem in two, and has no interruption model. I am not familiar with Swift, but I think you can hardly beat Kotlin's implementation. This is a good…

What do you mean by "it splits the ecosystem in two"? I never observed such split, certain methods intentionally offer sync and async variants.

Interruption is achieved through cancellation tokens and has to be handled by consuming methods. There is no way around it because interrupting execution at an arbitrary point would lead to all kinds of issues regardless of the language (unless it implements some form of transaction abstraction and rollbacks all uncommitted changes).

Re: Java 21 makes me like Java again

#370
post #182

The problem with Java is not Java. It is Oracle and no amount of new features is going to fix that.

Can this fkin FUD finally die? Java is pretty much the safest bet on a longevity, stability, risk aversion spectrum. Also, Oracle just has a particularly bad PR, but it is not at all worse than any other similarly sized company.

Oracle has definjtely done bad things; mismanagement of java is not one of them. They got a pile of crap and turned it into something competent.
Post reply on HN