• @[email protected]
    link
    fedilink
    English
    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
    link
    307 days ago

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

  • @lurklurk
    link
    287 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
      link
      227 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

      • @[email protected]
        link
        fedilink
        97 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

        • @[email protected]
          link
          fedilink
          26 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
          link
          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
        link
        fedilink
        English
        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
        link
        37 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
      link
      fedilink
      English
      77 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
        link
        3
        edit-2
        7 days ago

        Microsoft Java is a one-liner these days.

        > cat program.cs
        Console.WriteLine("Hello, World!");
        > dotnet run
        Hello, World!
        
      • @Valmond
        link
        26 days ago

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

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

      • مهما طال الليل
        link
        fedilink
        -1
        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
          link
          fedilink
          English
          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.

          • مهما طال الليل
            link
            fedilink
            -46 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
              link
              fedilink
              English
              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.

              • مهما طال الليل
                link
                fedilink
                -1
                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
                  link
                  fedilink
                  English
                  36 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).

    • @[email protected]
      link
      fedilink
      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

  • @mlg
    link
    English
    157 days ago

    Forgot the JVM eating the entire machine’s RAM for breakfast

  • Zement
    link
    fedilink
    137 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
      link
      77 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
      link
      English
      67 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

    • @[email protected]
      link
      fedilink
      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.

      • @[email protected]
        link
        fedilink
        English
        16 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.

        • @[email protected]
          link
          fedilink
          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
    link
    87 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.

    • @DerArzt
      link
      87 days ago

      Rust over there like

      Hey kid, tired of putting off your problems?

    • @kerrigan778
      link
      47 days ago

      So will so many better languages, more so actually.

      • @stetech
        link
        47 days ago

        Arguably there’s Typescript now, too.

  • @kerrigan778
    link
    77 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
      link
      fedilink
      English
      67 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
        link
        fedilink
        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
          link
          fedilink
          English
          16 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.)

    • @[email protected]
      link
      fedilink
      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>
      
        • @[email protected]
          link
          fedilink
          15 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.

      • @[email protected]
        link
        fedilink
        07 days ago

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

    • @[email protected]
      link
      fedilink
      English
      1
      edit-2
      7 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.

      • @[email protected]
        link
        fedilink
        26 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.

      • @ReluctantMuskrat
        link
        36 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!

      • @herrvogel
        link
        26 days ago

        Javascript is a beautiful language where ‘3’ - 1 = 2 but ‘3’ + 1 = ‘31’.

  • @[email protected]
    link
    fedilink
    -16 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
    link
    -27 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

    • @anyhow2503
      link
      47 days ago

      I use both professionally and I hate both of them for different reasons.

      • @dejected_warp_core
        link
        17 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.

  • Ginny [they/she]
    link
    fedilink
    1598 days ago

    I also think Java is shit, but if you manage to get a NullPointerException while writing a hello world program, maybe anon is just not cut out for computers?

    • Scott
      link
      fedilink
      English
      1368 days ago

      I’ve worked on a corporate project with multiple Java services, anon isn’t really exaggerating. Java can be a hell scape at times

      • @[email protected]
        link
        fedilink
        488 days ago

        They forgot to mention that production Java applications apparently need to log a certain minimum number of completely meaningless stacktraces per hour to work properly. Or at least I assume that is the case from the fact that all of them do that.

        • @[email protected]
          link
          fedilink
          288 days ago

          Best with an old and vulnerable log4j on a Windows log server.

          We don’t know what’ll happen if we update. And we don’t know if the dude who coded it will answer our calls. YOLO!

        • Scott
          link
          fedilink
          English
          57 days ago

          You would be surprised, errors right out of the box on a freshly initialized project aren’t uncommon

          • babybus
            link
            fedilink
            English
            147 days ago

            As I’ve been working with Java professionally for years, you’re right, I would be surprised, because that would be really uncommon.

    • @kitnaht
      link
      81
      edit-2
      8 days ago

      I’m pretty sure Java doesn’t have pointers, so writing a hello world application isn’t gonna fuck up nearly that hard.

      The one thing he forgot though is that your source file is probably in the folder

      com/companyname/net/classes/factory/factoryfactory/worker/lib/bin/refresh/jdk/model/ui/closebutton/press.java

      And spread out among a bunch of other directories, and the java file is like…3 lines. But there are 10k files spread all around directories like this that are all 3 lines a piece with a class definition.

      • @SpaceNoodle
        link
        358 days ago

        Everything in Java is a hidden pointer

      • @perviouslyiner
        link
        188 days ago

        wait, so when .io gets deregistered, are a load of companies going to have to rename their root directories and rewrite all of their include statements?

        • @kitnaht
          link
          41
          edit-2
          8 days ago

          Thankfully, despite naming them like that, it doesn’t actually seem to have any real purpose. Apparently they just wanted to make sure that different companies making different libraries didn’t accidentally use the same name for their project…

          • @Hawke
            link
            108 days ago

            That’s exactly the reason. And also no company is going through the bother to refactor that shit, so everything is named based on some other company 5 mergers and acquisitions ago.

      • @Valmond
        link
        68 days ago

        They have sort of pointers, like references, that can be null…

        You just “new” stuff to it and let the “garbage” collector deal with freeing stuff up. When it feels like it.

    • blue lion
      link
      fedilink
      English
      458 days ago
      • a hello world doesn’t need libraries in Java
      • installing JDK takes at most 5 steps, depending on the OS
      • a nullpointerexception is more likely the developper’s fault (unassigned value, calling a function on a null object)
      • IntelliJ is easy to install and modern (granted, other IDEs are very ancient)
      • developping GUI apps is a PITA, no matter the ecosystem (generally)

      The rest is more or less spot on (no idea about concurrency issues though)

      • @Blue_Morpho
        link
        288 days ago

        nullpointerexception is more likely the developper’s fault

        Of course it was the developer’s fault. But it’s absurd a language without pointers throws an error about pointers.

          • @Blue_Morpho
            link
            77 days ago

            Having error messages that match the language is actually helpful. A reference and a pointer aren’t exactly the same.

            Like if Rust output “invalid word size” on a type mismatch.

      • @[email protected]
        link
        fedilink
        87 days ago

        The date of the post is from this week so it’s not accurate at all. Java does support main outside of a class now, and it doesn’t need to be static, or take args. You wouldn’t use JavaFX in this day and age either. Installing the jdk is absolutely nothing especially if you’re using IntelliJ as it will install it for you and manage everything. No library is even close to 3gb.

        This entire post sounds like it was written by someone that last touched Java in 2010.

        Source: am a Kotlin dev. Java sucks. None of these are the reasons why.

        • @Ziglin
          link
          English
          27 days ago

          Depends on the version of Java you have to use and most places still say to put it in a class because they’re outdated too. (Is anything about Java modern?)

    • @[email protected]
      link
      fedilink
      28
      edit-2
      8 days ago

      95% exaggeration. Here is reality:

      • yeah you need main class coz it’s OO-language. Though, not required anymore, which should’ve been done once Java got scrip language capabilities (jshell) back in JDK 9. But as of today not required anymore
      • imports exist in most if not all languages. Gotta be insane writing them manually in 2010 let alone 2024
      • installing Java runtime (JRE) is as simple as installing any app. Though for installing JDK you need 5 mins for setting PATH. Think about JDK as like TSC or Webpack and JRE as a Browser. I’d argue installing and configuring JDK is simpler than TSC or Webpack
      • Unless you doing some non-trivial multi-threading your stack trace will tell you exactly where is your NPE. You gotta be as blind as my teammates to spend more than 1 minutes to find where it is coz it literally tells you file and line numer where Exception occurred
      • I mean, yeah if you use IDE from 2000 it will look like it. IntelliJ looks modern, though I don’t like the fact latest versions look like VSCode
      • I hardly reach 3G of deps from all 10 projects I have on my workstation.
      • IDK what anon means by ecosystem here, Java ecosystem is quite standard across the board. JDK(std lib), Maven/Gradle(deps, build, publishing), Spring Framework (all sorts of blueprints and solutions to standard app level problems), Hibernate/JPA (ORM), JUnit+Mockito (testing). These are tools and libs used in 90% of projects I worked on. Of course there will be more depending on project needs. Layers? It’s not like language imposes any layers whatsoever. It’s just common practice to have 3-4 layers and some glue in-between.
      • don’t do GUI in Java it sucks and will suck until Java gets string interpolation. Hopefully soon
      • concurrency is actually the only thing which is really bloated in Java. Which will change with next LTS version if I remember correctly. And it’s not that hard if you actually read the f manual and not just “try and hope”. Again it will become much more efficient and easier to follow soon. As of now - yeah, not trivial. But people mostly prematurely optimize, so karma
      • Java is kinda have 20 ways to do same thing but actually no. Java built with idea of providing simple building blocks. Then it provides more specific API built on top of those building blocks. It allows to have API which solves typical problems and provides capability to solve custom problems with those building blocks. People often confuse this as many ways to do one thing but it’s like saying “I can have byte array why I need string data type”. Those are different levels of abstraction

      Edit: typos

      • @[email protected]
        link
        fedilink
        English
        197 days ago

        95% exaggeration if he is a real programmer.

        If he just tried to walk into Java knowing nothing or maybe PHP, and refused to RTFA, he might experience about 30% to 40% of that I just trying to do everything wrong.

    • @schteph
      link
      278 days ago

      Java is religiously backwards compatible. Modern java projects are not as enterprisey and boilerplatey, but, as jdk21 is backwards compatible with jdk1.3, you can still happily write code as if it’s 2003.

      Additionally, the java space is huge, so just wildly googling will probably not help you that much.

      • @[email protected]
        link
        fedilink
        58 days ago

        On the other hand back in Java 1.2, 1.3 and 1.4 days you frequently had companies install a specific patch level version because their applications worked only with that patch level. That was back when Java was actually popular for some reason.

      • @Hawke
        link
        3
        edit-2
        7 days ago

        Is that why every single application will only work with some ancient version of Java?(usually 8, sometimes 1.6 or 11)

        I can’t think of many cases where Java 21 is a drop in replacement, and I don’t think anyone actually used 17.

        • @pivot_root
          link
          4
          edit-2
          7 days ago

          That’s entirely the fault of applications (or more likely their libraries) using internal APIs or JNI. As long as it isn’t doing anything screwy with reflection and class loading or using the sun.* packages that aren’t part of the language specification, Java bytecode compiled for ancient Java versions will still work on modern versions.

    • @[email protected]
      link
      fedilink
      English
      268 days ago

      I’ve been programming in Java professionally for 11 years. It’s not just embellishment, it’s outright lying.

      Threads giving you race conditions? All concurrent programming will do that if you’re shit at it.

      Java has come a long way. I will admit that UI in Java is terrible. I would never do that.

      • @extremeboredom
        link
        15
        edit-2
        8 days ago

        It’s not accurate to accuse Anon of “lying,” when both their story and yours would point to the race conditions from threads being a symptom of someone who’s just learning the language.

        It’s not that serious though; because it’s a greentext, it is both artificial AND homosexual.

        • @Maalus
          link
          18 days ago

          It’s not someone who is learning, because “how to avoid race conditions” is like java concurrency 101. The entire thing is made to prevent that shit from happening. And it is incredibly easy to setup a “happens before” relationship.

      • @[email protected]
        link
        fedilink
        98 days ago

        Been coding Java for about 15 years now. Pretty much agree - anon’s primary mistake was using javaFX. From a junior dev perspective I can see why they’d do that, but Java isn’t really meant for building desktop applications, it’s meant to power web apps.

        What they should have done instead is create a backend restful web service and wire up a frontend rest client with something suited to web app ui dev such as angular or react. Java has some awesome frameworks built for it over the years, something like spring boot would make building that backend service trivial if you know how to use it. JAX-RS/Jersey or even servlets could be utilized for this instead, if you wanted to.

        Spring boot has some nice tooling for thread management, but Java also has pretty good options for this built in as well. As chunky mentioned, if you aren’t already versed in concurrency patterns, don’t try to perform concurrent operations or you’re gonna have a bad time. But do learn how to do this, because exploiting concurrency is one of the golden rules of good computing.

        • @pivot_root
          link
          4
          edit-2
          7 days ago

          What they should have done instead is create a backend restful web service and wire up a frontend rest client with something suited to web app ui dev such as angular or react.

          If anon’s program was designed to work as a client for some external server or if Java had absolutely no GUI frameworks, that would be fine. But if anon’s goal was to create a simple desktop application, doing this would be the programming equivalent of a Rube Goldberg machine.

          With that approach, you also need to be really careful about how you do it. Fuck that part up and you can end up with the locally-hosted REST server listening on the device’s public network interface or vulnerable to CSRF from a web page opened in the user’s browser.

      • @[email protected]
        link
        fedilink
        37 days ago

        Threads giving you race conditions? All concurrent programming will do that if you’re shit at it.

        Well, if you write Rust then there won’t be race conditions.

        • @[email protected]
          link
          fedilink
          English
          17 days ago

          Rust is great, and I truly mean that. But saying you can’t get race conditions in Rust is just not true.

          And also, not everything is going to be written in Rust. When the company you’re working for needs a web application quickly, that’s better done in other languages.

          And also also, Spring has a lot of niceties when it comes to concurrency that make this much less of a point.

          • @[email protected]
            link
            fedilink
            27 days ago

            You can’t get data races at least, and in practice it’s very difficult to get actual race conditions.

        • @_stranger_
          link
          17 days ago

          Only in the context of data within the rust code. If you’re writing threaded rust that interfaces with external IO, for example, you can still get bit by a race condition. A person can absolutely be shit enough to hit a race condition in rust.

          • @[email protected]
            link
            fedilink
            27 days ago

            interfaces with external IO

            How would you run into a race condition like this with safe Rust? You can’t share mutable file handles between threads for example. I’m not sure you’re correct in saying its still possible. Even if it is, it doesn’t sound easy.

    • @darthelmet
      link
      258 days ago

      Only have a beginner perspective, but in school I did really well in intro CS class that used Python. 2nd class was in Java and it almost broke me I was so confused.

      • @[email protected]
        link
        fedilink
        58 days ago

        Hated Java in school

        But before Java I learned a bit of Pascal and C/C++, and I’m so fucking happy that I’m currently working with C++ in my job and not with fucking Java

        I still hate it with everything I’ve got …

    • @Pencilnoob
      link
      English
      248 days ago

      It’s much better today, but in 2010 that was 100% accurate.

      That being said, using Java as a first time programming language is like a 15 year old trying to fly an airliner to get a few blocks away to pick up some after school snacks. Obviously it’s way overkill. Sure you could get across town with it, but it’s probably 1000x more complicated than just a simple bicycle or even walking.

      Java is industrial strength for professionals. There’s absolutely no consideration made for educational usage.

        • @[email protected]
          link
          fedilink
          English
          1
          edit-2
          7 days ago

          Which other eco system has more stable libraries, which are easy to install and redistribute and deploy?

          I would choose always choose the most boring language for the task. That the good thing about java that it is very boring and most likely won’t run into a obscure problem if you stay away from reflection and unsafe.

          • @[email protected]
            link
            fedilink
            1
            edit-2
            7 days ago

            Pretty much any compiled language using native binaries is easier to install and distribute. Java applications are an absolute pain to get to run to the point that most need specialized wrapper scripts (usually in shell on unix platforms) and need to tinker with memory management parameters on almost all of them.

            • @[email protected]
              link
              fedilink
              0
              edit-2
              7 days ago

              Do you mean something like c or c++ where you have to deal with big little edian, libc, utf8, platform specific threads, various compilers feature sets and a lot of undefined behaviour. Also if you want to distribute a library it is much harder because you a have to package it yourself or what for a distro to package your library or build a header only library which has to be manually updated every time a new version comes out. With maven you just have to upload it and you can use it in another project

              How often do thinker with the memory management in Java? Just use the g1 garbage collector, which will be fine most of the time if you have a problem just use another one.

              You can also compile the program with GraalVM to a native binary, also most Java programs are servers where it make sense to have a systemd service to configure the server

              • @[email protected]
                link
                fedilink
                17 days ago

                How often do thinker with the memory management in Java?

                As a sysadmin unfortunately every single one of those shitty Java projects forces me into dealing with that sooner or later.

      • @[email protected]
        link
        fedilink
        -27 days ago

        Java is industrial strength for professionals.

        Disagree. It’s an outdated tool today. Professionals would not choose it for new projects.

        • @[email protected]
          link
          fedilink
          English
          17 days ago

          Java isn’t outdated it is stable, today you don’t need JakartaEE you can use something like Spring Boot, Quarkus, or a microframework.

          Try to run an npm install on a 3 year old Angular or React project and most likely it won’t work

    • @Aganim
      link
      188 days ago

      Anon pretty much sums up my experience with Java when I had to learn it in college 20-ish years ago. I’ll never get rid of my distaste for the language I’m afraid.

    • @Valmond
      link
      168 days ago

      I have developed in java and C/C++ (many years) and Anon is maybe exaggerating a bit but not lying, we all have been there more or less.

      Personally I hate how java forces you into bad architectural choices. Where is the unsigned int? Why isn’t an int a class BTW? Why the pass by copy for some, by reference for others? Where is multi inheritance? Lots of things are dumbed down or you have no choice in the matter.

      Sure didn’t help it was a power hungry beast moving at snail speed back in the day too.

      • @[email protected]
        link
        fedilink
        27 days ago

        I mean they are lying because Java does support main as a top level function now. If this was written last year, sure. Also IntelliJ will literally install the jdk and manage it for you. Using asdf I haven’t had to touch the PATH for Java in probably over a decade (used sdkman before that).

        This entire post sounds like someone that last touched Java in 2010 and wanted to complain about it again. Java is shit, but for none of the reasons in the post.

        • @anyhow2503
          link
          17 days ago

          It’s easy to accuse a noob of making the wrong choices when you have the experience necessary to make the right ones. There are a ton of outdated guides on the internet for every programming language. I’m almost certain there is some school kid downloading an old Borland C++ version right now, because the youtube video from 2010, regurgitating a tutorial from 2004 said so.

    • @[email protected]
      link
      fedilink
      128 days ago

      Anon is absolutely exaggerating for comic effect. That doesn’t mean Java doesn’t have all of those problems though, it just isn’t as ridiculous as they made it out unless you get dragged into enterprise bullshit (then you’re in for it).

    • @dohpaz42
      link
      English
      98 days ago

      For the “simple” apps anon is talking about, they are exaggerating a lot. Though, when you get beyond the obligatory “Hello World” and “a window with a button”, the complexity does start to increase exponentially.

      Throwing in frameworks like Spring or JavaFX does make things more complicated. But it’s still relatively manageable once you get used to it and know what goes where and when.

      Now the whole configuration thing, that’s an art form best left to those hooded “seniors”. It’s good to learn eventually, but not when you first start out; lest you have a fetish for pain.

      Java has come a long way. It’s not the languages fault that people create monstrosities like AbstractJavaFinalSerializedFactory or whatever. But if you do want to be “good” at Java, you will want to learn about design patterns. It also doesn’t hurt to have a thick skin too, because you’ll be both criticized and made fun of for your choices. 😊

      • @Aganim
        link
        27 days ago

        also doesn’t hurt to have a thick skin too, because you’ll be both criticized and made fun of for your choices.

        As somebody who started out with PHP I can fully relate to this. 😋

    • @[email protected]
      link
      fedilink
      English
      37 days ago

      Concurrency isn’t bad, and package management (while maven is absolutely terrible to work generally), the dependency chains aren’t exceptionally bad. Getting it installed is easier than python on platforms it’s not already there on, not because it’s more portable, but because the installers do more for you. Portability is hard, they haven’t done it well but they’ve paved the default use case pretty well (although that works against you when you get to harder cases)

      But the rest is pretty close.

      The worst is the scaffolding, it’s literally superstition for years to gain the understanding as to why you’re doing it. I took two years of Java in high school before getting a degree - it was 4 years and halfway through a degree before I understood why I was making a class with a method main(string[] args). It works like that because your entry class calls the main method with a list of string arguments… I didn’t understand at all, because even though it’s simple it’s a special case, and I’d never seen anyone name the string array anything different, so I just copied and pasted it, never understanding it because I’d been told “you just have to have that” for do long

      Builds are arcane too - there’s still companies that only use netbeans in their build pipeline, Android still requires a specific an old Java version in conjunction with the IDE or a gradle build, at best a project uses maven (the package manager), which is xml based and full of arcane details that are best treated as a magic incantation to be copied exactly from elsewhere

    • tiredofsametab
      link
      fedilink
      27 days ago

      If you’ve never used Eclipse, which I assume it was referencing, it does feel old, clunky, and ugly out-of-the-box (to me at least). I tried to use IntelliJ wherever possible, but a previous company had a project that really didn’t like to run from it but would with a very specific setup in Eclipse (I don’t recall any details now more than 10 years later).

      There is a fair bit of boilerplate and bloat.

      I don’t remember UI stuff being so bad, but most of what I worked with was old Swing/AWT stuff. I did have to use JavaFX (I think it was?) once and remember something about it being frustrating, but it was for some existing thing I had to modify.

      I don’t mind Java so much, but it’s certainly not my favorite language.

      I don’t know how one gets a nullPointer when doing a hello world, though. I’m guessing this is embellishment or mashing together something later with their initial printing of hello since I think you’d come up with some other error in that process to getting something to print before nullPointer.

    • @[email protected]
      link
      fedilink
      17 days ago

      After working with somewhat modern Java using IntelliJ for 4 years, it’s alright. Null is the most annoying thing imo; just use Optionals instead

    • @SpaceNoodle
      link
      -2
      edit-2
      7 days ago

      Yes. Not an exaggeration.

      Edit: I say the same thing as a bunch of other commenters, yet I’m downvoted? Who’s got a stick up their ass today?