15 ms·
Java 18 / JDK 18: General Availability
- krnaveen14 5y agoJDK 18 G1/Parallel/Serial GC changes [1]: https://tschatzl.github.io/2022/03/14/jdk18-g1-parallel-gc-changes.html https://tschatzl.github.io/2022/03/14/jdk18-g1-parallel-gc-c...
- daypay 5y agoThanks for sharing, I enjoy reading about the GC changes every release.
- haunter 5y agoWhat are some good resources to learn Java? I only heard about this book being _really_ good https://www.amazon.com/Java-Beginners-Guide-Herbert-Schildt/dp/0071809252 https://www.amazon.com/Java-Beginners-Guide-Herbert-Schildt/...
- halestock 5y agoHere's the openjdk page which includes links to details of all new features: https://openjdk.java.net/projects/jdk/18/ https://openjdk.java.net/projects/jdk/18/
- tyingq 5y agoThis one looks interesting: "JEP 400: UTF-8 by Default": https://openjdk.java.net/jeps/400 https://openjdk.java.net/jeps/400 It sounds like a good idea, but I can imagine lots of downstream breakage, some of it not immediately obvious, with apps that make bad assumptions. Edit: The risks section of the linked doc above does explain some of that, and there is some notable risk.
- zenron 5y agoWindows default went over to UTF-8 from UTF-16 a few years back so its probably alignment with them especially with MS now rolling their own linux and java.
- JoshTriplett 5y agoTo the best of my knowledge, Windows still uses UTF-16 internally. They now support opting for UTF-8 as the charset in the 'A' APIs, but that doesn't mean Windows natively uses UTF-8.
- carimura 5y agoHere's a short interview with Naoto on JEP 400 https://inside.java/2022/03/22/podcast-023/ https://inside.java/2022/03/22/podcast-023/
- ardoise 5y agoI wouldn't be surprised if defaulting to UTF-8 inadvertently fixes more problems than it causes.
- tyingq 5y agoThat was not the experience when MySql switched in v4.1, at least for existing apps. Probably for net new ones it was great. Maybe things are different now?
- throw0101a 5y ago> It sounds like a good idea, but I can imagine lots of downstream breakage, some of it not immediately obvious, with apps that make bad assumptions. You're not wrong, which is probably why they did it in this release. JDK 17 was an LTS release, and 18 isn't. The next LTS will be JDK 21 in September 2023: * https://www.oracle.com/java/technologies/java-se-support-roadmap.html https://www.oracle.com/java/technologies/java-se-support-roa... This presumably gives folks times to adjust before jumping between LTSes in production.
- throw0101a 5y agoSomewhat related is "Oracle Java SE Support Roadmap" (LTS / non-LTS): * https://www.oracle.com/java/technologies/java-se-support-roadmap.html https://www.oracle.com/java/technologies/java-se-support-roa...
- kaycebasques 5y agoThis is tangential and possibly too open ended to be productive but worth a shot anyway. Why is Java so popular? I know of a major Silicon Valley company that's migrating their backend to it. Why Java over other languages? Or maybe there's not really other viable options? I'm speaking as someone who spent the last 6 years focused on frontend web technology.
- badhombres 5y agoIt's a stable and well proven technology that still has a lot of developer activity. Businesses are trying to make money, not explore technology, so a lot of them don't want to bother risking deliverables on something they may not have experience with. IMO
- jraph 5y agoI'll try: Java is a proven, boring and "easy" language without much surprise, with a big standard library and ecosystem.
- ape4 5y agoJava is great, but here's a surprise: if (str1 == str2) { // oops }
- dpratt 5y agoThat’s not an oops. You’re comparing pointers.
- jraph 5y agoStill, coming from other languages, it is all too easy to write this and this silently fails without any warning. This is consistent with the rest of the language, but I'd bet one rarely wants referential equality when comparing strings. People commenting "yeah but that's because you are a newbie / you are comparing references and you should know better" miss the point I think. I can easily see myself making this mistake while fully understanding what's going on.
- hu3 5y agoIs there a reason to use Oracle's closed-source Java implementation instead of the opensource implementations? Asking as someone who's ignorant about Java. edit: per comments below, Oracle's Java is open-source too these days.
- deleted 5y ago[deleted]
- water8 5y agoLicensing. Oracle requires a commercial license
- lgessler 5y agoThat's a reason not to use Oracle--GP's asking for a reason to use Oracle.
- water8 5y agoOpenJDK:Ubuntu::OracleJDK:RedHat
- ajoberstar 5y agoYou can get a paid commercial support license for Oracle's JDK to get an extended maintenance window. But Oracle's publicly available builds don't require a paid license. However,they only provide public builds of the current Java version. If you want LTS, you have to pay them or use another vendors builds.
- carimura 5y agoThat's changed a bit. As of JDK 17, Oracle offers Oracle JDK builds under the NFTC license [1], free for use in production with updates overlapping the next LTS version. [1] https://www.oracle.com/java/technologies/javase/jdk-faqs.html https://www.oracle.com/java/technologies/javase/jdk-faqs.htm...
- th3iedkid 5y agoIntelliJ is yet to catchup it seems https://www.jetbrains.com/help/idea/supported-java-versions.html https://www.jetbrains.com/help/idea/supported-java-versions....
- toyg 5y agoI don't think they ever supported a JDK on the day of release, they don't seem to have any sort of inside-track that would allow them to fix bugs before then.
- krzyk 5y agoThey don't need inside track, EA releases are available quite soon (and some JetBrains developers are also commiting to OpenJDK).
- astange 5y ago2022.1 is coming shortly. In any case, one can easily specify jdk18 as the platform to use for a project. The IDE might not recognize some syntax, but the code will compile and run just fine.
- throwaway9233 5y agoStill waiting for JNullType to be deleted or made illegal to inhabit all reference types. "I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. In recent years, a number of program analysers like PREfix and PREfast in Microsoft have been used to check references, and give warnings if there is a risk they may be non-null. More recent programming languages like Spec# have introduced declarations for non-null references. This is the solution, which I rejected in 1965." -- Tony Hoare Let's give credit to C# and Dart for fixing this, and bring shame to Java and Go for not doing so.
- xyst 5y agoMeanwhile, still using Java 8 at work
- potamic 5y agoI see this everywhere. What's the excuse in your case?
- abledon 5y agonot op, but in my company: all the people who wrote the systems left decades ago for better paying gigs. Broken CI/CD culture, DevOperations people are afraid to write (or unwilling to learn) IaC for deployments, must manage things by GUI (made at the time when JDK 1.8 was released). Developers are not engaged nor motivated to learn new tooling/best practices nor interested in migrating off JDK 8, since it just 'works' so why change it. Mgmt does not know much about tech so does not know that 'severe' technical rot is happening
- InfiniteRand 5y agoA Spring Boot project with a good number of dependencies, the bleeding edge Spring Boot supports newer Java, but then you need to worry about Hibernate's compatibility with the latest Spring Boot, etc. I think at least some of my dependencies still rely on reflection features that are limited by Java 9. Not OP by the way
- chromaton 5y agoI think for most people it's the introduction of the module system. If it causes code to break in libraries you're using and there's no direct replacement for those libraries, it's a big hill to get over.
- xyst 5y agoI think it's a mix of complacency, the change to a LTS model, internal governance, and lack of awareness. The company will only get off their ass once 1.8 no longer receives any updates. Looking at some of the older tickets in the system, this was the case when java 7 was no longer supported (massive influx of migration tickets in '15).
- rr808 5y agowhere tf is loom. Async programming is way too toxic.
- freedomben 5y agoIt's legitimately fascinating to see the rise of pattern matching, to the point that even Java will have it [1]! Combined with lambdas, this is a different language than the Java 1.5 that I first learned. If you would have told me that this would be valid Java code: static void testStringOrNull(Object o) { switch (o) { case null, String s -> System.out.println("String: " + s); } } I would never have believed you. And while it's not Elixir-level pattern matching, it's not toothless either. This is valid pattern matching code too: static void testTriangle(Shape s) { switch (s) { case Triangle t && (t.calculateArea() > 100) -> System.out.println("Large triangle"); default -> System.out.println("A shape, possibly a small triangle"); } } [1]: https://openjdk.java.net/jeps/420 https://openjdk.java.net/jeps/420
- Angius 5y agoJava turning more and more into poor man's C# with each release
- azth 5y agoMore like a very reasonable C# that fits in your head :) Even C# programmers are complaining about feature creep. Java's Project Loom will be superior to C#'s async/await.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- shepherdjerred 5y agoEverything since Java 7 has been a pleasure. The language is so much more mature now. The only problem is enterprise companies giving it a bad name, but I guess that's the price you pay for its broad usage.
- octotoad 5y agoAny good books out there on “modern” Java that somebody would recommend?
- shepherdjerred 5y agoEffective Java [0] is the Java book. It covers up to Java 9, and I expect the author will release another edition for Java 17 at some point. Java 9-17 adds some major language features, but they're not so major that you'd really need a whole book. You could look up the individual JDK release notes and see what each release changed. [0] https://www.oreilly.com/library/view/effective-java/9780134686097/ https://www.oreilly.com/library/view/effective-java/97801346...
- desdiv 5y ago>JEP400: UTF-8 by Default This changes the default charset of the Java APIs to UTF-8. I read that the Java 8's JVM's internal string representation is UTF-16 [0][1]. Is that still the case after JEP400? [0] https://docs.oracle.com/javase/8/docs/technotes/guides/intl/overview.html https://docs.oracle.com/javase/8/docs/technotes/guides/intl/... [1] http://tutorials.jenkov.com/java/strings.html http://tutorials.jenkov.com/java/strings.html
- exyi 5y agono, it's only for IO. It lead to way too much breakage if they changed how the string behaves. I generally like the idea to use UTF-8 strings, but if they didn't want to break string indexing, the indexing would take O(str.length)...
- papercrane 5y agoInternally strings will either be UTF-16, or if a string can be represented in LATIN-1 it may use a more compact representation. JEP400 is about I/O, previous to this change when you create something like a FileWriter without specifying the charset the platform default would be used. For a long time this has been recognized as a common foot gun, hence this change to a default that is more likely to be what the developer actually wants.
- shellac 5y agoYes, that won't change anything internal. However: > ...JVM's internal string representation is UTF-16 Hasn't been try for a while. They switched to using a byte array internally for storage, plus an encoding. Currently that's either UTF-16 or Latin 1, unless compact strings are disabled in which case it's all UTF-16.
- rcoveson 5y agoYou're talking about implementation details of java.lang.String. The interface it exposes is still UTF-16. Latin 1 has the special property that each of its fixed-width code units maps onto a single UTF-16 code unit. It is for that reason alone that CharSequence implementors can use it as an alternative to UTF-16. Imagine trying to implement `char charAt(int index)` if you're backed by a UTF-8 byte array (or UTF-32, for that matter)! From a programmer's perspective, Java is pretty much as UTF-16 as ever.
- krnaveen14 5y agoThe Arrival of Java 18! [1]: https://inside.java/2022/03/22/the-arrival-of-java18/ https://inside.java/2022/03/22/the-arrival-of-java18/
- mwcampbell 5y agoI'm pleasantly surprised by the deprecation of finalizers, with a plan to eventually remove them.
- Strilanc 5y agoWow, that's a really well-established feature to remove. But reading "JEP 421: Deprecate Finalization for Removal" [1] did convince me it's a good idea to deprecate it. I'm suspicious they'll never ever actually be able to remove them, given the reality of maintaining backwards compatibility. [1]: https://openjdk.java.net/jeps/421 https://openjdk.java.net/jeps/421
- native_samples 5y agoThey removed much bigger things, and broke backwards compatibility in much bigger ways. Finalizers aren't really used much in Java except for safety checks ("you forgot to close this object"), which can go missing without breaking things.
- kevincox 5y agoIf you are leaking file descriptors in a production service it will absolutely break things. Generally most servers that aren't pushing the FD limit can get away with delayed reclamation of FDs but if you never claim them you will run into problems. Plus most code probably handles this poorly. I suspect it will often result in exceptions opening new files or connection which are just caught and retried forever, resulting in your server locking up after some period of time. If you are lucky it just crashes and restarts. (The ultimate garbage collection.)
- mmastrac 5y agoI believe reference queues are the way to go about this now. Once you wrap your brain around them, it's far simpler to reason about. The only really issue is that you effectively need to litter your code with queue checks, or dedicate a thread to watching them.
- qqqqqwakers 5y agoWhen is this coming to Android?
- pjmlp 5y agoMost likely never, given Google's agenda to push Kotlin. Android 13 is surprisingly adopting more Java 11 features, most likely because they need compatibility with Java libraries that have moved beyond the Android Java subset.
- bitcharmer 5y agoI hate that they obsoleted CriticalJNINatives and gave nothing as an alternative. For my industry it's a serious performance regression.
- azth 5y agoPanama?
- bitcharmer 5y agoSadly yes. We'll have to stick to jdk17 for now because of that. Hopefully Panama delivers one day.
- criddell 5y agoWhat's your favorite toolkit for desktop Java applications? I believe JetBrains use Swing and their stuff is pretty great.
- native_samples 5y agoJavaFX by far. The API is probably the nicest I ever used of any toolkit, it's got a lot of features, is maintained by multiple companies, is mature, has a well integrated WebKit control, good multimedia support, can do 3D effects, uses CSS, has a UI designer, is stable, runs on embedded, mobile, desktop and can be "projected" to web browsers using JPro, and most releases are just bug fixes these days. Currently fully FRP UI is quite popular (Jetpack Compose, ReactJS etc) but frankly whenever I've read such codebases I've been somewhat unimpressed. You can make JavaFX work that way with a bit of extra utility code, and there are places where that approach makes sense, but fundamentally a well engineered OOP UI toolkit is in its element. The functional reactive approach seems to create quite a few problems. Whether it creates as many as it solves, I reserve judgement as I haven't had a chance to write a large GUI app since they came out. Still, I've written a lot of them in the past and would definitely be tempted to stick with JavaFX despite having worked through the Jetpack Compose tutorials.
- criddell 5y agoI think Jetbrains are a great example of Swing done right, who's doing the same with JavaFX?
- native_samples 5y agoBrowse through the app gallery at https://www.jfx-central.com/home https://www.jfx-central.com/home (note: jfx-central is itself a JavaFX app, again running with JPro to be projected over the web, but you can also download it and run it locally).
- nsxwolf 5y agoThe simple HTTP server is a nice addition. I end up using python's SimpleHTTPServer for all sorts of things so it will be nice to have an alternative right in the JDK.
- ianopolous 5y agoEver since Java 11 enabled running single Java files directly without compiling them I've been using my own trivial single file web server for this purpose: https://github.com/ianopolous/simple-http-server https://github.com/ianopolous/simple-http-server
- nsxwolf 5y agoI did not know about this direct execution trick!
- pie_flavor 5y agoI gotta say, I'm impressed with what they put together for the FFM. Previous iterations were terrible, in the way only Oracle can. In particular the ability to upcall and to manage mostly-safe handles off-heap with a declarative API is pretty nice. However, if I understand this correctly, FFI calls are going to be limited to modules explicitly authorized on the command line, which blows and defeats the purpose of having all this safe stuff being required instead of manipulating pointers directly. I assume there's some kind of reason for this but it seems like it's just going to be extra noise limiting time-to-hello-world without benefit. It still remains the most relevant part of P/Invoke that it's so performant and clean that the standard library makes all its syscalls with it, rather than getting magic backdoors from the runtime.