• AVincentInSpace@pawb.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    4 days ago

    Anyone who knows me knows that I hate Java with the fire of a thousand suns, but this is just sad. Most of these are true of any programming language. There are plenty of legitimate reasons to hate Java besides the fact that its concurrency utilities are as utterly shite as those of its 90s contemporaries, like the fact that it does not support multiple inheritance, or remote interface implementation, or any form of namespacing besides the goddamned filesystem, or unsigned integers, or string formatting. Or you could rant about the primitive type/object dichotomy and how you can’t use primitive types in generics, or the fact that type erasure is a thing and you can’t return a generic type from a method because javac is too stupid to remember what generic parameters you passed to a class, or the JVM’s atrocious memory efficiency, or the fact that it’s not backwards compatible thus requiring end users to install multiple versions of the JVM for different projects, or

  • Batman@lemmy.world
    link
    fedilink
    arrow-up
    30
    ·
    7 days ago

    My inner mathematician respects Java. The first step in any problem is defining your universe

  • lurklurk@lemmy.world
    link
    fedilink
    arrow-up
    30
    arrow-down
    2
    ·
    7 days ago

    Hello World

    30 minutes of boilerplate

    writing imports

    $ cat <<EOF > Hello.java
    public class Hello {
      public static void main(String args[]) {
        System.out.println("Hello world!");
      }
    }
    EOF
    $ java Hello.java
    Hello world!
    

    ok

    • MooseTheDog@lemmy.world
      link
      fedilink
      arrow-up
      26
      arrow-down
      4
      ·
      7 days ago

      Welcome to java, we have a couple unconventional ways of doing things, but overall I’m like every other mainstream oo language.

      People: AHH! Scary!

      Welcome to python. your knowledge of me wont help you elsewhere as my syntax is purposefully obtuse and unique. Forget about semicolons, one missed space and your code is as worthless as you after learning this language.

      People: Hello based department

      • Classy
        link
        fedilink
        arrow-up
        9
        ·
        7 days ago

        Oh my god I got fucked by a python script once because of a single space. It took forever to figure out what went wrong

        • greenkarmic@lemmy.ca
          link
          fedilink
          arrow-up
          2
          ·
          6 days ago

          You can’t use Python without a linter. I have everything setup in vscode to use tabs yet copilot autocomplete insists on inserting random spaces everywhere creating indentation errors. The linter is essential to quickly see and fix them.

        • TonyOstrich@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          6 days ago

          I refuse to code in Python without a really good IDE and linting like PyCharm. When using PyCharm it’s very rare I have issues like this, because it catches them in one way or another, but I notice it catches those kinds of issues a lot when I’m coding soooooooo…

          I have also setup the IDE to specifically color code comments like

          ’ # End If and ’ # Next

          in the same style as their beginning statements as I find it much easier to visually scam through code when they are present.

      • JackbyDev@programming.dev
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        7 days ago

        **kwargs

        “No, I don’t use type annotations because they don’t actually do anything. In fact I purposefully give this parameter different types for different behaviors. How is that confusing?”

      • lurklurk@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        7 days ago

        Python has its drawbacks but it also has a pretty useful standard library so as a language for small scripts, one can do much worse

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      7
      ·
      7 days ago

      This is getting a little better nowadays.

      > cat Hello.java
      void main() {
          System.out.println("Hello, World!");
      }
      > java --enable-preview Hello.java
      Hello, World!
      

      Things to notice:

      1. No compilation step.
      2. No class declaration.
      3. Main method is not public static
      4. No String[] args.

      This still uses preview features though. However, like you demonstrated already, compilation is no longer a required step for simplistic programs like this.

      • cashew@lemmy.world
        link
        fedilink
        arrow-up
        4
        arrow-down
        1
        ·
        edit-2
        6 days ago

        Microsoft Java is a one-liner these days.

        > cat program.cs
        Console.WriteLine("Hello, World!");
        > dotnet run
        Hello, World!
        
      • Valmond@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        6 days ago

        System.base.stuff.output.out.printfunctions.println

        Or so it felt every time you wanted to dump something into the console…

      • مهما طال الليل@lemm.ee
        link
        fedilink
        arrow-up
        1
        arrow-down
        2
        ·
        edit-2
        6 days ago

        Main method is not public static

        It must be somewhere under the hood. Otherwise, it wont be callable and it would require an instance of an object to call. Unless the object here is the Java environment?

        No String[] args

        They are just optional I’m sure, like C and C++. You still need them to read command line arguments.

        All in all, these syntax improvements are welcome. I already moved on to Kotlin for Android development though.

        • JackbyDev@programming.dev
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          6 days ago

          Main method is not public static

          It must be somewhere under the hood. Otherwise, it wont be callable and it would require an instance of an object to call. Unless the object here is the Java environment?

          No. From JEP-445:

          If an unnamed class has an instance main method rather than a static main method then launching it is equivalent to the following, which employs the existing anonymous class declaration construct:

          new Object() {
              // the unnamed class's body
          }.main();
          

          No String[] args

          They are just optional I’m sure, like C and C++. You still need them to read command line arguments.

          Without the preview feature enabled, it is not an optional part of the method signature. It specifically looks for a main(String[]) signature.

          • مهما طال الليل@lemm.ee
            link
            fedilink
            arrow-up
            2
            arrow-down
            6
            ·
            6 days ago

            I am not in the mood to read a technical document, but I don’t think the resulting binary/byte code should be different between the two “hello world” programs. But then again, why not?

            Without the preview feature enabled, it is not an optional part of the method signature. It specifically looks for a main(String[]) signature.

            Ah ha! So that’s what’s going on here. They almost got it right. They had the potential to make a lot of the boilerplate optional or implicit under relevant circumstances, but instead the language has two explicit switchable modes.

            Can I write a Java application in “preview feature”?

            • JackbyDev@programming.dev
              link
              fedilink
              English
              arrow-up
              7
              ·
              edit-2
              6 days ago

              I mentioned this uses preview features twice in the first comment regarding this, so I don’t know why you’re "ah ha"ing. Also you don’t need to read the technical document, I’ve quoted the entirety of the relevant text. I provided it as a citation.

              You seem confused about preview features. It’s not a switchable mode to reduce boiler plate. I find the name very clear, but here is more information. From JEP-12

              A preview feature is a new feature of the Java language, Java Virtual Machine, or Java SE API that is fully specified, fully implemented, and yet impermanent. It is available in a JDK feature release to provoke developer feedback based on real world use; this may lead to it becoming permanent in a future Java SE Platform.

              As an example, JDK 17 added pattern matching for switch statements as a preview, and by JDK 21 it was added as a full fledged feature that doesn’t require usage of the enable preview flag. Presumably in some future release of Java this feature will not require the usage of a flag.

              • مهما طال الليل@lemm.ee
                link
                fedilink
                arrow-up
                1
                arrow-down
                2
                ·
                edit-2
                6 days ago

                It is pretty late for me. Sorry. And thank you for your patience. Repeating it three times helped.

                It will be interesting to find out if the resulting binary is the same or not and what’s possible once it matured.

                • JackbyDev@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  3
                  ·
                  6 days ago

                  Yes, because it’s genuinely not a static method. It’s an instance method. Also the signature is different. It’s not some sort of mere syntactic trick that translates void main() to public static void main(String[] args).

    • meowMix2525@lemm.ee
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      7 days ago

      I got the impression they skipped the hello world cause it was too easy and they wanted to get right to writing their app, so they moved on to more advanced stuff without having a real grasp of the basics

  • Zement@feddit.nl
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    7 days ago

    I really enjoyed the text.

    From the perspective of a python programmer it all seems valid.

    A Java-Dev would probably write the same about an embedded engineer.

    • MooseTheDog@lemmy.world
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      7 days ago

      Sorry, you had a small error in the spacings of your post; Therefore I cannot parse a thing you’re saying. Didn’t mean to scare you with a semicolon either. It’s just a tool in language’s to end a clause and begin a related, independent clause. That could be useful somewhere…

    • MajorasMaskForever@lemmy.world
      link
      fedilink
      English
      arrow-up
      6
      ·
      7 days ago

      As embedded dev, the stack trace alone scares me. It would be funny to watch the Java runtime blow the 8 frame deep stack on a PIC18 tho

    • sugar_in_your_tea
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      7 days ago

      Honestly, I prefer C to Java, it’s incredibly simple without all the BS that Java throws at you:

      • interfaces - compiler will fail if you provide the wrong types; w/ Java, figuring out what types to pass is an effort unto itself
      • functions - everything needs to be in a class; even callback functions are wrapped in a class (behind the scenes if you use modern Java); in C, you just pass a function
      • performance - Java uses a stop the world GC, which can cause issues if you have enough data churn; in C, you decide when/if you want to allocate or free memory, no surprises

      There are certainly some bad parts, but all in all, when I run into an issue in C, I know it’s my fault, whereas in Java, there are a million reasons why my assumptions could be considered valid, and I have to dig around the docs to find that one sentence that tells me where I went wrong w/ the stuff I chose.

      That said, I prefer Rust to both because:

      • get fancy stack traces like I do in Java (I really miss stack traces in C)
      • compiler catches most of my stupid mistakes, Java will just throw exceptions
      • still no stupid interface hell, I just satisfy a specific trait and we’re good
      • generally pretty concise for what it is; I can rarely point to a piece of syntax and say it’s unnecessary

      I use:

      • Python - scripting and small projects
      • Rust - serious projects or things that need to be fast
      • Go - relatively simple IO-heavy projects that need to be pretty fast
      • C - embedded stuff where I don’t want to mess w/ the Rust toolchain

      Java has been absent from my toolbox for well over a decade, and I actively avoid it to this day because it causes me to break out in hives.

      • NakedGardenGnome@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        1
        ·
        6 days ago

        For over a decade?

        In the last decade java finally is starting to catch up! The latest java releases have finally given us the ability to pass through a function, and work more functional.

        And you can choose any GC you want, even less “stop the world” ones, but who got the time to figure out which GC they actually want… The memory allocation from C is what haunts my dreams more than the GC from java.

        Still, I really want to give Rust a look, if only I gave myself enough time.

        • sugar_in_your_tea
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          6 days ago

          The latest java releases have finally given us the ability to pass through a function, and work more functional.

          Which AFAIK is still a class under the hood. That doesn’t particularly matter for developers, but it’s still odd.

          But honestly, if I’m going to use anything on the JVM, I’ll just use Kotlin. Java is kind of catching up, but Kotlin is just so much cleaner IMO. But if I’m not stuck w/ the JVM, I’ll use one of the others I mentioned.

          The memory allocation from C

          Eh, it’s honestly not so bad, provided you’re using it for the type of work where C is suited. For most embedded work, I just pass on the stack (esp. w/ the new variable length arrays on the stack, which C++ doesn’t have), so no need to malloc() or free() most of the time. If I’m building a larger program, I’ll probably not use C, because it just doesn’t have the features I want for larger-scale development work, and I definitely won’t use C++ because that’s a nightmare of conflicting legacy features.

          Rust is my go-to if I know it’ll be large-ish and I don’t have any particular restraints on where it’s going to run (i.e. not on a microcontroller or something). The compiler catches a lot of my bugs, the result is fast, and now that I’m comfortable with it, I’m pretty productive with it. It does have a bit of a learning curve, but it’s way better than when I started with it (around the 1.0 launch).

  • yamanii@lemmy.world
    link
    fedilink
    arrow-up
    10
    arrow-down
    2
    ·
    7 days ago

    I still think Java is good for teaching newbies precisely because it will throw an error quickly if they are doing it wrong.

  • kerrigan778@lemmy.world
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    7 days ago

    Java is terrible and I hated it but I feel like this stuff is not why, this mostly just seems like stuff that most powerful object oriented languages do.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      2
      ·
      7 days ago

      Java is amazing and I love it, and I agree that this is not really a good list of problems. (Not that I expect green texts to be well thought out, rational, real, fair, or anything other than hyperbolic rants lol.) There are good reasons to critique it and the ways people use it, but this isn’t it.

      Particularly funny is the one about race conditions. That’s something you’d have to deal with in any sort of multi threaded environment.

      • shastaxc@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        6 days ago

        Maybe they got confused and assumed it would run on a different cpu? Is there another language that does it that way? No, now I’m confusing myself.

        • JackbyDev@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          6 days ago

          Various languages have various features to make multi threading/concurrent programming easier. Without knowing what language the green text is fanboying for instead of Java it’s hard to know what their specific gripe is. Supporting true multi threading out of the box has always been a priority of Java so I don’t know what they’re complaining about. Generally languages that people praise over Java like Python and JavaScript do not feature true multi threading. (Although Python is getting closer or there now that the GIL is optional.)

  • lennivelkant@discuss.tchncs.de
    link
    fedilink
    arrow-up
    8
    arrow-down
    3
    ·
    7 days ago

    Aside from the general stupidity, Java is a heavily front-loaded language in my experience. I’m not going to engage in any tribalism about it or claim that it’s better or worse than others. As a matter of personal taste, I have come to like it, but I had to learn a lot until I reached a level of proficiency where I started considering it usable.

    Likewise, there is a level of preparation on the target machines: “Platform-independent” just means you don’t have to compile the program itself for different platforms and architectures like you would with C and its kin, as long as the target machines have an appropriate runtime installed.

    Libraries and library management is a whole thing in every general-purpose language I’ve dealt with so far. DSLs get away with including everything domain-specific, but non-specific languages can’t possibly cover everything. Again, Java has a steep learning curve for things like Maven - I find it to be powerful for the things I’ve used it in, but it’s a lot to wrap your head around.

    It definitely isn’t beginner-friendly and I still think my university was wrong to start right into it with the first programming classes. Part of it was the teacher (Technically excellent, didactically atrocious), but it also wasn’t a great entry point into programming in general.

    • ebc@lemmy.ca
      link
      fedilink
      arrow-up
      7
      ·
      7 days ago

      I’m not a Java dev, but I know enough of it to fix simple bugs in the backends I work with. My main issue with it is that 99% of the code doesn’t seem to do anything. The clear, obvious place that looks like it handles the feature you’re looking for? None of it does anything! It just instantiates another class from God knows where to actually do the work. I swear I spend most of my time in Java projects just looking for the damn implementation in a sea of AbstractSingletonFactoryBean shit.

      • lennivelkant@discuss.tchncs.de
        link
        fedilink
        arrow-up
        2
        ·
        7 days ago

        The dev culture certainly contributes to the problem. In the attempt to modularize, isolate functionality from expectations and create reusable code, a mess of abstraction patterns have sprung up.

        I get the point: Your logic shouldn’t be tightly coupled to your data storage, nor to the presentation, so you can swap out your persistence method without touching your business logic and use the same business logic for multiple frontends. You can reuse parts of your frontend (like some corporate design default structures) for different business apps.

        But you can also go overboard with it, and while it’s technically a dev culture issue rather than a language one, it practically creates another hurdle to jump if you want to use Java in an enterprise context. And since that hurdle is placed at the summit of the mountain that is Inheritance, Abstraction and Generics… well, like I said, massively front-loaded.

        Once you have a decent intuition for it, the sheer ubiquity makes it easier to find your way around other projects built on the same patterns, but getting there can be a confusing slog.

    • frayedpickles@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      10
      ·
      edit-2
      7 days ago

      I’m sorry just as a matter of policy I’m going to have to downvote you for saying you like java. Nothing personal.

      I think some things that were novel when java came out are such old hat at this point the 1990s benefits just aren’t benefits anymore. Run anywhere? I’m in a html app right now. As is my IDE and my chat app. Strong interfaces and sane types are only in comparison to the bizarroland of c++ which visibly always seems to basically be word vomit. JIT compilation is in python which is both easier to use and has way better tooling and libraries…making python today run in the “fast enough” category that java was kinda in. I’ve literally never seen a usable java UI tho.

      • lennivelkant@discuss.tchncs.de
        link
        fedilink
        arrow-up
        6
        ·
        7 days ago

        So you’re going to stride past the part where I say “I’m not going to […] claim that it’s better or worse than others”, ignore the bulk of my comment on Java being hard to get into, make a point of declaring you’ll downvote for stating a personal opinion, then pretend it’s “nothing personal”? I’d be curious how that makes sense in your mind.

        Anyway, like I said, I see no point in petty tribalism. I like Python and C too - that’s not mutually exclusive. I hope you have a pleasant, Java-less day :)

        • frayedpickles@lemmy.cafe
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          7 days ago

          I was attempting to combine my genuine belief that nobody has ever written a java app that is any good along with humor. As an end user java has always been the scourge of human existence. I’ve never written a line of java code and have no opinion on that.

          • lennivelkant@discuss.tchncs.de
            link
            fedilink
            arrow-up
            1
            ·
            7 days ago

            I’m not sure you’d even notice all apps that are made with Java, particularly Enterprise Web apps. But yeah, if you’re going for humour, maybe jokingly shitting on people’s opinions isn’t the safest bet.

            • frayedpickles@lemmy.cafe
              link
              fedilink
              English
              arrow-up
              1
              ·
              6 days ago

              “not going to engage in tribalism”

              Moments later, engages in tribalism

              You’ve really got to lighten up, don’t feed the trolls

              • lennivelkant@discuss.tchncs.de
                link
                fedilink
                arrow-up
                1
                ·
                edit-2
                6 days ago

                What came across as tribalistic there? Pointing out that you might not immediately see the tech stack of every Web app you use is hardly saying “Java is better”, and suggesting to not shit on others’ opinions is kinda the opposite: I’m saying your opinion disliking it is fine, just as mine liking it is.

                don’t feed the trolls

                Fuck me for trying to take people in good faith and have constructive conversations

      • MooseTheDog@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        7 days ago

        Minecraft is a decent example of a good java program. People jump to the first silly reason to disregard it. Cope.

        • frayedpickles@lemmy.cafe
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          3
          ·
          edit-2
          7 days ago

          You seem very butthurt over a joke, be chill

          Have to admit I didn’t know Minecraft was in java. Explains the graphics ;p

          • Hoimo@ani.social
            link
            fedilink
            English
            arrow-up
            2
            ·
            6 days ago

            I didn’t mind your opinion, but now I have to downvote anyway. An opinion this uninformed doesn’t have any right to exist. Minecraft was the sole reason for the current generation of Java devs, it’s literally the Statue of Liberty of the United Javates, the first thing those poor huddled masses saw before landing in the New World.

      • CompassRed@discuss.tchncs.de
        link
        fedilink
        arrow-up
        1
        ·
        7 days ago

        Python and Java are barely comparable. I adore both languages equally and use them about the same amount at work. They are just different tools better suited to different tasks.

        • frayedpickles@lemmy.cafe
          link
          fedilink
          English
          arrow-up
          1
          ·
          7 days ago

          Care to expound? Why barely comparable? I’d say 90s java and today’s python fill a similar niche of barely functional apps with performance issues.

  • arc@lemm.ee
    link
    fedilink
    arrow-up
    8
    arrow-down
    5
    ·
    7 days ago

    Could be worse, could be programming Javascript (or Typescript).

    • jol@discuss.tchncs.de
      link
      fedilink
      arrow-up
      7
      ·
      edit-2
      5 days ago

      A text file with a script block and nothing else, containing a console log, is all you need. You already have all the boilerplate to run it in any computer. No extra dependencies, no installing anything. Literally just a notes editor app. This is a valid HTML file:

      <script>
      console.log("Hello World")
      </script>
      
      • arc@lemm.ee
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        6 days ago

        By that logic we should all program with .bat files

        • jol@discuss.tchncs.de
          link
          fedilink
          arrow-up
          1
          ·
          5 days ago

          Bash and bat scripts are really useful for that reason. You’re making a bad generalization from my comment. But the premise from OP seems to be that a language’s value is how hard it is to get started.

      • Lysergid@lemmy.ml
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        6 days ago

        I think you forgot to pollyfill your console.log and now you have some error in some script in some callback

    • Seeders
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      6 days ago

      I love javascript. Shit. Just. Works.

      Even if you, the programmer, are a complete fucking moron, by god javascript will try to make your program run as long as possible.

      • arc@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        6 days ago

        Javascript doesn’t “just work”. It’s a language originally designed to glue actions to html elements and it is fundamentally broken in ways that will be never be fixed. Weird syntax, weird type coercion, horrible base types & functions, surprises galore. Even Typescript, which is basically a precompiler, is just JS with some type checking. The only reason anyone uses either is because it is ubiquitous - people have to use it.

        • Seeders
          link
          fedilink
          English
          arrow-up
          1
          ·
          5 days ago

          It’s the greatest language on the planet.

      • ReluctantMuskrat@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        6 days ago

        Even if you, the programmer, are a complete fucking moron, by god javascript will try to make your program run as long as possible.

        I mean it might not work as intended but it’ll run and not complain!

  • cows_are_underrated@feddit.org
    link
    fedilink
    arrow-up
    1
    arrow-down
    2
    ·
    6 days ago

    Trying to print hello world is actually pretty easy

    public static void main[Args]{ SystemPrintOutLn("Helli world"); }

    That’s should be it. But I can devinetively agree. For simple tasks Java is to complex because you need to do to much stuff prior to it. If you have more complex things its actually not that bad since if you have a good polished infrastructure it can be quite good.

  • MooseTheDog@lemmy.world
    link
    fedilink
    arrow-up
    3
    arrow-down
    5
    ·
    7 days ago

    I’ll never get the hate for java and love for python. It’s like learning mandarin because you think it’s easier than Spanish. When you know java you also kinda know javascript, C, Php, and others. When you know python, it’s probably a government sponsored course, or a programming class talked your school district into buying their “intro to programming python course”. Plus you only get to know python. I’ll die on this hill

      • dejected_warp_core@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        7 days ago

        In my experience, this kind of sentiment is what marks someone as a seasoned professional. When you finally see that all tools are flawed and deserving of some negative remark for a bone-headed misfeature or three, you’ve arrived. Carry on.