18 ms·
Java 20 / JDK 20: General Availability
- ar9av 4y agoGist: ``` JDK 20 introduces six features: - Scoped values for safe sharing of data across threads - Record patterns for declarative data navigation and processing - Foreign function and memory API for interoperation with code and data outside the Java runtime - Virtual threads for lightweight concurrent programming - Structured concurrency for simplified multithreaded programming - Pattern matching for switch statements and expressions for concise and safe complex data-oriented queries ```
- carimura 4y ago...but also thousands of other stability, performance, and security updates.
- ActorNightly 4y agoDon't worry, someone will still manage put in a bug that results in a zero day in the next 2 years.
- papercrane 4y agoWhile 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.
- cesarb 4y ago> I can't recall a major one that was actually tied to the JVM itself since dropped applets. Not exactly tied to the JVM, but IIRC one of the prerequisites for the Spring4Shell vulnerability was the existence of a new method added by Java 9. If you were still on Java 8, you were not affected.
- ActorNightly 4y agoCorrect, but the reason those happen is because JDK, despite being on version 17 is still missing core features that are necessary for modern day use, like logging, backend web stuff, json parsing, e.t.c. So delegation to that is left to a large number of 3d party developers, and risk of pollution goes up, especially when you consider that there is financial incentive in the case of orgs like Apache to keep developing new features. There should be no reason why someone deliberately writes code for a logging library to go fetch and execute code over the internet, and make that the default behavior. The fact that someone did that, and it got approved and published to production, should be an indicator for anyone competent to stay away from Java completely. There is plenty of other compiled languages out there for whatever use case you need.
- kaba0 4y agoAs opposed to what, powering off your servers so they can never get vulnerable?
- ActorNightly 4y agoAs opposed to not using an enterprise, outdated language that is only used to essentially create jobs.
- mfiguiere 4y agoA good coverage of all the JEPs included in JDK 20: https://foojay.io/today/its-java-20-release-day-heres-whats-new/ https://foojay.io/today/its-java-20-release-day-heres-whats-...
- PaulHoule 4y agoNote all the new cool stuff is incubator and preview status and I'm a little worried that this will still be the case for the JDK 21 stable release.
- ludovicianul 4y agoI have hopes to see Virtual Threads in Java 21, also being the next LTS.
- grishka 4y agoIIRC they are going to release pattern matching for switch and record deconstruction as stable in JDK 21.
- rfrec0n 4y agoI think this is supposed to be the last preview version of FFI and the other JEPs from Project Panama, so hopefully we will have them at least but I definitely share a bit of that concern.
- carimura 4y agoProbably not this go-around: https://openjdk.org/jeps/442 https://openjdk.org/jeps/442 Better to be right then rushed though.
- zjaffee 4y agoI really hope to see the SIMD vector related improvements come through, I know there are some independent JDK code bases that have more evolved SIMD support, but for a lot of big data processing tools, switching away from jdk based languages appears to be the way SIMD related performance improvements have been realized because of this missing crucial feature set. JDK 11 was when this stuff was first in development, and it's truthfully insane that it hasn't fully been released yet.
- kaba0 4y agoMost of these low-level APIs simply just wait for value types - they don’t want to hardcode something into the language, that might not be a perfect fit for those. Which makes sense, frankly.
- carimura 4y agoMore details on 20: Announcement: https://inside.java/2023/03/21/the-arrival-of-java-20/ https://inside.java/2023/03/21/the-arrival-of-java-20/ VM improvements: https://tschatzl.github.io/2023/03/14/jdk20-g1-parallel-gc-changes.html https://tschatzl.github.io/2023/03/14/jdk20-g1-parallel-gc-c... Non-JEP Improvements: https://nipafx.dev/java-20-guide/ https://nipafx.dev/java-20-guide/
- Idiot_in_Vain 4y agoDamn, time flies. I remember the excitement from the different alpha/beta versions that were coming out in 1994/1995.
- garblegarble 4y agoThis 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() -> ...; ...am I misunderstanding the reasoning here? Is it being introduced to keep the grammar definition simpler? 1: https://foojay.io/today/its-java-20-release-day-heres-whats-new/ https://foojay.io/today/its-java-20-release-day-heres-whats-...
- mason55 4y agoIn the case of &&, the left hand side of the expression (Tuner t) isn't a boolean expression. In the case of "if", you're right, the grammar doesn't work, both because the syntax of Java already says that the if condition must be enclosed in parentheses and also because an if block is a statement and you need an expression here. To make either of those work, you'd have to make the rest of the pattern matching syntax much worse.
- anyfoo 4y agoThe “&&” one is super confusing indeed, but the “if” one is just a question of style. It would be possible to reuse the “if” keyword for different grammar. python does it for its trinary operator, where there is an expression instead of a statement after “then” (e.g. “foo = if bar then 1 else 2”), but if Java does not have the same habit of reusing keywords already (not sure), it might not want to start now for consistency.
- morph123 4y agoThis feels a bit like discussing the new fancy garden hoe as a farm hand as they are making the tractor.
- philipwhiuk 4y agoOnly if you build your tractors out of garden hoes ;)
- unixhero 4y agoAre these hoes somehow related to lemon stealing hoes?
- mrkeen 4y agoJava is a conservative language, which means that it waits and sees which features work well for the tractor, and then retrofits them to the hoe.
- timcavel 4y ago[dead]
- pron 4y agoexcept no one's making the tractor
- znpy 4y agoDoes anybody know if there are significant improvement fir java on arm in this release?
- tw1984 4y ago[flagged]
- voidfunc 4y agoThat people still write this kind of drivel and actually believe it on this site is frustrating. Every tool has a purpose and Java is a fantastic tool for a lot of use-cases.
- jwr 4y agoThat, and there are other languages (like Clojure) that are implemented on the JVM. I don't write any Java, but Clojure running on the JVM pays my bills.
- krzyk 4y agoWhat is the "cool" language nowadays?
- helf 4y ago[dead]
- WesSouza 4y agoRust or Zig
- substation13 4y agoOCaml is having a bit of a moment
- throwaway742 4y agoHolyC
- pansinghkoder 4y agoYou are right; lets start a linux kernel in rust. Send me a PR for that bootloader.
- carimura 4y agoMore info on 20: Announcement: https://inside.java/2023/03/21/the-arrival-of-java-20/ https://inside.java/2023/03/21/the-arrival-of-java-20/ VM improvements: https://tschatzl.github.io/2023/03/14/jdk20-g1-parallel-gc-changes.html https://tschatzl.github.io/2023/03/14/jdk20-g1-parallel-gc-c... Non-JEP Improvements: https://nipafx.dev/java-20-guide/ https://nipafx.dev/java-20-guide/
- pshirshov 4y ago> structured concurrency That's another huge effort which delivered us an imperfect abstraction. I would prefer to have HKTs and typeclasses, so I may implement my own IO monad.
- quectophoton 4y ago> I would prefer to have HKTs and typeclasses, so I may implement my own IO monad. I'm not a Java developer, and I haven't even read about higher kinded types or typeclasses (the theory side of programming is my weakness); but you picked my curiosity with this. Can you elaborate how concurrency done this way would look in Java?
- pshirshov 4y agoIdeally like this: https://zio.dev/reference/#concurrency https://zio.dev/reference/#concurrency Or this: https://hoogle.haskell.org/?hoogle=fork https://hoogle.haskell.org/?hoogle=fork
- bluetech 4y agoSome discussion on zio in loom-dev mailing list recently: https://mail.openjdk.org/pipermail/loom-dev/2023-March/005350.html https://mail.openjdk.org/pipermail/loom-dev/2023-March/00535...
- pshirshov 4y agoLoom is useful as an underlying mechanism for an IO monad. What I mean is that Java as language still lacks important features so they have to deliver half-baked things like that "structured concurrency". From my point of view these new abstractions are evil - the better ones were out there for a while.
- ackfoobar 4y agoOther than STM, what is special? Almost everything there has an equivalent in traditional imperative programming.
- roschdal 4y agoJava 8 is the best Java.
- oweiler 4y agoWhy? Java 11 is already leaps and bounds better than Java 8.
- roschdal 4y agoJava 8 was before Oracle started with evil licensing terms and crazy language changes which allowed all kinds of alternative syntaxes.
- cesarb 4y agoNot the parent poster, but I can see why: IMHO, the best new feature for Java was try-with-resources (Java 7), and the second best new feature was all the functional stuff in Java 8. On the other hand, Java 9 started the introduction of several breaking changes (it took years before I stopped seeing updates to Java libraries to fix their compatibility with Java 9 and Java 11), so it can be seen why someone would think of Java 8 as the highest point of that language. (For Java 9/10/11 in particular, there are several small enhancements, but nothing as earth-shaking as the changes we got with Java 7/8.)
- vips7L 4y agoIMO you're neglecting the thousands of improvements in the HotSpot runtime.
- cesarb 4y agoYou can't use any of these thousands of improvements if your software is broken because it depended on something which was removed, or changed in incompatible ways. It can take a lot of work and time until it all works fine, even more when the breakage happened deep within a third-party library, and as far as I could see, there was a lot of these breakages early on the Java 9/10/11 cycle. IMO, it's worth it to make your software compatible with the latest Java LTS release, but I can understand why some people see it as too much work for too little gain.
- akavi 4y agoNow even Java has pattern matching, what's Javascript's excuse? Literally the only feature preventing Typescript from being my perfect language.
- Waterluvian 4y agohttps://github.com/tc39/proposal-pattern-matching https://github.com/tc39/proposal-pattern-matching I'm not sure if it's stalled or not. But it's being discussed.
- jackworks 4y agoWe're still developing this proposal. be patient LOL
- Waterluvian 4y agoI've got infinite patience for the brave souls who propose and implement TC-39 specs. =)
- akavi 4y agoSorry, that was rude of me. I know it's a ton of work, and am endlessly appreciative of the work you (I assume?) and others have been doing to push this forward.
- javajosh 4y agoWow that's a proposal! I really like the idea of pattern matching, and I'm glad you're steering clear of modifying switch, but I find the sketches in the proposal pretty hard to read, especially with the combinator examples. I hope you guys take your time and stay more proud of what you leave out than what you put in.
- TheRealPomax 4y agoThis is something that far too few folks put in their progress/change logs. "We didn't do ..." is so incredibly important.
- leros 4y agoThis seems like an appropriate place to post the official Java rap: https://youtu.be/b-Cr0EWwaTk https://youtu.be/b-Cr0EWwaTk
- BenoitP 4y agoI prefer this one: Java Forever And Ever Movie (Java vs Windows .Net) https://www.youtube.com/watch?v=RnqAXuLZlaE https://www.youtube.com/watch?v=RnqAXuLZlaE
- oaiey 4y agoAwesome but today this would be a different story line ... maybe: two old conservatives (Java and C#) re-inventing themselves to fight against the hipsters (Go, Swift, JS, ...) ;)
- orthoxerox 4y agoJS is older than C#.
- pjmlp 4y agoWhile true, the hipster languages are the reason why minimal APIs came to be. .NET is loosing people to the "cool languages" in regards to younger generations.
- elygre 4y agoAll the JavaZone videos are amazing. Like this one: https://www.youtube.com/watch?v=1JZnj4eNHXE https://www.youtube.com/watch?v=1JZnj4eNHXE
- Traubenfuchs 4y agoI still don't understand what's the correct way to replace thread locals holding initialization heavy & non thread-safe instances besides using a pool which produces a lot of overhead when using loom/virtual threads. In the past, with ThreadLocal, you'd have one instance per thread, making sure that those instances could only be used once and would only be instantiated for all threads of your (acceptor) thread pool Does anyone know the solution?
- Holo314 4y agoVirtual threads are designed for light, IO-bound, tasks, if your task is heavy/CPU-bound tasks then you won't necessarily want to switch to virtual threads with ScopedValue.
- rjzzleep 4y agoHere's me wondering how many more years will pass before the Wayland support is going GA.
- erik_seaberg 4y agoIf applets and web start are dead, and Wayland doesn’t render remotely, how would this work? Would a Java app server have to ask the user to run something on the desktop?
- drdec 4y agoThere are java desktop applications, e.g. IntelliJ, SQLDeveloper, etc.
- erik_seaberg 4y agoIntelliJ is one of the few GUI apps on my work laptop, but my company is encouraging everyone to use JetBrains Gateway with a remote server farm instead (which sort of seems like a browser DOM only for their IDEs). When a backend needs an internal UI here, it's always a Javascript app in a browser.
- kaba0 4y agoDesktop apps are a niche, but a well-needed niche. Plus it’s not like there isn’t already a huge amount of Java desktop apps, and those are all running in X instead of Wayland.
- foolfoolz 4y agoits 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
- jayd16 4y agoWhy do you think that is? I thought things like the language server protocol made this a self service kind of problem. Who needs to be catching up?
- oaiey 4y agoBecause syntax highlighting in JavaScript is (presumingly) not covered by LSP but by a generic syntax parser. And these updates take endless through the supply chain pipeline. And as a side note: LSPs are not exactly free these days anymore. Java is not considering it core project (I guess outsourced to RedHat and Eclipse) and Microsoft has a very erratic behavior towards what is in and out the LSP or DAP.
- TheAceOfHearts 4y agoGithub uses Linguist for syntax highlighting and has a section in their CONTRIBUTING document for fixing bad syntax highlighting [0]. Admittedly I couldn't figure out exactly what repo is being used for Java's syntax highlighting since vendor/README.md says Java is using tree-sitter/tree-sitter-java and grammar.js in that repo appeears to already include references to record. languages.yml [1] shows ace_mode java, and ace editor's java_highlight_rules.js doesn't mention record anywhere. I'm not clear if github is using ace editor or code mirror, since both are mentioned there. Hopefully this helps get started on improving the poor syntax highlighting experience. [0] https://github.com/github/linguist/blob/master/CONTRIBUTING.md https://github.com/github/linguist/blob/master/CONTRIBUTING.... [1] https://github.com/github/linguist/blob/c34f887f48d81e2ed42b59825fa5fe12d3918d63/lib/linguist/languages.yml#L3194 https://github.com/github/linguist/blob/c34f887f48d81e2ed42b... [2] https://github.com/ajaxorg/ace/blob/a2e89b94b4dcdff28bf3c8f4cb90ff008b13d0bd/src/mode/java_highlight_rules.js https://github.com/ajaxorg/ace/blob/a2e89b94b4dcdff28bf3c8f4...
- mrkeen 4y ago
- tiffanyh 4y agoWhat's the relationship between the Java releases and GraalVM releases?
- mike_hearn 4y agoThey're being synchronized at the moment.
- jwr 4y agoAs a Clojure programmer, I don't care about any of the Java language features or improvements, but I'm super happy that I'm getting a state of the art JVM that is continuously developed, maintained, extended and optimized, over a time scale of decades. This is incredibly useful: having a good VM to run your code in, with good modern garbage collectors, is not an obvious thing (as many other languages have learned). This is not the LTS release, so I won't be switching to it, but I'm looking forward to the next LTS.
- zerr 4y agoThe same applies to Clojure CLR, right?
- herculity275 4y agoI 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.
- useerup 4y ago> 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/blazor https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blaz...) and Blazor United (https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-1/ 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.
- FalconSensei 4y agoAnd here I am still on Java 8 :/
- rafaelturk 4y agoImpressive how many companies are stuck on quite old java versions. We are a core API for payments services, and we need to force our customers to upgrade to newer Java versions as most of them don't support newer encriptyion protocols
- oaiey 4y agoThank You for your service.
- taftster 4y agoI 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 that is just being conservative and intentional about the upgrade path, that's another entirely different thing. I don't mind a company that has been using Java so much that it's just a slow process for them to get on the next thing. Old libraries that need to be recompiled for Java modules, etc. Hopefully it happens for you soon.
- logistark 4y agoI think that the main problem upgrading beyond Java 8 is Java 9 and module system and a lot of javax package classes that were removed. It will be very helpful a tool that can detect what modules or classes that are being used by your codebase and add them as maven or gradle dependencies and add them to the classpath.
- rerdavies 4y agoThe main problem with upgrading beyond Java 8 is that it's Android! And we all know how THAT went.
- barkingcat 4y agoMinor 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.
- spicybright 4y agoJust 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.toString()` as `o` isn't defined.
- mdaniel 4y agoJFC, I was going to say they should have used `String.valueOf(obj)` since I expected `Object obj = null; switch (obj) { default ->` to do something sane but no, the stupid PoS NPEs because `switch` itself evidently calls `Objects.requireNonNull` The Billion Dollar Mistake meets the Power of Compounding Interest to produce an inflation adjusted number that just keeps on giving
- _old_dude_ 4y agoYou can add a 'case null' explicitly and merge it with default using 'case null, default -> ...'. See [1] for more. [1] https://openjdk.org/jeps/433 https://openjdk.org/jeps/433
- barkingcat 4y agoThis was fixed by Mark Reinhold
- philonoist 4y agoCould the pundits of HN please compare this release with Kotlin?
- jillesvangurp 4y agoPicking the release notes apart: - ScopedValue (Incubator). Seems like a replacement for ThreadLocal that is intended to be a bit less dangerous (it is notorious for leaking memory and file handles). The Kotlin equivalent would be CoroutineScope. I'd say the latter is the cleaner solution. And probably ScopedValues came into existence for the same reason (co-routines & structured concurrency kind of breaking ThreadLocal a bit). - Record Patterns (Second Preview). This looks a bit like Kotlin's smart casts. Useful. I think the Kotlin implementation with contracts is a bit more powerful and broadly applicable in more use cases. But nice of course. - Pattern Matching for switch (Fourth Preview). That looks to me like an attempt to beef up the Java switch, which is a welcome change. The Kotlin equivalent would be when. Not a whole lot of difference at first glance. But combined with smart casts, Kotlin is quite nice already IMHO. Scala developers might disagree about a thing or two here.. - Foreign Function & Memory API (Second Preview). Looks like a nice JVM level feature for integrating native code that is potentially also of use to the Kotlin language developers. - Virtual Threads (Second Preview). The second iteration of Loom. The JVM level implementation for this is going to make Kotlin's co-routines potentially even nicer. I don't think it should be that disruptive for Kotlin developers already using co-routines but performance increases are nice. - Structured Concurrency. Also Loom related. From what I've seen of Loom so far, it should just work with your existing code without too much changes. And co-routines are definitely a nice API to do structured concurrency so not particularly relevant for Kotlin users. But it's going to be a big enabler for Java developers that have lacked this. - Vector API (Fifth Incubator). Another JVM level optimization that the Kotlin developers should be able to make use of. I imagine projects like the kotlindl framework (a deep learning framework) can make use of this. A bit niche but nice if you use things like that. So, nice incremental change and a few nice things that Kotlin will benefit from probably. Whether you use Java or Kotlin, it's going to be nicer for everyone once this ships in an LTS jdk.
- Holo314 4y ago
- DonHopkins 4y agoWhy not just use C# instead? It was purposefully designed to address and correct the many mistakes of Java, and much more importantly, it's not owned by Oracle.
- Alifatisk 4y agoIsn’t openjdk disconnected from Oracle?
- znpy 4y agoNot only that, oracle’s jdk is actually a distribution of openjdk.
- vips7L 4y agoOracle is the main contributor in both lines of code and financial backing to OpenJdk.
- kaba0 4y agoDisconnected? No. Oracle pays for 95+% of all OpenJDK commits. Their OracleJDK is pretty much just an OpenJDK with a few logos added — they have over time made every proprietary feature open-source and available in OpenJDK. But as I expanded a bit more here (https://news.ycombinator.com/item?id=35249701 https://news.ycombinator.com/item?id=35249701 ), Java is probably the safest bet from a code longevity perspective.
- Alifatisk 4y agoI didn’t know that, interesting!
- oaiey 4y agoWith all my love for .NET, why not continue Java with its new features when it fits to your developer base, existing products etc. Give it one or two more years and Java is where C# is ... also aesthetically. As did JavaScript.
- DonHopkins 4y agoWhy not just use C# instead? It was purposefully designed to address and correct the many mistakes of Java, and much more importantly, it's not owned by Oracle.
- taftster 4y agoAll the while, adding its own mistakes to the pile. As an example, idiomatic Java style is moving away from getters/setters and instead favors builders and immutable types. That whole inheritance vs. composition concept is changing the way Java is being used. Meanwhile, C# has baked getters/setters so deep into their language (as properties) that there's just no moving off of them. Have you tried making a Builder in C# - ugh. Much harder than it should be. C# took the best of Java and ran deep into a cave with it. Meanwhile, Joshua Bloch's Effective Java has completely changed the way that "good" Java should be written and likely helped kickstart the whole revolution that is modern Java. I agree with your sentiment in general. C# / CLR are truly remarkable engineering feats. But Java is starting to break away from its old molds and is seemingly adding agility as it goes. As far as ownership. Java is not owned by Oracle any more than C# is not owned by Microsoft. They are both open languages with a majority backing supporter that yes, has a lot of influence over the languages. I'd argue Microsoft has more influence over C# / CLR than Oracle does on Java / JVM (but that's too close to call and probably too opinionated to suggest).
- desertlounger 4y agoYes. And with "records" (record classes, something with the characteristics of a tuple or struct) you can get further away from getter/setter boilerplate code.
- taftster 4y agoI just wish records had an easy way to facilitate and/or associate a builder with them. Wishful thinking, out of scope for what they are. And of course, it's not hard to write a FooBuilder that's defined to help construct a Foo record. If Java records could be told to have a private constructor, I'd be completely satisfied with them. I just don't like the ability for callers to be able to directly instantiate a record without having gone through my builder to do so. I want to completely enforce that my record is instantiated with all its invariants dealt with properly. A builder is a very nice way of doing that.
- mbfg 4y agoI'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?
- somenameforme 4y ago"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-language-and-vm-features.html https://docs.oracle.com/en/java/javase/19/language/preview-l...
- deleted 4y ago[deleted]
- simonkagedal 4y agoYes, they reserve the possibilty to completely redo or even remove these preview features. They are not enabled by default, you have to opt in with a compiler flag.
- mbfg 4y agook, that makes some sense.
- carimura 4y agoYou can read all about it here: https://openjdk.org/jeps/12 https://openjdk.org/jeps/12 with a slight addendum here: https://openjdk.org/jeps/8300604 https://openjdk.org/jeps/8300604 and podcast that discusses both: https://inside.java/2023/03/21/podcast-030/ https://inside.java/2023/03/21/podcast-030/
- WesSouza 4y ago[flagged]
- jayd16 4y agoStructured concurrency looks a lot like C#'s Task library without the async/await sugar but with the exact same footguns. Joining into a synchronous function is an anti-pattern in C# because you consume threads. This seems to be the same, except with the assumption that virtual threads are fine.... But that's not an assumption that can be made by the method writer, right?
- pjmlp 4y agoTasks aren't threads in TPL.
- deleted 4y ago[deleted]
- jayd16 4y agoWhat are you trying to say? They still run on threads and can consume them.
- pjmlp 4y agoThey are no different from how Go routines or Java's virtual threads multiplex OS threads per execution path. In fact, if you feel like doing some advanced stuff, you can write your own schedule algorithm.
- deleted 4y ago[deleted]
- digitalsanctum 4y agoAs an engineer that last used Java when it was Java 11, I cringe at the thought of diving back in. A trade-off of increased release velocity for any language I suppose.
- kaba0 4y agoWhy? Only the encapsulation difference was a slightly bigger breaking change since 8, after you are done with that it really is smooth sailing. Or if you mean addition of new features, then Java is very conservative on that front and it is still a very small language compared to most other mainstream ones.
- nprateem 4y agoIt's really not as bad as it used to be. I recently picked it up again after playing with Spring boot. I got to say Spring boot seems awesome, and java as a whole it much more ergonomic. Worth another look.
- twblalock 4y agoYou don’t need to learn or use any of the new features. Most devs seem to still pretend they are writing for Java 8 anyway.
- oulu2006 4y agoI use Clojure, which benefits from these consistent JVM improvements; things like pattern matching have been accessible to me for years already, but I like that Java slowly trails along as it helps keep me vested in the Java ecosystem.
- hn_throwaway_99 4y agoReally excited to see how virtual threads are taken up by developers, and if they affect the larger programming language community. They just really seem like "the best of both worlds" to me: the high scalability/low resource usage of async/await, with the ease-of-use experience of threads (e.g. not having to worry about "function coloring").
- cesarb 4y agoI'm personally not so sure. We already had something like that before (M:N threads), and the world moved away from it, towards letting the kernel manage everything (1:1 threads). So I'd expect instead that operating system kernels gain whatever features are missing for scaling to a higher number of threads, and everything once again goes back to each programming language thread corresponding to one kernel thread.
- kaba0 4y agoM:N is not the interesting aspect of virtual threads at all, automagically turning blocking operations into non-blocking is - which has not really been tried before (with erlang and go being the first).
- cryptonector 4y agoGNU Pth had "automagically turning blocking operations into non-blocking" ages ago, and it wasn't the first. I think what you probably had in mind is that C libraries of the 90s that did M:N threading didn't turn blocking operations into non-blocking? Using blocking operations to switch contexts is really nothing new. Heck, the cooperative multi-tasking systems of the 80s (Mac, Amiga) all essentially did that for processes (not threads), and so did Unix in the 70s.
- kaba0 4y ago> I think what you probably had in mind is that C libraries of the 90s that did M:N threading didn't turn blocking operations into non-blocking Yes, mostly, though my history knowledge is definitely lacking so do correct me if I’m wrong. But you are right, there was nothing fundamentally missing, probably just no good OS support for non-blocking IO calls in the early days? Though probably the IO-CPU ratio was also different, so the benefits were not as big?
- nsm 4y agoWhat 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 something like "Modern Java for the experienced Rust/Python/C++ programmer". Thanks!
- mongol 4y agoBoring 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 learned it much better by querying Chat GPT than say reading Wikipedia. Something about the interaction, to ask for more details on what was not clear that helped me understand it.
- nsm 4y agoThanks! I keep forgetting to reach for this.
- copperx 4y agoI've avoided that because of the tedium of having to fact check everything.
- illiarian 4y ago> Boring answer... but Chat GPT? Trained on data up to September 2021.
- dragonwriter 4y ago> Trained on data up to September 2021. Wrap the ChatGPT API in a ReAct pattern implementation where one of its available actions is a search against the Java 20 docs? Probably better for reference than tutorial, though.
- marsven_422 4y ago[dead]
- furtiman 4y agoComing from the telegram bot of hacker news, where this post has a lot of downvotes (21 down to 6 up, which is quite a lot for how many reactions usually are there), could someone (perhaps even from people who downvoted) explain why this news is met with such negativity? I kind of assume it's due to the cliché Java-oriented hatred, but curious to hear opinions...
- timcavel 4y ago[dead]
- MichaelMoser123 4y agovirtual threads are still in preview. At which stage/release will they be in regular usage? (not preview) Is anyone planning to use virtual threads, at this stage? i understand that virtual threads are very similar to goroutines in golang
- kasajian 4y agoWhy is it difficult to determine what those features are 429, 432, 433, etc. How difficult would it have been to put links there so one can click on the link to see what it is. Have these people hard of hyper-text markup?
- bcrosby95 4y agohttps://openjdk.org/projects/jdk/20/ https://openjdk.org/projects/jdk/20/ It's linked in the email.
- vbezhenar 4y agoSo... exactly zero new features? Well, hopefully JVM got faster and future LTS release will be more interesting.