9 ms·
Migrating from Java 8 to Java 17: A Comprehensive Guide to New Features
- sgammon 2y agoNew features… ? We are on Java 22
- atorodius 2y agointeresting how all languages evolve a „record“ construct.
- MichaelNolan 2y agoIs there a reason you choose to go to 17 but not to 21? 21 is also a LTS version.
- hiAndrewQuinn 2y agoThe latest version of The Well Grounded Java Developer was released in 2022, when 17 was the latest LTS version. The high quality of that book and being able to prescribe it is one reason why someone might prefer it. I think OpenJDK 17 might also the highest LTS installable one on Debian 12 out of the box right now, but that's a lot less certain.
- piperswe 2y agoIndeed, OpenJDK 21 isn't available in Bookworm's repo, just Sid's: https://tracker.debian.org/pkg/openjdk-21 https://tracker.debian.org/pkg/openjdk-21
- lye 2y agoAs far as I'm aware, the only officially supported way of shipping Java applications is by building custom runtimes with jlink. So if you want to play by the rules, it doesn't matter what the distributions ship. Ubuntu ships multiple runtimes for every supported distribution and does backports FWIW.
- hiAndrewQuinn 2y ago`jlink` was released for Java 9, I believe, so it's unlikely people who are upgrading from Java 8 already have the infrastructure in place to seamlessly transition to that instead of however they were managing their JAR files before. "But this should be simple! It's almost like a Go binary!" I've learned not to underestimate how long it can take to change infrastructure. DevOps isn't seen as a profit center in most places, and they might well have much bigger things to worry about than transitioning from a kind of working JARs-on-VMs approach.
- vips7L 2y agoJlink/jpackage UX isnt the best either. They mostly produce installers not a single binary that you can just run. Project Leyden has some interesting work around this called Hermetic Java which plans to ship one binary with the VM + jar together. It’s coming out of some folks at Google. I’m really looking forward to it.
- hiAndrewQuinn 2y agoReally now? Now that's interesting. I thought GraalVM might be a good option in that space https://www.graalvm.org/ https://www.graalvm.org/ last I checked, but something literally called Hermetic Java has my interest piqued.
- ydant 2y agoIf you're using AWS ElasticBeanstalk Tomcat distribution, 21 isn't supported yet. I realize this isn't a huge segment of the market, but it's probably not the only example. https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.java https://docs.aws.amazon.com/elasticbeanstalk/latest/platform... 21 is supported for Amazon Linux 2023 and the JavaSE ElasticBeanstalk offering, though.
- kernal 2y agoSome large application servers may not support Java 21 yet.
- neonsunset 2y agoThe payment processing case is nostalgic if a bit ironic, the team I worked at used this exact pattern 6 years ago or so in C#, and the expressiveness has only improved since then.
- lye 2y agoYes, C# is better by every measure and has had everything we can only dream of for decades. You can stop coming to every discussion of Java with the same old story.
- Alupis 2y agoThe problems with C# are many. It's tied to .NET at the hip - there are no 3rd party implementations (Mono is effectively dead, correct me if I'm wrong), it's development is effectively solely driven by Microsoft, and every few years you have to rewrite all your things or get stuck on EOL versions of frameworks or abandoned tooling. The community is also vastly different in that it does not (yet) value open source and many different implementations of ideas (ie. there's an official Microsoft way to do X and that's what everyone does). C# might be a fine language, but it's coupling to .NET and Microsoft are kind of a liability. Java has a ton of warts, and it's not the language I'd choose today. However, it's ecosystem is FOSS-first and is immense in size and scope, has numerous options for any type of library/framework (take a loot at HTTP clients, or logging frameworks, or web frameworks, etc), and while Oracle primarily drives development they don't get the de facto final say anymore. There's also many JVM implementations and many class library implementations - all with different pro's and cons. Perhaps .NET will get there one day. It is, after all, relatively new at FOSS/XPlat.
- neonsunset 2y agoAt least the company driving .NET releases it under MIT and does not have a trap SDK that should you make a mistake of using makes your company liable to legal action by Oracle. Surely you're not gonna say that OpenJDK and GraalVM (both owned by Oracle) is somehow an issue, would you? And Mono lives well in dotnet/runtime, serving targets like Browser WASM and iOS (until NativeAOT replaces it in full at that target, at some point). But you're not using .NET, so no need to worry. No one is gonna pry Java from your hands, but we'll get to laugh at the choice - it is both slower in performance-oriented code and more verbose in LOB one. Pretty much the only driving reason behind choosing it is if the company is an Apache/Java shop or when a vendor offers an SDK in Java/Python/JS only due to their popularity which is a common issue in the industry.
- swayvil 2y ago[flagged]
- oneepic 2y agoWhat's the motivation behind going to an article about a language upgrade, then proceeding to shit on language features that have been there even before Java 8?
- swayvil 2y agoAn expression of disapproval is shitting now?
- playingalong 2y agoJava without generics was a pain. By today's standards I wouldn't even call it a statically typed language.
- CobrastanJorji 2y agoThis is an article about going from Java 8 to 17. Generics and annotations are from Java 5. Java's implementation of generics isn't great, but there are some professional coders out there who were born after generics and annotations were added, so it's probably time to let that one go.
- sgammon 2y agoBecause you’re wrong, that’s why. Generics really aren’t that bad. And people forget that Java generics came before many other languages.
- Clamchop 2y agoNeither of your examples distinguish 8 and 17, and a few things highlighted in the article that do can only be said to make things simpler and easier, like records and text blocks.
- mrkeen 2y ago> Keep my language simple. Yep. Why class when record does job? Why polymorphic dispatch when pattern-matching does job?
- joshlk 2y agoWhy the large jump from Java 8 to 17?
- sgammon 2y agonext LTS is 11, which I believe is already out of support, so 17 would be the next logical LTS.
- ebiester 2y agoMany organizations are stuck on Java 8 because Java 9 made breaking changes. (Java 11 also made breaking changes.) Many of these changes also broke some popular libraries at the time that hacked into the JDK internals, so it meant a significant refactor for software that might be in maintenance mode already.
- joshlk 2y agoIs this analogous to the Python 2 to 3 jump?
- papercrane 2y agoIt isn't that severe of a break. Most of the friction was with the libraries with transitive dependencies, like ASM, that depend on a particular bytecode version, using internal classes that were removed (e.g. sun.misc.BASE64Encoder), or the new module system encapsulating APIs that were intended to be internal-only (usually fixable with JVM runtime flags.) A lot of organizations that use Java are very conservative with their tech changes, and didn't see a compelling reason to upgrade. This was especially true since Android Java still used Java 8, so many popular libraries continued to support Java 8 for their Android userbase.
- sgammon 2y agoNo. Java 22 will happily execute code built for Java 6.
- vips7L 2y agoTo clarify Java made changes to things they never promised would be a part of backward compatibility. Libraries were using things from JDK internals/implementation details, things that were never guaranteed to be there.
- xyst 2y ago[flagged]
- Alupis 2y agoTry Kotlin. It's what modern Java should be, and might eventually slowly (slowly) develop into. It's a joy, and can use the entire JVM ecosystem (frameworks, libraries, tooling, etc). The C# folks can't even knock it... it's less verbose and more functional. Kotlin + Spring Boot for backend work is the way...
- jimbokun 2y agoSprint Boot is the part of the Java ecosystem I most want to escape from.
- Alupis 2y agoFair - good thing there's like a dozen web frameworks you can choose from. Find one you like and run with it.
- jimbokun 2y agoI love Javalin for new projects! But have too much code in Spring Boot to ever justify rewriting all of it.
- Alupis 2y agoThanks for naming Javalin - I had not previously heard of it and it appears quite nice. I will say though, I vastly prefer pushing configuration out of my code and into config files/text. Things like `Javalin.create { config -> config.useVirtualThreads = true }` in my opinion should live in a config file. But, to each their own - that's the beauty of the JVM ecosystem - lots of choice and lots of ideas.
- jimbokun 2y ago
- mjfl 2y agoJava is a good, fun language that gets the job done.
- 1234554321a 2y agoGood for both everything and nothing at the same time.
- LoganDark 2y agoIt's really good at causing pain
- mrkeen 2y agoWeird example with the "Java 8 exception handling": catch (Exception e) { if (e instanceof IOException) { } else if (e instanceof SQLException) { } else if (e instanceof NumberFormatException) { } else { } } Older Javas already allowed choosing which Exceptions (and subclasses) to catch directly.
- deleted 2y ago[deleted]
- whartung 2y agoI love Java, I love the ecosystem. It's been a 25 year journey. I will be the first to admit that I have not adopted "modern Java", mostly with all of the functional stuff (notably all of the collection streams and what not). I certainly enjoy easy lambdas, but I don't necessarily code stuff up that way. I'm not big on locked down classes, as a general rule. I won't say I never use "private", but it wouldn't bother me if that didn't exist. I can't say I'd "never" use records, but I'm so used to the boiler plate, I don't really see it any more. My one issue, though, is simply how heavy handed the Java 9 module system is. I have a desktop app, and I use the module system to lighten up the JRE that it bundles. But that's an edge case (to me). I'm just not a fan of it, I find it gets in the way more than anything, and it just seems more forced than optional. Outside of building JREs, does anyone use the module system for anything?
- MichaelNolan 2y agoMy understanding is that the module system is primarily for library developers and not application developers. You can use the module system to strongly encapsulate your internals, which allows you to change those internal implementations without having to worry that some client is depending on it.
- vips7L 2y agoIt’s for both really. The module system comes into play when application developers what to ship a jlinked runtime. You can make the size of your JVM executable down to like 35MB or smaller.
- kernal 2y agoGraalVM uses it to build its native executables.
- gergo_barany 2y agoYou can build GraalVM native images from modularized code, but you can also build them from non-modularized code.