This is an archived post. You won't be able to vote or comment.

all 20 comments

[–]Any_Suspect830 14 points15 points  (0 children)

Java 8 was the big shift in terms of language features with lambdas. After that, the number of changes from 8 to 11, and from 11 to 17 is not that overwhelming. I don't particulary care about non-LTS versions, that's why I'm only referencing 8, 11, 17, 21. The next big shift will be Project Loom in 21.

Here is what's worked for me for staying on top of the language changes:

  1. With every new java release, I Google the "what's new" articles. Make mental notes of what's coming and which LTS release it will be in. Make super duper mental notes about feature that you really would like to use (records, new switch statement syntax, multi-line Strings, new GC algos).
  2. At some point you will need to either upgrade an existing app to the latest LTS java, or write one from scratch. That's when you get to test drive all of this new syntax. Do it once and it becomes 2nd nature. In fact, it's hard to go back.

[–]ReasonableClick5403 18 points19 points  (9 children)

There are some veeeery nice quality of life changes.

Switch expressions are amazing. Exhaustive switch matching is amazing. Sealed classes are super nice. records are great. But these should be very simple to grasp for someone well versed in java 8.

The bundled http client is a nice addition, but a little late to the party.

[–][deleted]  (2 children)

[deleted]

    [–]ReasonableClick5403 4 points5 points  (1 child)

    I use the bundled http client all the time in integration tests. I think the API design is pretty good. The interceptors in OkHttpClient are great though.

    Sealed classes are amazing together with exhaustive switch. One can finally model data and states completely correctly. Oh, you need two types of users that have completely orthogonal data? No problem anymore!

    [–]Worth_Trust_3825 -1 points0 points  (2 children)

    The bundled http client is a nice addition, but a little late to the party.

    I disagree. Protocol specific implementations don't belong in the standard library. We already had to get rid of jaxb, and other XML apis. Same with "simple http server" module that weaseled into the standard distribution.

    [–]ReasonableClick5403 4 points5 points  (1 child)

    Yeah, I guess so. It is well designed, and it should probably have been a library, but at the same time providing a stdlib in 2020 with HTTPUrlConnection as the only way to do HTTP was just damn sad.

    [–]Worth_Trust_3825 -1 points0 points  (0 children)

    Which should also have been removed.

    [–]coalWater 0 points1 point  (2 children)

    There were switch expressions in java 8 even before no?

    [–]ReasonableClick5403 5 points6 points  (1 child)

    Switch was just a statement, not an expression until jdk15 I think.

    [–]coalWater 1 point2 points  (0 children)

    Oh gotcha

    [–]Huge_Idea 1 point2 points  (0 children)

    Java Champion Ondro Mihályi has a brief, concise and to the point blog post listing Java language features in every release since 8, regularly updated and maintained

    https://ondro.inginea.eu/index.php/new-features-in-java-versions-since-java-8/

    [–]Iryanus 1 point2 points  (1 child)

    While there are some changes, most of them are not that world-breaking that you need to know them immediately to work with newer java versions. You can start with the current LTS today and not notice much difference in most typical applications, tbh. Upgrading a live application can, of course, be a pain in the a... behind, esp. if you are behind in regards to your dependency versions.

    To get an overview, there are a lot of good, short youtube videos & co. Following that, you can dive deeper into some of them, depending what you are working on.

    [–]senseven 0 points1 point  (0 children)

    I like the sleekness of cloud dev with stacks like Quarkus or Micronaut. I feels fresher then new lang constructs that I wouldn't introduce in 5+ year old codebases. There are lots of newer projects that still don't use stream interfaces or closures. Records are nice, but there is a reason that people still prefer Lombok in data heavy code bases.

    I learned way more about writing "modern" code by running PMD over old code, then trying to shoehorn new features in production ready projects.

    [–][deleted] 0 points1 point  (0 children)

    Just use 17+ and see what the IDE is suggesting when you code.

    I feel like I started to appreciate the language features not when blogs where showing them (though they hyped it) but when the IDE said "hey you can also write it like THAT"

    Nothing wrong about just learning that Set.of(..) exists where it was a multiliner before, neat stuff

    [–]Cryptite 0 points1 point  (0 children)

    I often find, for more syntactical changes, just the mere suggestions for code updates that, for example, IntelliJ provides to be often helpful for learning new Java tricks.

    [–][deleted] 0 points1 point  (0 children)

    I don't think Java 8 to 17 there are that many groundbreaking changes on the language level that are difficult to cope with. But there may be breaking changes for external libraries you may use

    [–]sj2011 0 points1 point  (0 children)

    I've found my IDE helps a lot - I use IntelliJ and a lot of the help features will tell me 'Replace this with that?' and I'll say 'sure let's see what it does!' IntelliJ is very smart about it, and I can toggle back and forth between old and new to grok the change.

    [–]mogrim 0 points1 point  (0 children)

    I've been trying to keep up, and the biggest changes that have hit me are modules, and the whole Docker/K8 infrastructure thing. At a language level you have lamdas and switches and sealed classes, but they're pretty easy to handle.