<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi David<br>
</p>
<div class="moz-cite-prefix">On 01/11/2023 21:23, David Alayachew
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAA9v-_MHQEQatD8pn2WkAoV7wMfKf9f8Zcysi-JYJnYPjrj0cg@mail.gmail.com">
<div class="gmail_default" style="font-family:monospace">1. In the
name of simplifying things for beginners, what is the reason why
the main method is specifically called "main"? Would not "run"
or something similar be better? The word "main" implies to me
that it is the "main" method (out of all of the others). But
that right there means I must be aware of the concept of there
being multiple methods. But again, that's forcing the beginner
to think about concepts that they don't yet need to. Most
students' first programs will be solely contained in a single
method.<br>
</div>
</blockquote>
<p>I believe calling it any name other than "main" would compromise
one of the main goals of this JEP, which is stated nicely in the
"Growing a program" section (I actually believe this section is,
IMHO, the most important one in the JEP, and the ones that is
driving many of the decisions contained in it!):</p>
<p>
<blockquote type="cite">Even so, all members are interpreted just
as they are in an ordinary class. To evolve an implicit class
into an ordinary class, all we need to do is wrap its
declaration, excluding <code>import</code> statements, inside
an explicit <code>class</code> declaration.</blockquote>
</p>
<p>Perhaps there's a more intuitive name out there - but regular
classes would still need a "magic" name to pick what they want to
run. And since "main" is the magic name that's been used for the
last 25 years, our hands were a bit forced here...<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:CAA9v-_MHQEQatD8pn2WkAoV7wMfKf9f8Zcysi-JYJnYPjrj0cg@mail.gmail.com">
<div class="gmail_default" style="font-family:monospace"><br>
</div>
<div class="gmail_default" style="font-family:monospace">2.
Alternatively, could we have the name be irrelevant if it is the
only method in the class? If we do that, then the concept of the
"main" method would be really impactful, because, once you
introduce the concept of multiple methods, students are likely
to ask themselves "which method will get run first?" In that
instance, the concept of a method called main wll be extremely
intuitive and understandable. I really like this idea. I feel
like we have an opportunity for a memorable "light bulb" moment
in student's minds. If they ask themselves which method will be
called now that there are multiple, the "main" method will make
perfect sense the first time. It will complicate that launch
protocol. For example, do we allow parameters? I say, it should
follow suit with "main" semantics.<br>
</div>
</blockquote>
<p>Again, quoting from the above section:</p>
<p>
<blockquote type="cite">Eliminating the <code>main</code> method
altogether may seem like the natural next step, but it would
work against the goal of gracefully evolving a first Java
program to a larger one and would impose some non-obvious
restrictions (see <a href="https://openjdk.org/jeps/463#Alternatives">below</a>).
Dropping the <code>void</code> modifier would similarly create
a distinct Java dialect.</blockquote>
So, it seems natural for an implicit class with one method to
behave exactly like an implicit class with two methods. Adding
special rules for an implicit class with one method seems ad-hoc
and likely to backfire. E.g. you add a method and your program no
longer compiles or, if you are unlucky and you call the second
method "main" now you launch that one instead, perhaps unkowingly.</p>
<p>Cheers<br>
Maurizio<br>
</p>
<p><br>
</p>
</body>
</html>