Professional developer and amateur gardener located near Atlanta, GA in the USA.

  • 59 Posts
  • 4.16K Comments
Joined 1 year ago
cake
Cake day: June 13th, 2023

help-circle
  • 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.








  • 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.



  • 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.











  • I’m on Lemmy essentially 99% of the time. When I’m on Reddit it’s because of niche hobbies that have more presence there. It’s very rare. (Or search index results.)

    I never use Mastodon. I was only on Twitter for very niche and interactive hobbies that do not have enough people to engage with on Mastodon. I mostly use BlueSky now but still use Twitter on occasion. It’s like 50/50 at the moment, but that’s a lot considering my BlueSky account is only like two weeks old.

    Lemmy has enough content to keep me entertained for general browsing and most of my hobbies.