New candidate JEP: 445: Flexible Main Methods and Anonymous Main Classes (Preview)
Brian Goetz
brian.goetz at oracle.com
Mon Apr 10 23:24:24 UTC 2023
As you allude to, there is already the “Single File Source Launcher”, which let’s you run a Java program directly from the command line without compilation (`java Foo.java`), which has been around for a while, and additionally does support “shebang” execution. (There are plans to extend this further.). This was aimed at script-like programs, which, while not written by beginners, also do not require the ceremony of the class declaration. So the design center here is not “beginning programmers”, but “simple programs”, but of course there is a lot of intersection between the two — beginning programmers write simple programs.
There is also a chicken-and-egg problem here; one of the reasons people don’t write script-like programs in Java so often is because of the declaration and building overhead. But that’s an accidental consequence, and we can remove these impediments. So students may be the most obvious group of beneficiaries, but they are not the only ones.
> On Apr 10, 2023, at 11:45 AM, Attila Kelemen <attila.kelemen85 at gmail.com> wrote:
>
> Sure, sorry, didn't want to elaborate too long, and lose the main
> message (thus only the assertion), but here is my problem in more
> detail:
>
> The reason why I don't think it would be useful in general, because it
> only makes writing entry points easier, which would give more
> incentive to "#!/bin/java" (correct me if I'm wrong, but I vaguely
> remember that there is a JEP for java to auto compile java files and
> run them), but I find that to be optimistic, since if somebody wants
> something like that, the small extra boilerplate won't stop them. So,
> basically this JEP provides a minimal simplification of writing an
> entry point, and entry points are rare (compared to the rest of the
> code). This is merely my opinion, but writing out the small boiler
> plate for the entry point didn't bother me at all. Thus, I would say
> that this JEP provides little benefit to anyone but beginners. Or
> rather, I would throw back the question: What could I gain from using
> this? What value do I get from this as a non-beginner? (not trying to
> mock you, I'm honestly curious what am I missing here) I did see you
> mention on another list that abstract classes could have a main
> method, but if we want such a thing, that need not be tied to this
> JEP, and we shouldn't prevent future possibilities by introducing this
> JEP (such as easier writing of utility classes).
>
> Brian Goetz <brian.goetz at oracle.com> ezt írta (időpont: 2023. ápr.
> 10., H, 20:17):
>>
>>> While I like the idea of making the language more beginner friendly, I
>>> don't think the proposal in this form is the best way, because it does
>>> exactly what it claims to want to avoid: It introduces a separate
>>> beginner's dialect. That is, a form of writing code only to be used by
>>> beginners and never again.
>>
>> Since you provide no argument or examples to support your assertion, it is pretty hard to tell where you’ve gone off the trail here.
>>
>> But your claim that the features here are useful only to beginners and never again is simply incorrect. If you want to unpack your claim, perhaps we can clarify the disconnect.
>>
>>
More information about the amber-dev
mailing list