Live data from Hacker News

Paving the on-ramp to Java

openjdk.org

1–10 of 156 posts

Re: Paving the on-ramp to Java

#2
Another option is any classless java file is just a class with the same name as the file implementing Runnable.

E.g. Foo.java

   println("foo")
Becomes:

   class Foo implements Runnable {
     void run() {
       System.out.println("foo");
     }
   }
Then running java Foo.java instead just stubs a main() that looks like:

   class Main {
     void main() {
       new Foo().run();
     }
   }

Re: Paving the on-ramp to Java

#3
This seems to be a weird micro-optimisation. While I agree with some of the goals (classless files, parameterless main exist in Kotlin and are nice to have), they should, in my opinion, not be implemented for the sole purpose of making `main` as minimal as possible.

I don't think you need to understand every single character of your very first program right from the beginning. A few of the concepts can be hand waved away to be explained in a later chapter without impeding the overall understanding of programs once you left the sub-twenty-lines beginner programs.

Re: Paving the on-ramp to Java

#5
post #3

This seems to be a weird micro-optimisation. While I agree with some of the goals (classless files, parameterless main exist in Kotlin and are nice to have), they should, in my opinion, not be implemented for the sole purpose of making `main` as minimal as possible. I don't think you need to understand every single character of your very first program right from the beginning. A few of the concepts can be hand waved…

Extra language specification rules that you need to be aware of for your whole career... in order to make the first 30 seconds easier when looking at hello-world for the first time.

Re: Paving the on-ramp to Java

#6
post #4

Doesn't Groovy ( https://groovy-lang.org ) achieve much of this? I remember being taught with it at university for some time before they introduced Java. With Groovy you don't need the class or main method, and can have a program which is just `println "Hello world!"`.

> achieve much of this

Well no, because that on-ramps you to Groovy, not Java.

Re: Paving the on-ramp to Java

#7
post #4

Doesn't Groovy ( https://groovy-lang.org ) achieve much of this? I remember being taught with it at university for some time before they introduced Java. With Groovy you don't need the class or main method, and can have a program which is just `println "Hello world!"`.

Groovy is not Java.

Re: Paving the on-ramp to Java

#8
post #7
post #4

Doesn't Groovy ( https://groovy-lang.org ) achieve much of this? I remember being taught with it at university for some time before they introduced Java. With Groovy you don't need the class or main method, and can have a program which is just `println "Hello world!"`.

Groovy is not Java.

But it's a brilliant example of everything that could possibly go wrong if you blindly optimize for hello world

Re: Paving the on-ramp to Java

#9
post #3

This seems to be a weird micro-optimisation. While I agree with some of the goals (classless files, parameterless main exist in Kotlin and are nice to have), they should, in my opinion, not be implemented for the sole purpose of making `main` as minimal as possible. I don't think you need to understand every single character of your very first program right from the beginning. A few of the concepts can be hand waved…

C# just went through this for C# 10, which I find a waste of resources, optmizing for "Hello World" is not what matters in large scale engineering.

Re: Paving the on-ramp to Java

#10
post #3

This seems to be a weird micro-optimisation. While I agree with some of the goals (classless files, parameterless main exist in Kotlin and are nice to have), they should, in my opinion, not be implemented for the sole purpose of making `main` as minimal as possible. I don't think you need to understand every single character of your very first program right from the beginning. A few of the concepts can be hand waved…

Extra language specification rules that you need to be aware of for your whole career... in order to make the first 30 seconds easier when looking at hello-world for the first time.

As I mention on the sibbling comment, C# 10 already went through this.

For me it seems like a reaction to JavaScripts and Pythons of this world, optimizing for Hello World just to win over them on those 30 seconds.

They are going to rewrite their applications anyway, when performance comes knocking on the door.

Post reply on HN