5 ms·
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), th
by Kolja 4y ago
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.
- chrisseaton 4y agoExtra 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.
- pjmlp 4y agoAs 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.
- neonsunset 4y agoI think there is more value to a terse declaration of 'main()' than people think. In C#, you can declare a quite functional microservice under 90 lines of code with asp.net core's minimal api format. To this day I think the "enterprise style religious OOP+SOLID Java/C#" is something that has to go - so many applications that take 30 files and 4 projects could've been declared in 3-5 files with the most of core logic being in Program.cs that you can grasp within few seconds of looking at it.
- pjmlp 4y agoIt will never go away, before it was COBOL, xBase, C, C++, Smalltalk. Tomorrow might be Go, Rust, Zig, or whatever they fancy using. These are projects at scale of dozens of developers with various skill sets distributed around the world, optimizing for Hello World hardly matters.
- rhdunn 4y agoIt's also a reaction to languages like Kotlin that already have these and run on top of the JVM. With Kotlin these don't apply just to main. IIRC, other JVM languages have similar reductions in boiler-plate compared to Java.
- kaba0 4y agoThe genius of this proposal is that besides the implicit unnamed class, the other changes are all purely done to the program launcher program, no changes are proposed for the language at all. And one could argue that quickly writing up some program happens often regardless of skillset (I do make at least two psvm Main classes per month), so the code reduction there is also a welcome change.
- chrisseaton 4y ago> the other changes are all purely done to the program launcher program, no changes are proposed for the language at all But the behaviour of the launcher is covered by the language spec isn't it? It's the language that specifies how main is selected. https://docs.oracle.com/javase/specs/jls/se19/html/jls-12.html#jls-12.1.4 https://docs.oracle.com/javase/specs/jls/se19/html/jls-12.ht...
- kaba0 4y agoWell, there is nothing in the spec that says would forbid the JVM loading a ProgramLauncher.class file with a public static void main method, which will look at the program arguments and if it has something ending in .java, it will compile that file, and load the resulting class (current mode of execution). Also, even if it might become a spec change (a language level one, not a jvm level one), it will be an additive change, at worst some new program won’t run on older JVMs, but all old program will continue to run on new ones.
- pjmlp 4y agoC# 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.
- whizzter 4y agoLarge scale engineering is totally beside the point for this. This is about optimizing for teaching a first language (since many will stick with that). Read the article, the "static trap" is a real thing for new students (on top of all other ceremony). To solve the issue of main being non-static some students will start to put static everywhere as a 'fix' to their initial issue, a day or two later they'll be asking why every student gets the same name (because they have one static variable to keep the student or name objects). The verbosity of Java also introduces another more serious problem for learning, not only do the students have problems compiling, they also start putting their mind on focusing on syntax instead of logic once they're past the first few problems. The issue of de-programming students from this affliction is waaay too common to be ignored.
- pjmlp 4y agoBack when I was a TA, first year students got along just as well with Pascal, Fortran and C++, many of which lacked a programming background. I wasn't found of minimal APIs, global usings and implicit Program.cs for C# 10, and share a similar opinion in relation to Java. No need to try to make it look like JavaScript and Python, each language has its place.
- EdwardDiego 4y agoAnecdata - I'm self taught. Started my learning on Python. I wanted to delve into Java. And sure enough, my very first thoughts were "wtf is public static void, why does this even matter, and why is print() so weird and long?" Shit, I ended up finding it easier to get into F# than Java. Then I got hired for a Java role, which is proof that the universe has a sense of humour.
- binarray2000 4y ago