top | item 26477144

Java 16

410 points| JCWasmx86 | 5 years ago |jdk.java.net | reply

310 comments

order
[+] benjiweber|5 years ago|reply
Lots of shiny new toys to play with :) I like playing with new features and pushing to silly limits. Here's some fun things you can do now:

Compiletime checked state machines with Sealed Classes [preview feature] https://benjiweber.co.uk/blog/2020/10/03/sealed-java-state-m...

Autobuilders, Mixins, Conversions & more with Records https://benjiweber.co.uk/blog/2020/09/19/fun-with-java-recor...

Pattern Matching fun https://benjiweber.co.uk/blog/2021/03/14/java-16-pattern-mat...

[+] bob1029|5 years ago|reply
If you enjoy pattern matching in Java, I would recommend checking out the latest & greatest that C# has to offer as a comparison:

https://docs.microsoft.com/en-us/dotnet/csharp/pattern-match...

Being able to combine pattern matching with switch expressions has allowed us to construct extraordinarily concise state machines for our UIs.

[+] elric|5 years ago|reply
Nice to see that Records are finally out of preview. But note that Sealed Classes are still in Preview mode and are subject to change (or removal) in newer versions.
[+] exdsq|5 years ago|reply
Love the state machine example :)
[+] dadoge|5 years ago|reply
Very cool to see that Scala continues to have a huge impact on Java’s roadmap.

Records and Sealed Classes are borrowed from Scala.

Could be not the best news for new Scala adoption, but good news for developers having better abstractions in Java

Edit: Kotlin, and other languages should also mentioned since they also include similar features. I still think Scala has had the most influence over the years.

[+] mdm12|5 years ago|reply
We see similar developments with C# borrowing features from F#, with records in v9, pattern matching, etc.

While it's good for C#/Java, it does make it harder to push for adoption for a language such as Scala and F#. Why bother investing in the languages with a much smaller market share when the big boys adopt good bits and pieces from them constantly?

[+] Decabytes|5 years ago|reply
This is why it's so important to have different programming languages! Sometimes it's hard to do things differently when you are just looking at your own programming language, and the tools it has available to it. Not everyone programming language needs to be a behemoth to be useful to other people. I say keep making new an interesting programming languages! It will only lead to better programming languages over all
[+] bishop_mandible|5 years ago|reply
> Records (...) are borrowed from Scala.

I think records already existed in FORTRAN and other languages like ALGOL-60. C has structs, too.

[+] meddlepal|5 years ago|reply
I think the reaction has been more to Kotlin than Scala.
[+] JohnKacz|5 years ago|reply
I saw someone recently post the idea that Java/Scala/F# almost functioned as LTS/Stable/Dev in reference to how these languages were sharing impact.
[+] eweise|5 years ago|reply
I think Kotlin is more at risk than Scala on the server at least. Scala still has a lot of advanced features that sets itself apart. Kotlin is a better Java but Java is catching up fast.
[+] wpietri|5 years ago|reply
I hope they're subsidizing the Scala project, and Kotlin too. Nothing better for a dominant player than having other people scout the territory for you.
[+] u678u|5 years ago|reply
I spent a few years moving to Scala but have come back as Java really does everything I want now. Just Akka is a bit clunky.
[+] sireat|5 years ago|reply
Besides Scala, I feel both Kotlin and Rust have been heavily influenced by Scala.
[+] BoyRobot777|5 years ago|reply
Why not Kotlin, C#, F#, ML and so many other languages?
[+] closeparen|5 years ago|reply
Man, I hope the migration to Java 11 that my infrastructure team started 18 months ago is going okay.
[+] kronin|5 years ago|reply
Can't read whether this is sarcastic or tongue in cheek ;-)

Java 11 is the newest LTS release. The next LTS release will be Java 17. Many companies won't touch anything that isn't LTS. There are still a large number of companies staying on Java 8 :shrug:

[+] hasa|5 years ago|reply
OMG I'm old. I thought that Java 9 would be next version.
[+] tmp7oaje|5 years ago|reply
As a student most of the way through a Java course, I'm wondering what Java is still used for. Java applets are dead, Android is moving on to Kotlin (apparently Google got in legal trouble with Oracle even though Java is "open source?"), and I can't think of any desktop applications that use Java anymore. Java is supposed to be able to "run anywhere," yet C++ is more portable because it doesn't require the JVM to run.

Yet clearly I'm mistaken, since Java is still one of the most popular languages.

Edit: also please help me understand - do I have to pay for a license even though Java is open source? Is this normal for other languages too?

[+] kaladin_1|5 years ago|reply
Happy with the number of comments on this release.

HN is a funny place.One day you are convinced no smart person on HN is still writing Java and the next day you see droves discussing about a java release.

[+] whalesalad|5 years ago|reply
I love the Java website. Strong early-2000s vibes. Still has an XHTML doctype!
[+] btown|5 years ago|reply
And now a 500 database error too!
[+] java-man|5 years ago|reply
Why they decided to change the keyword rules to use "non-sealed" is beyond me. Surely, there might be other choices? Closed/unclosed? Unsealed?
[+] mooreds|5 years ago|reply
Super interested in https://openjdk.java.net/jeps/386 as alpine linux is at the heart of a lot of docker images. We use ubuntu currently as our base image, but tried to use alpine recently and ran into some issues with musl.

Hopefully this version will work better.

[+] pkphilip|5 years ago|reply
I wish Java had something similar to Properties in Delphi.

http://docwiki.embarcadero.com/RADStudio/Sydney/en/Propertie...

You can have Get and Set methods for properties or even allow direct access to the variable itself.

type TCompass = class(TControl) private FHeading: THeading; procedure SetHeading(Value: THeading); published property Heading: THeading read FHeading write SetHeading; ... end;

Also, properties can be indexed.

type TRectangle = class private FCoordinates: array[0..3] of Longint; function GetCoordinate(Index: Integer): Longint; procedure SetCoordinate(Index: Integer; Value: Longint); public property Left: Longint index 0 read GetCoordinate write SetCoordinate; property Top: Longint index 1 read GetCoordinate write SetCoordinate; property Right: Longint index 2 read GetCoordinate write SetCoordinate; property Bottom: Longint index 3 read GetCoordinate write SetCoordinate; property Coordinates[Index: Integer]: Longint read GetCoordinate write SetCoordinate; ... end;

Properties can also have "property pages" which can show specific user interfaces for viewing/setting these properties.

https://www.delphipower.xyz/guide_8/adding_a_property_page.h...

I have yet to see anything of this sophistication in Java or for that matter in any other component framework.

[+] yellow_lead|5 years ago|reply
Records are a cool highlight for this version. https://openjdk.java.net/jeps/395
[+] seahawks78|5 years ago|reply
I am curious where does it leave libraries like Lombok that basically ports a non-record type Java class to make it more record type-e by adding things like @Value, @Data annotations. Are those libraries/frameworks going to become obsolete now?
[+] ObscureScience|5 years ago|reply
What's the state of tail call optimization on JVM nowadays?
[+] JulianMorrison|5 years ago|reply
Still on Java 8 at work :-/
[+] stonemetal12|5 years ago|reply
Amazon's version or the for a while now EOL Oracle version? Maybe push to upgrade to something supported :)
[+] cferr|5 years ago|reply
Eight's JVM still ships with Minecraft, so that's not necessarily a bad thing. It's battle-proven.
[+] randomopining|5 years ago|reply
8 is still “modern” Java right? 11 didn’t add a ton ton for most developers.
[+] dehrmann|5 years ago|reply
For those who have upgraded, I assume Jigsaw is the main concern?
[+] EdwardDiego|5 years ago|reply
I've been using Maven and Gradle's toolchains functionality to move individual apps to Java >8 without breaking the legacy apps, works pretty well.
[+] BoyRobot777|5 years ago|reply
Every thread about new Java version has the same comment all the time. Why share it? What kind of response do you seek?
[+] aogl|5 years ago|reply
At a bank, and yes, us too!
[+] bartvk|5 years ago|reply
What’s the reason for that?
[+] setheron|5 years ago|reply
I'm actually stoked for jpackage, muslc and the vector API.

Just finished my CPU architecture and enjoying to see the new trend to adopt vectors again in the USA

[+] seahawks78|5 years ago|reply
Hopefully, there will be a day/release in the Java world when we will be able to write 10x - 20x shorter programs (in terms of LOC) with most mundane stuffs disappearing under the hood. Sighs!!

It will be interesting to see the reaction of project managers some of whom still measure productivity in terms of lines of code/# of commits! (yeah, they do and still exist).

[+] Fiveplus|5 years ago|reply
Curious how many folks here experimented with the now depreciated Ahead-of-Time Compilation feature?
[+] _old_dude_|5 years ago|reply
I did, the main issue is that jaotc doesn't do any pruning of the unused methods, so it generates too much assembly code. If i remember correctly, compiling just guava was to close to 1 gig.

GraalVM native image is far better, it "compiles" more slowly but the resulting executable is not too big.

[+] tannhaeuser|5 years ago|reply
Only briefly tested it. I thought RH's Quarkus project made use of it, didn't it? What's the post-16 way of Java AOT compilation?
[+] JCWasmx86|5 years ago|reply
I did experiment with it to improve the startup times of one of my applications (Java Swing). The gain was quite small, nearly not noticeable.
[+] seattle_spring|5 years ago|reply
Wow, might be time to finally throw out my copy of Java 6 SCJP (Sun Certified Java Programmer)