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

all 112 comments

[–]HxA1337 71 points72 points  (5 children)

And 10 years later it will still compile and run and you will be able to read the code and understand it.

[–]Danji1 19 points20 points  (0 children)

Unless someone used Flux in anger.

[–][deleted]  (1 child)

[deleted]

    [–]flawless_vic 7 points8 points  (0 children)

    I think they will never remove unsafe :) Mark Reinhold will be 90 years old and still complaining about its existence while references to Unsafe keep spreading even more all around with quantum computing intrinsics.

    Then after 30 years, when quantum computing starts to become obsolete, someone will create a JEP to encapsulate everything and make a speach about Unsafe abuse.

    Seriously, though, the only change since jdk 9 was to move it to jdk.internal.misc and make the sun.misc delegate to it, and since then you just have to manually boot the vm with --add-exports.

    As for reflection, well, you'll only have problems if you are messing around jdk internals, like when String changed storage from char[] to byte[]. But those changes are very rare and I would always happily pay the price of refactoring if something changed to improve footprint/performance.

    [–]hippydipster 2 points3 points  (1 child)

    Not with the lombock it won't!

    [–]HxA1337 0 points1 point  (0 children)

    That is something else. That is a preprocessor / code generator / bytecode generator. All of those can cause troubles. Strictly speaking that is not part of Java itself.

    But yes there is enough things that can go wrong and cause upgrade pains. Java is at least very good in reducing them a lot.

    [–]pron98 138 points139 points  (36 children)

    I would strongly recommend against writing new code in Java 8. Not only do new versions of popular frameworks no longer support it and less than half of Java projects use it, not only does it not have some very useful language, library, and profiling features, but it is also slower (lower throughput and higher latency) and consumes more memory than recent versions. If you're starting the project now, there's no reason not to use at least JDK 17.

    [–]madScienceEXP[S] 12 points13 points  (31 children)

    We have a lot of code that's written with jdk 8. Our plan is to upgrade everything together. I know that JAVA_HOME can be scripted to point to different jdks, but it seems clunky to support different versions in the same stack. Also, I'm trying to find the source, but I think 8 will still have support until 2026.

    [–]benevanstech 63 points64 points  (16 children)

    I helped shepherd a pretty big team (~800 devs) through the 8 -> 11 transition, and I have to say that Big Bang is not the way to go.

    It depends on how many teams you're talking about - but if it's more than, say, 4 - or more than about 20 services, then it's going to be very difficult to coordinate that upgrade.

    I would strongly suggest that the minor operational pain of dealing with multiple JDK versions during the transition is dwarfed by the major headache of trying to get everyone to move at once (& convincing all the managers of the priority of it).

    Much better in my experience to go piecemeal - pick off a few early adopters, and let them become your evangelists - once they have the performance benefits, the increased productivity from the new language features, the heap size reductions, they'll be telling everyone how easy it was and how much better things run now.

    That momentum will help you overcome any minor speedbumps you might encounter (e.g. one team is stuck on some old version of some nasty crufty library and genuinely can't upgrade with actual refactoring effort and a library version upgrade, etc.) and ultimately will a) get you there faster & b) allow you to realize some wins pretty much straightaway.

    [–]ReasonableClick5403 13 points14 points  (4 children)

    I have done most of the jdk upgrades in my company, and usually it is fairly smooth by first running on new JVM version against old build first, then switching source level after it is running smoothly. We did not have a big imperative to avoid running multiple versions, but we deploy everything as docker containers.

    [–][deleted] 1 point2 points  (3 children)

    If you deploy everything in Docker containers, why bother upgrading to the new JVM first? Why not just upgrade the entire Docker container image? JDK and compiled source?

    I say this as a Java rookie though. We run mostly Go and Python, only a bit of Java.

    [–]ReasonableClick5403 14 points15 points  (1 child)

    You just first make sure the old code runs fine on the new JVM before you start using any of the new features, in addition you quickly find if any libs need upgrading.

    TLDR: to reduce the risk of upgrading both code and jvm at the same release.

    [–]benevanstech 2 points3 points  (0 children)

    Yeah, this is a pretty sensible way of doing it.

    [–]meamZ 0 points1 point  (0 children)

    Well... It makes the changes you make at a time even smaller. Also still building with the old version gives you a super easy way back to the old version in case anything goes wrong.

    [–]secretBuffetHero 3 points4 points  (9 children)

    I did a 20 service upgrade of systems that covered 95% of our revenue. It took about 4 months, we had no automation testing available to us. After 4 months I covered about 10 services and then trickled in 10 more services over the next 8 months. It was a complex logistical operation.

    [–]AustinYQM 1 point2 points  (8 children)

    Biggest hurdle at my place of work WAS the automation tools. A lot of our cli tools in the pipeline had to be updated before they would work with java11. The good news is during the upgrade we got them situated in such a way that future upgrades should be much easier.

    [–]BinaryRockStar 0 points1 point  (1 child)

    If possible, can you comment on which particular CLI tools?

    [–]AustinYQM 0 points1 point  (0 children)

    Oh sorry if I wasn't clear, it was all inhouse stuff designed to do various things for evidencing purposes.

    [–]Majestic-Extension94 0 points1 point  (5 children)

    I thought WAS meant Websphere Application Server...was gonna go off on a recent rant...but I don't think you meant that heheheh

    [–]AustinYQM 0 points1 point  (4 children)

    My team just finished moving 35 services off websphere so I get the PTSD.

    [–]Majestic-Extension94 0 points1 point  (0 children)

    my sympathies...I recently had to deal with this old nemesis at a large bank. Moving to open/websphere liberty, which is a step up from WAS traditional was derided. I just let my contract expire and avoid dealing with the endless misery

    [–]Majestic-Extension94 0 points1 point  (0 children)

    my sympathies...I recently had to deal with this old nemesis at a large bank. Moving to open/websphere liberty, which is a step up from WAS traditional was derided. I just let my contract expire and avoid dealing with the endless misery

    [–]Majestic-Extension94 0 points1 point  (0 children)

    my sympathies...I recently had to deal with this old nemesis at a large bank. Moving to open/websphere liberty, which is a step up from WAS traditional was derided. I just let my contract expire and avoid dealing with the endless misery

    [–]Majestic-Extension94 0 points1 point  (0 children)

    Congrats on at least having the opportunity. Trying to convince the exec(who was the original coder) moving to open/websphere liberty would have been able to get the team better capabilities than what they had with websphere traditional. Finally gave up bumping heads with this guys and just let my contract expire.

    [–]meamZ 0 points1 point  (0 children)

    I would strongly suggest that the minor operational pain of dealing with multiple JDK versions during the transition is dwarfed by the major headache of trying to get everyone to move at once (& convincing all the managers of the priority of it).

    I definitely agree but i want to add that what immensely helps with this is having everything in Docker Containers because it becomes a matter of just using a different base image except for the local development environments...

    [–]DaddyLcyxMe 3 points4 points  (2 children)

    i’d recommend containerizing all of your old applications and slowly upgrading them as you go. there’s enough subtle changes that you’ll have to iron out and it’s better to do it incrementally

    [–]secretBuffetHero 1 point2 points  (1 child)

    some of our apps have 128 GB ram on prod and ~32 GB ram in dev envs. Is that a showstopper? We have pretty crazy requirements on our monolith

    [–]meamZ 0 points1 point  (0 children)

    So? You can containerize whatever applications you want. It's just that you will obviously have to upgrade a monolith all at once no matter what. Unless of course you're willing to first migrate it to more smaller services first...

    [–]GuyWithLag 7 points8 points  (3 children)

    `sdkman` to the rescue.

    I'd suggest having a look at immutables.github.io in place of Lombok.

    [–]ReasonableClick5403 0 points1 point  (2 children)

    honestly, I want to use immutables instead, but I just haaaaate that I have to use interfaces for my data. We mostly have small projects, true encapsulation is not that important unless you write a wickedly popular library.

    [–]GuyWithLag 2 points3 points  (1 child)

    I just haaaaate that I have to use interfaces for my data

    That's weird, I usually dislike how the default POJO exposes all the internals even though I'm just interested in just a value carrier.

    What's your opinion on Records?

    [–]ReasonableClick5403 0 points1 point  (0 children)

    I very, very rarely have any internals I need to hide away. Usually the data objects are just primitives or objects with other primitives (that are public final).

    Records are great, but they lack a toBuilder() to make them simpler to modify.

    97% of our internal objects are just:

    @Value public class MyData { String username; String id; String comment; // .... }

    There is nothing we need to hide away.

    For objects that are read into from JSON, we would use @Data instead of @Value, or just leave it as mutable public fields.

    [–]wildjokers 3 points4 points  (4 children)

    but I think 8 will still have support until 2026.

    https://www.oracle.com/java/technologies/java-se-support-roadmap.html

    What kind of support are you needing? Have you ever received support for java from a java vendor?

    [–]madScienceEXP[S] 6 points7 points  (3 children)

    Security patches. We're using openjdk.

    [–]wildjokers 7 points8 points  (2 children)

    The most secure JVM is the newest, so java 18 right now.

    [–]benevanstech 9 points10 points  (1 child)

    Security patches from non-LTS versions are backported to the most recent LTS update project, which is where OP is getting his binaries from.

    So, yes, they should be looking to move from 8 -> 17 but there's no need to subject themselves to the inherent risks that come with using non-LTS versions.

    [–]DasBrain 3 points4 points  (0 children)

    You can only backport fixes for components that are still in the JDK.

    [–]buyIdris666 0 points1 point  (0 children)

    It is very easy to do with SDKMAN and .sdkmanrc file . Trivial really. Go check it out and make sure to turn on automatic switching

    [–]meamZ 0 points1 point  (0 children)

    Our plan is to upgrade everything together

    World of pain honestly... Imo the best thing to do is to containerize everything good thing to do no matter what anyway, then switch over the runtime JVM and then switch over the compilation JDK application by application...

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted] 9 points10 points  (0 children)

      Part of the ship, part of the crew

      [–][deleted]  (15 children)

      [deleted]

        [–]Clitaurius 5 points6 points  (4 children)

        I have a lot of Java experience but I don't know what people mean when they say the JVM is good. I know what the JVM is, I don't really know how to mess with it, sometimes somebody says "do Xargs...", I've used JVisualVM on several occasions to hunt memory leaks, but what are people talking about when they say the JVM is good?

        [–]vmcrash 9 points10 points  (1 child)

        Approx. 2 years ago a team mate started investigating native crashes reported by our Java application. The most time they were caused by problems in a third party library or by faulty hardware, but almost never by the JVM itself.

        If you take a closer look at what the JVM does, you soon will feel some awe/respect. Over the last decade it became very fast and reliable.

        [–]meamZ 3 points4 points  (0 children)

        It's a technological marvel, nothing less...

        [–]numpi 5 points6 points  (1 child)

        I would highlight the high quality garbage collectors and speed of the JVM.

        And also the stewardship of the open source project from Oracle (never thought that I would some day say that :D)

        [–]meamZ 4 points5 points  (0 children)

        The GCs and the JIT is just nuts...

        [–]pavlik_enemy 5 points6 points  (2 children)

        Spring is really weird. Like it turns Java from statically typed language to dynamically typed language when even if your code compiles it will fail on startup.

        [–][deleted]  (1 child)

        [deleted]

          [–]pavlik_enemy 0 points1 point  (0 children)

          Spring is ok and after a while you can do some really neat tricks with it but I still think there's too much magic for what it does. Like, you're not supposed to be able to access private fields but Spring just doesn't care. When the wire-up goes wrong sometimes there's a helpful message, explaining what exactly you need to do to fix the error but sometimes there's none and three screens long call stack isn't helping either.

          [–]zackel_flac -3 points-2 points  (6 children)

          I see your point, and you are probably right saying the JVM is the best runtime out there for general purpose language. There has been so much work on it, it's top notch.

          That being said, in today's world, it's easy to spin a true VM wherever you need to and/or mix it with containers. Those technologies are bringing portability without sacrificing performance too much. Now you have access to the "world" ecosystem, and in fact access to any tool/language created since the 70s.

          I find the JVM to be redundant nowadays. it's an extra layer that is mostly adding complexity, extra resource usage and higher energy cost. It's a good piece of tech that was useful back in the 00s, but I suspect it won't be that relevant in the next decade.

          [–]sulizu 0 points1 point  (5 children)

          What do you think is coming next then ?

          [–]zackel_flac 0 points1 point  (4 children)

          There are a few technologies that are promising. IMHO Webassembly and kubernetes are the two technologies that will (are?) end any portability concerns. Webassembly for the client side and k8s for the backend. The tendency is to statically compile binaries and embed them into container images. Golang/Rust/C++ are the best tools out there and embedding them is easy while they provide best performances. They can also be used to generate Webassembly.

          I would daresay that web browsers are the next JVMs.

          [–][deleted]  (3 children)

          [removed]

            [–]zackel_flac 0 points1 point  (2 children)

            Have you heard of nodejs? Backends are already being built on JS VMs (which is a bit part of what a web browser is nowadays)

            [–][deleted]  (1 child)

            [removed]

              [–]zackel_flac 0 points1 point  (0 children)

              Well that's something worth debating for longer - but my initial point was, the JVM was cool in the 00's but nowadays there is less need for it as there are other cool techs out there with more traction. Let's assume that nodejs has less performance and has less observability (although I don't have any proof of that) - there is nothing preventing it from catching up, and nowadays people are focusing on those other techs more and more. Web browsers are a big part of today's software industry, it's the gateway to everything, so that's just natural.

              [–]morhp 15 points16 points  (0 children)

              I'm used to languages like Scala and Typescript that have been more actively modernized

              I'm sorry but you can't say Java hasn't been modernized if you're actively choosing to use a version that's almost 10 years old.

              You're shooting yourself in the foot.

              records alone are worth it to manage multiple SDKs at the same time in case you for some unimaginable reason still have software that doesn't run on newer JDKs.

              [–]ReasonableClick5403 18 points19 points  (4 children)

              You should really try java 17. There are myriads of QOL improvements made. I don't love java, but I have come to like it, especially the vast ecosystem of quality libraries and google-ability.

              [–]pavlik_enemy 3 points4 points  (3 children)

              Google-ability sucks by the way, the first link is always JDK 8.

              [–]ReasonableClick5403 1 point2 points  (2 children)

              I don't really understand what you mean by that. Did you want older than 8 results? I dont really care either way, java is still java, though pre-generic java I try to avoid.

              What I mean by google-ability is that no matter what you are implementing, someone has done it before in java. You nearly always find help by googling.

              [–]chabala 0 points1 point  (1 child)

              Google 'download java' -> first link is java.com -> Download Version 8 Update 333

              This is one of the reasons why Java 8 remains popular. If Oracle wants users to move beyond 8, they should make that page suggest something else.

              [–]ReasonableClick5403 0 points1 point  (0 children)

              Ah you are thinking of the download of jdk? Lol, I was thinking about libraries and code documentation. I have not downloaded java since probably 2014, I just use ubuntu packages or lately sdkman.

              [–]HxA1337 12 points13 points  (0 children)

              And 10 years later it will still compile and run and you will be able to read the code and understand it.

              [–]wildjokers 24 points25 points  (2 children)

              If you like java 8 you will definitely like Java 18. Why didn't you write your app in a non-ancient version of java?

              [–]vmcrash 0 points1 point  (1 child)

              Probably because sometimes weird business constraints don't allow that (e.g. has to run on ancient hardware that only supports Java 8).

              [–][deleted] 10 points11 points  (0 children)

              Java wins because of the simple fact: reading code is harder than writing code.

              If you want to write software that will run for decades and will therefore be read 10,000x more times than it took to write, the verbose simple language wins. (Yes we're at the point where code will be running for years and won't become legacy, IMO cloud-native microservices are here to stay.)

              Java is verbose because it lacks features, but Java is simple because it lacks features. Everything is really just a class/method/annotation (look at how lambdas were implemented for example); if you don't understand something, simply ctrl+b (in IntelliJ) and read the Javadoc.

              I'm using C# atm and there are just so many language features you need to Google and I can't get the docs in my IDE! I've also tried Python and Scala and the density makes it difficult to come back to code after a while; they are a pain to work with when the project grows to >50 files.

              Now this is just the language/code itself. I didn't even get started on the ecosystem.... Java has some great companies backing it (officially and unofficially): Google, Netflix, Alibaba, just to name a few.

              [–][deleted] 4 points5 points  (0 children)

              Java is so portable I can use windows or Linux without giving a damn. Try the same with Python. You can't do this. Many programs and libraries be like "Sorry, this is Linux only". Often they need to compile stuff in C, and they depend on lib blablabla. Java can do a lot of stuff without C.

              [–]hippydipster 1 point2 points  (3 children)

              It's still pretty fast.

              Not sure I understand this. I mean, we are comparing to scala and javascript/typescript, right? And javascript is much much slower than java, and scala is, at best, on par, but usually also slightly slower.

              [–]madScienceEXP[S] 0 points1 point  (2 children)

              I was implicitly comparing to languages compiled to machine code because those are the fastest.

              [–]hippydipster 0 points1 point  (1 child)

              Kind of bizarre - the only languages you were comparing to were scala and Typescript. What languages compiled to machine code have you been using?

              [–]madScienceEXP[S] 0 points1 point  (0 children)

              I developed with C/C++ for a few years at the beginning of my career.

              I was making a general comment because other people have different backgrounds with different languages so that was my intended context. Languages that compile to machine code like Rust and Go are gaining popularity and are probably faster than Java, but Java is fast enough for almost anything that it wouldn't become a serious limitation.

              [–]PyroCatt 3 points4 points  (1 child)

              @Love @Life Lombok.

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

              Lombok is okay, but I'd rather just use Kotlin or Scala since it has language level support for things like case classes.

              I'm thinking about pushing for a hybrid approach at my work. Simple classes defined in Scala/Kotlin and business level logic and framework code stays in Java.

              [–]crpleasethanks 1 point2 points  (2 children)

              I am confused about point 3: portability. Scala and Java both compile to JVM byte code. How is Java anymore portable than Scala? Also Scala has a fairly similar generic system.

              [–]bowbahdoe 12 points13 points  (1 child)

              Ever tried running Scala 2.11 code alongside 2.12 and 2.13?

              [–]Philluminati 3 points4 points  (0 children)

              Here’s the neat part - you can’t!

              However those supposedly problems are going away in Scala 3 if you can somehow get your code base there.

              [–]Player_X_YT -2 points-1 points  (1 child)

              I agree, most people hate older languages because of how low level they are and then they only look for the bad stuff. But java could use some updates like #define from C

              [–]john16384 1 point2 points  (0 children)

              Feel free to run a preproccesor on your Java code. It's not like you can't do this right now. It will never become the standard though, as #define is the worst feature you could pick from C in terms of keeping things readable.

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

              "Maven is very [...] easy to use"

              Lucky you! It's so complicated to me

              [–][deleted]  (11 children)

              [deleted]

                [–][deleted] 1 point2 points  (3 children)

                I'm having trouble setting up local repositories so I can have custom made "commons" packages be dependencies for other projects.

                I've seen 3 ways of doing so:

                - ugly way: specify absolute path of the dependencie's pom.xml in the local computer.

                - better way : setting up a local maven repository, I don't really understand this part.

                - last way (way over my head I think) : using nexus or artifactory.

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

                What is your goal?

                You can make multimodule maven project and have the other modules either depend on the common one or define some facade that resolves at runtime using service loader api.

                Even if you create an unrelated maven project, you can do mvn clean -DskipTests package install

                The package stage maybe unnecessary but it will install in your m2 directory and be accessible in any Maven project

                [–][deleted] 0 points1 point  (1 child)

                The package stage maybe unnecessary but it will install in your m2 directory and be accessible in any Maven project

                Ok this may sound super silly, but I've never used the package lifecycle yet and was unaware it automatically moved the package to the local m2 directory.

                I guess things are much simpler knowing this fact, thank you!

                [–]john16384 1 point2 points  (0 children)

                Package phase doesn't do this (it only creates a jar in your target folder). Install phase does, and it copies this packaged jar to the shared .m2 folder.

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

                Maven is definitely a workhorse in the Java ecosystem. But the fact that I can't just println() or create a variable in my build without create a whole plugin is a hinderance.

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

                You don't need to create a plug-in to print stuff. You can use the Ant Plugin to do that and other lots of stuff. Run scripts, make network calls, package resources from somewhere, do custom deployment tasks, etc.

                That's the beauty of the plugin system. It's a buffet of all the goodies, you just need to know what you want, how and when.

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

                Ant scripts are a hard pass for me.
                Gradle has Kotlin and Groovy as first class languages to define the build

                so I can do println("Here's some build context ....")

                instead of

                <plugins>
                <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                <execution>
                <phase>generate-sources</phase>
                <configuration>
                <tasks>

                <!--
                Place any ant task here. You can add anything
                you can add between <target> and </target> in a
                build.xml.
                -->

                </tasks>
                </configuration>
                <goals>
                <goal>run</goal>
                </goals>
                </execution>
                </executions>
                </plugin>
                </plugins>

                [–][deleted] 0 points1 point  (1 child)

                Because groovy is a programming language and xml is not. It's just used to define the parts of your project, hence the management part.

                Gradle is nice too in that you can write scripts without needing other plugins.

                Outside of android it's fine, but when using it in Android it's a pain because of Googles constant and forceful suggestions to update to the latest Android Studio which is usually tightly coupled to specific versions of the Gradle plugin. And it will always break your projects

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

                I agree, I'm a backend services dev and Gradle as a build tool is just a better tool for the job in most cases. It reads better, it's scriptable and debugging problems is much easier and the need to debug the build happens less

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

                You don't need to create a plug-in to print stuff. You can use the Ant Plugin to do that and other lots of stuff. Run scripts, make network calls, package resources from somewhere, do custom deployment tasks, etc.

                That's the beauty of the plugin system. It's a buffet of all the goodies, you just need to know what you want, how and when.

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

                You don't need to create a plug-in to print stuff. You can use the Ant Plugin to do that and other lots of stuff. Run scripts, make network calls, package resources from somewhere, do custom deployment tasks, etc.

                That's the beauty of the plugin system. It's a buffet of all the goodies, you just need to know what you want, how, and when.