In this article, we’ll debunk the notion that Java is a relic of the past and showcase the language’s modern features, thriving ecosystem, and unwavering presence in enterprise and open-source communities.

  • sizeoftheuniverse@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    Yes it does, the only parts where Java doesn’t shine are usually some advanced features that are nightmarish for people who are building tools and libraries:

    • The type system is so 90s and it’s kept like that for backwards compatibility.

    • Generics having type erasure is again an improvisation for the sake of backwards compatibility. It makes writing generic code in conjunction with Reflection painful.

    • The lack of control for the memory layout. I mean in most cases you dont need full control, but there are use cases where it’s literally impossible to do optimisations that are easy to do in C/C++. You must have faith in the JVM and JIT.

    • Integration with native code is cumbersome.

    Other than that Java is fine for most backend work you need to do, except probably for Real Time Processing apps where every millisecond count, but even there there are ways.

    You use Java not for the languages itself, but for the tooling and the ecosystem.

    • moonleay@feddit.de
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      You use Java not for the languages itself, but for the tooling and the ecosystem.

      This is why I love Kotlin so much. You can use the Java ecosystem with a modern language.

    • darkfiremp3@beehaw.org
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      There is also a big enterprise group who write extra verbose legacy java, vs a more modern light way to write

      • sizeoftheuniverse@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        1 year ago

        Yes, i was part of the cult in my early days as programmer. I would endlessly create abstractions over abstractions. But the whole madness started for valid reasons.

        Im the early days of Java on the web, you had servlets and JSP. Servlets were miserable to write, and JSPs were basically the java interpretation of having a PHP. Those were the days before JSON and yaml, when XML was king.

        So people wanted to abstract their way out of JSP and XML, so they created layers to isolate the nasty parts and make it easier to write actual Java code. So a few ideas emerged/frameworks: ORMs, EJBs, Struts, JSF, template frameworks, and finally Spring which was the lightweight one, if you can believe it. A lot of those ideas coming from the Java world were exported into various other languages in a selective ways.

        People experienced with various patterns and frameworks. Eventually Spring won, and then Spring started to use annotations, JSON became more popular, etc., the code became less and less verbose.

        Some Java developers never made the mental jump and are still creating huge piles of abstractions because this is what they’ve learned from their seniors.

  • gravitas_deficiency@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    As a software engineer, from experience: yes and no.

    The language itself is getting a lot of cool, new, modern features. However, I’ve never had a job where we were using the latest Java version. The most up-to-date JDK I’ve used in work was two major releases back, and most of the time it’s older than that.

    • huginn@feddit.it
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      I’m normally working in Kotlin when coding because I do Android development. I’ve had the misfortune of taking up some slack in a greenfield backend project and holy God is it miserable.

      Everything is harder to read, every basic data model is 200 lines of getters and setters, multithreading is painful, basic transformers require separate class declarations. And that doesn’t even touch on the horrific experience of using Jackson to handle json serialization.

      • pprkut@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        1 year ago

        I felt the same way coming back to Java from Kotlin. The more streamlined syntax of Kotlin is so much more comfortable to read and write. That being said, I never had an issue with using Jackson for JSON serialization in Java. I’m curious what issues you have encountered and if you have any alternative suggestions that are nicer to use in Java?

      • BlueBockser@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Lombok will shrink the 200 lines of getters and setters to one or two. It has its own pitfalls of course, but IMO it’s definitely worth it.

        • huginn@feddit.it
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          Corporate standards.

          I’m pushing for no half measures: it’s Kotlin or bust.

          • BlueBockser@programming.dev
            link
            fedilink
            arrow-up
            0
            ·
            1 year ago

            Definitely agree that Kotlin is so much better than Java + Lombok, but it’ll take a lot of time for all the existing Java projects or migrate to Kotlin or reach EOL. In the meantime, it’s hard to avoid the occasional Java project…

            • huginn@feddit.it
              link
              fedilink
              arrow-up
              0
              ·
              1 year ago

              Sure but you can also just drop kotlin into any Java codebase. It’s a single line maven import and the entire company already uses Intellij

              • gravitas_deficiency@sh.itjust.works
                link
                fedilink
                English
                arrow-up
                3
                ·
                1 year ago

                Oh yeah - the seamless Java/kotlin interop is pretty slick, though there are some pitfalls - nullity is one of them. Kotlin treats it explicitly, but when it’s talking to Java, it’s forced to treat it ambiguously unless you wrap stuff in Optional. And then even if you do, some Java lib that you need to plug into your project might not do that, so you’ve got to be careful about managing the interactions between their interfaces in some situations. And then there’s the unfortunate divergence that’s started to occur as newer versions of Java have brought certain features that were first available in Kotlin into Java, but the patterns and interfaces often differ subtly, so you have to worry about that too, especially with less experienced engineers on the team.

                Don’t get me wrong - it’s great, and I’ve enjoyed working with it, but if you’re doing an incremental migration, make sure you test the ever-loving shit out of it.

                Source: I did an incremental Java -> Kotlin migration on a huge project a couple jobs ago

                • huginn@feddit.it
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  1 year ago

                  Yeah it can be slightly hairy because Java does a terrible job with nullability. I’ve also done an incremental migration of an android codebase to Kotlin.

                  Personally I think being forced to declare the nullability of a field is something backend developers should do more of. It helps eliminate some of the foot guns that otherwise get built into the code base.

                  I’m a bit of a kotlin fanboy though, I’ll admit.