Remix.run Logo
tedk-42 4 days ago

I'd swap java with go any day of the week. I never liked how much 'code-padding' is required with java `public static void main`

kasperni 4 days ago | parent | next [-]

For Java 25 which is planned to be released in a couple of weeks:

----- https://openjdk.org/jeps/512 -----

First, we allow main methods to omit the infamous boilerplate of public static void main(String[] args), which simplifies the Hello, World! program to:

  class HelloWorld {
    void main() {
      System.out.println("Hello, World!");
    }
  }
Second, we introduce a compact form of source file that lets developers get straight to the code, without a superfluous class declaration:

  void main() {
    System.out.println("Hello, World!"); 
  }
Third, we add a new class in the java.lang package that provides basic line-oriented I/O methods for beginners, thereby replacing the mysterious System.out.println with a simpler form:

  void main() {
    IO.println("Hello, World!");
  }
aatd86 3 days ago | parent [-]

so getting closer to Go's syntax, n'en déplaise à certains, apparently. :-)

gf000 3 days ago | parent [-]

Except for the extra 3 lines of if err for every statement..

aatd86 3 days ago | parent [-]

Perhaps that it is coming sooner than you think... It all started with adding Value types, now syntactic refinements à la Go... Who knows? :-) You'll be very happy.

edit: hold on wait, java doesn't have Value types yet... /jk

Capricorn2481 3 days ago | parent [-]

> syntactic refinements à la Go

An oxymoron if I've ever heard one.

aatd86 3 days ago | parent [-]

???!

refinement: the process of removing impurities or unwanted elements from a substance.

refinement: the improvement or clarification of something by the making of small changes.

public static void in a class with factory of AbstractFactoryBuilderInstances...? right..? Yes, say that again?

We are talking about removing unnecessary syntactic constructs, not adding as some would do with annotations in order to have what? Refinement types perhaps? :)

Capricorn2481 3 days ago | parent [-]

> public static void in a class with factory of AbstractFactoryBuilderInstances

That's not syntax. Factory builders have nothing to do with syntax and everything to do with code style.

The oxymoron is implying syntax refinements would be inspired by Go of all things, a language with famously basic syntax. I'm not saying it's bad to have basic syntax. But obviously modern Java has a much more refined syntax and it's not because it looks closer to Go.

wing-_-nuts 3 days ago | parent | prev | next [-]

Always find 'java is verbose' to be a novice argument from go coders when there is so much boilerplate on the go side of things that's nicely handled on the java side.

lenkite 4 days ago | parent | prev | next [-]

Every function call is 3-5 lines in Go. For any problem which needs to handle errors, the Go code is generally >2x the Java LOC. Go is a language that especially suffers from the "code padding" problem.

gf000 4 days ago | parent | prev [-]

It's rich to complain about verbosity coming from Go.

Nonetheless, Java has eased the psvm requirements, you don't even have to explicitly declare a class and a void main method is enough. [1] Not that it would matter for any non-script code.

[1] https://openjdk.org/jeps/495