Minor typo in the linked site: "JDK 20 reached General Availability on 21 March 2022" Should be 21 March 2023 Not sure who can edit that page but putting here.
Java 20 / JDK 20: General Availability
211–220 of 356 posts
Re: Java 20 / JDK 20: General Availability
#212What are some good primers to understand the prominent new Java features? Not just in 20, but since, say, 8. Asking as someone who would like to be cursorily familiar with Java, but does not use it day to day. I'm very familiar with things like auto type inference, pattern matching, multi-line strings and structured concurrency from other languages, so I'm not looking for an introduction to Java. I'm looking for some…
Boring answer... but Chat GPT? I asked it what was new in Java 8 and it enumerated a number of features. I could proceed to ask it about more details for each, and then continue Java version by version and I think it would be quite exhaustive. The other day I did something similar for cell biology. As a layman I wanted to learn more about DNA, mRNA, tRNA, translation, transcription, mitosis, miosis, etc. I think I le…
Re: Java 20 / JDK 20: General Availability
#213its amazing how much the world hasn’t been able to keep up with java. github PRs still have no syntax highlighting support for record and var
Re: Java 20 / JDK 20: General Availability
#214Earlier quoted context omitted.
Because it is an expression that introduces a new keyword. You could say “return match…” It’s not easy to introduce without breakage. Not saying it cannot be done. But PHP didn’t manage to for example. It also isn’t real pattern matching but that’s a different issue.
Oh, so you were referring to the specific syntax in the current proposal, rather than pattern matching in general? Java and C# show how the syntax can be done in a fully backwards-compatible manner. It looks like it's just not the JS way by choice - apparently every new keyword that was added since ES5 is an actual keyword reserved in all contexts, not context-dependent?
Re: Java 20 / JDK 20: General Availability
#215I kind of assume it's due to the cliché Java-oriented hatred, but curious to hear opinions...
Re: Java 20 / JDK 20: General Availability
#216Earlier quoted context omitted.
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.
At the risk of starting a flame war, the CLI and the coreCLR are fare superior VM and platform from a technical stand point. A lot of the features schedule for jave 21 / project Valhalla are just basically catching up to modern VM design. Of course there is more to the choice of a platform than just the technical differences.
Re: Java 20 / JDK 20: General Availability
#217Minor typo in the linked site: "JDK 20 reached General Availability on 21 March 2022" Should be 21 March 2023 Not sure who can edit that page but putting here.
Just adding too, I think some of the switch statement example code is wrong: Object obj = 123L; String formatted = switch (obj) { case Integer i -> String.format("int %d", i); case Long l -> String.format("long %d", l); case Double d -> String.format("double %f", d); case String s -> String.format("String %s", s); default -> o.toString(); }; Unless I'm not understanding something, the default statement should be `obj…
The Billion Dollar Mistake meets the Power of Compounding Interest to produce an inflation adjusted number that just keeps on giving
Re: Java 20 / JDK 20: General Availability
#218Earlier quoted context omitted.
I unfortunately encounter this mindset so much in Java programmers, and the similar "we don't need no feature X" even if the feature has proven themselves for a long time in a large amount of languages. I'm hesitant to bring it up, but I see a lot of Blub Paradox [1] among Java programmers. Heck, a lot of places disallow `var`, while over here in Kotlin-Python-Rust-C#-Typescript-Go-etc-land that's been the default si…
Var is nice. But I generally prefer to not require people to jump out of the current code to figure out the type of a variable. And yeah, I've worked in those other languages, and navigating unfamiliar code with var everywhere can be confusing, so I try to avoid that kinda thing. Records are nearly useless to me. Immutability is great, but I need a way to derive new sets of information based upon an set of informatio…
Regarding records, you never had someone update a POJO, add a field, and forget to update equals and hashCode?
Sealed classes are great for everything parsing/validation, in data modelling. They're not a solution for behavior polimorphism, but I don't think they were supposed to.
Re: Java 20 / JDK 20: General Availability
#219This feels a bit like discussing the new fancy garden hoe as a farm hand as they are making the tractor.
Re: Java 20 / JDK 20: General Availability
#220Earlier quoted context omitted.
What’ the hype with pattern matching? What does it solve?
It's really nice syntactic sugar. Complicated conditional logic cluttered with redundant types turns into a series of simple patterns. "Just" makes it easier to not make stupid bugs (I'm all for it).
// Given an Option
val maybeThing: Option[String] = getThing()
// Classic
if (maybeThing.isDefined) {
useThing(maybeThing.get)
} else {
NotFoundResponseEtc()
}
// Pattern matching (not too IDE auto generated exhaustive match cases!)
maybeThing match {
case Some(thing) => useThing(thing)
case None => NotFoundResponseEtc()
}
This scales well when matching a higher cardinality of things like a variety of Exceptions or enums or other tuple responses like Either etc.