Live data from Hacker News

Java 20 / JDK 20: General Availability

mail.openjdk.org

131–140 of 356 posts

Re: Java 20 / JDK 20: General Availability

#131
post #14

[flagged]

C++ for when you need to be very close to the metal. Java (and C#) are still legitimate options for server side code when you want speed and type safety but managed memory.

Not only legitimate. Also better for many scenarios. Not only when you consider your existing workforce but also hire new people. It is so much easier if you onboard someone into something which is procedural at its heart and everyone can translate their core C/C++/JS/PHP/Python/Perl/... procedural programming into Java and C#. The reason async/await is so accepted there is because of exactly that.

Try throwing someone into a Go project with a C background. Until they learn the way of concurrency there, a lot of time is gone. Or even go one step further and throw a generic procedural coder into something like F# or Haskell. Or take the example of reactive UIs: It took the industry a decade to move from MVP based UI frameworks to reactive based UI platforms and we are far from being done with that move. Angular literal reactive-under-the-hood existence is due to that fact that people love to work with their traditional ways and are more productive in them.

Re: Java 20 / JDK 20: General Availability

#132

Earlier quoted context omitted.

...but also thousands of other stability, performance, and security updates.

Don't worry, someone will still manage put in a bug that results in a zero day in the next 2 years.

While the Java community has had some high profile vulnerabilities, I can't recall a major one that was actually tied to the JVM itself since dropped applets. Instead it's usually a popular library or framework.

Re: Java 20 / JDK 20: General Availability

#133

Earlier quoted context omitted.

I mean, that's OK though. Not sure why this is considered such a bad thing. You're missing out on some new language features, sure, but Java 8 is still reliable and rock solid. There's lots of companies that have hesitation or even inability to upgrade, hopefully there's at least some initiative and/or direction to do so. A company that is head-in-sand deliberately not upgrading from Java 8 is one thing. A company th…

> I mean, that's OK though. Not sure why this is considered such a bad thing For existing software, sure. But the problem I guess is when there are a lot of newer projects starting and everyone is stuck on the older version

[deleted]

Re: Java 20 / JDK 20: General Availability

#135

And here I am still on Java 8 :/

I mean, that's OK though. Not sure why this is considered such a bad thing. You're missing out on some new language features, sure, but Java 8 is still reliable and rock solid. There's lots of companies that have hesitation or even inability to upgrade, hopefully there's at least some initiative and/or direction to do so. A company that is head-in-sand deliberately not upgrading from Java 8 is one thing. A company th…

There's very little reason not to upgrade from Java 8 at this point. Everything should be a drop-in replacement and there are significant performance benefits (garbage collection is leagues better) to doing so.

The bigger problem is that a lot of places are stuck on Oracle JDK - 8u252 is the last free version so a lot of places just decided they'd never upgrade, nor do they want to look at whether Temurin or Coretto would work for them (the answer is usually yes).

Re: Java 20 / JDK 20: General Availability

#136

This is exciting, can't wait for the LTS release next year... that said, I don't much care for the "case SomeType t when ..." pattern matching syntax, I don't see the benefit of introducing a new keyword over using "if"... or even just "&&". To pinch the example used in[1]: case Tuner t && guitar.isInTune() -> ...; and case Tuner t if guitar.isInTune() -> ...; both seem as clear as case Tuner t when guitar.isInTune()…

I work on Dart which is also adding pattern matching [1]. When we designed the syntax for guards, we also considered exactly these three choices before ultimately landing on "when" too.

Our main reasoning was:

"&&" is intuitive but it means that you can have a pattern that is immediately followed by an infix operator. That can be problematic if you ever want to make "&&" a valid pattern infix operator. And, in our case, we ended up doing exactly that, so "&&" would have been ambiguous. If you were to write:

    case foo && true:
Then it could be parsed as either a pattern that matches when the value is equal to the constant "foo" and is equal to the constant "true". Or it could be parsed as a pattern that matches when the value is equal to the constant "foo" followed by a pointless guard that always succeeds.

"if" is nice because it's already a reserved word and the semantics are pretty obvious. But in Dart, an if statement always has the condition in parentheses. Those are pointless in a pattern since we already have another explicit delimiter separating the guard from the case body:

    case foo if (condition):
    //                     ^
We could say that the if condition in a guard doesn't need parentheses but if conditions elsewhere do. But that's likely just an annoying footgun where users will write them unnecessarily (but harmelessly at least) in guards and forget them in if statements and get compile errors.

If Dart didn't require parentheses around if conditions, we probably would have used "if" for guard clauses to (like Scala and Rust do).

So we tried "when" and most users and team members seem to like it. Syntax design is a human-centered process so often the right answer is just what feels right to the most people.

[1]: https://github.com/dart-lang/language/blob/master/accepted/f...

Re: Java 20 / JDK 20: General Availability

#137
post #75

Earlier quoted context omitted.

The same applies to Clojure CLR, right?

I haven't looked into CLR in a long time, but it feels like it has a fraction of JVM's adoption and community size. Microsoft also seems to be prioritizing Typescript and Node internally with its recent moves.

> Microsoft also seems to be prioritizing Typescript and Node internally with its recent moves.

You may want to look at Blazor Webassembly (https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blaz...) and Blazor United (https://devblogs.microsoft.com/dotnet/asp-net-core-updates-i...)

They scrapped the old CLR and started over with a new "CLR Core".

Then they ported the new CLR Core along with the framework BCL to webassembly and has the CLR running in the browser, upon which they built Blazor Webassembly.

So you can now target the CLR and have your code run in the browser.

And now they are making progress on Blazor Unified where components can start of as server-side rendered exclusively and transparently and automatically move to webassembly rendering within the same application or page. It really is crazy stuff.

Typescript is not the only thing going on in MS Engineering.

Re: Java 20 / JDK 20: General Availability

#138
post #90

I'm curious what is meant by a "preview feature, or second preview feature, or..." in a released product?? I don't suppose they are going to remove it later. So in what way is it a preview? Are they signalling that it might have breaking changes in the future?

"A preview feature is a new feature whose design, specification, and implementation are complete, but which is not permanent, which means that the feature may exist in a different form or not at all in future JDK releases." https://docs.oracle.com/en/java/javase/19/language/preview-l...

[deleted]

Re: Java 20 / JDK 20: General Availability

#139

Earlier quoted context omitted.

What’ the hype with pattern matching? What does it solve?

If you've ever done any assembly programming or worked with other old or low level languages, you may have encountered an environment where you can write simple operator expressions, but you can't compose them. So this is OK: a = b + c d = e - f g = a * d But the compiler doesn't allow: g = (b + c) * (e - f) You have expressions that produce, but they don't compose. You can't produce a value from a more complex, nest…

All of your examples basically map to Javascript destructuring, which is already fully supported. Comment you are replying to is asking about pattern matching for flow control or conditional assignment, which JS doesn't currently support.

Re: Java 20 / JDK 20: General Availability

#140

And here I am still on Java 8 :/

Perfectly fine for already written codebases or codebases that need to target hardware that's stuck in the past?

Just don't use it for new projects on modern hardware. Be on at least the current LTS version for that and enjoy a much more expressive language on a much better JVM.

Post reply on HN