JEP 477 Interacting with the Console

forax at univ-mlv.fr forax at univ-mlv.fr
Tue Jul 16 15:45:54 UTC 2024


----- Original Message -----
> From: "Cay Horstmann" <cay at horstmann.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-dev" <amber-dev at openjdk.org>
> Sent: Tuesday, July 16, 2024 9:15:30 AM
> Subject: Re: JEP 477 Interacting with the Console

> On 16/07/2024 08.41, Remi Forax wrote:
>>> In general, the needs of beginners and authors of small programs are not the
>>> same. The JEP bounces between the needs of the two. Implicit classes are useful
>>> for both, but magic imports will add puzzlement for beginners.
>> 
>> I disagree, this is only an issue if you talk about "import", seing println as a
>> shorcut for IO.println is not a real problem.
>> 
>> The notion of "import" in Java is tricky anyway especially because most of my
>> students know Python so you need a full lesson about the difference between
>> Java import and Python import,
>> but that lesson can be taught in the second part of the semester when you need
>> "package".
>> 
> 
> Hi Rémi,
> 
> I agree that not having to talk about imports right away is a win. I am all for
> importing java.base.
> 
> I am not sure I get your point about shortcuts, though. I wouldn't want to talk
> about shortcuts any more than about imports. I would not want to discuss why
> there is a println shortcut but not parseInt or pow.

Shorcuts is not the right term, convenient is a better term.
This is the word we use to explain "var" too.  

> 
> Really, how painful is IO.println? (If that's too long, call it IO.out.) And it
> is consistent. IO.println. Integer.parseInt. Math.pow. Consistent is good for
> beginners. If further brevity is desired, there is an existing
> mechanism--static imports. Which can wait.

I think this is perfectly fine to not use "println" but "IO.println" instead and mention later that it can be abbreviated to "println".

> 
> The alternative is to go big, and to provide "shortcuts" for all beginner
> methods. println, parseInt, pow. Consistent and not puzzling. But of course the
> rub is, what are all beginner methods ?

and the fact that all these names polute the scope.

We have exercises where students rewrite simple functions like pow or parseInt, it would be sad if IO.parseInt is called instead of the method "parseint" defined by a student because the method call is written "parseInt(...)".

> 
> Cheers,
> 
> Cay

regards,
Rémi

> 
> --
> 
> Cay S. Horstmann | https://horstmann.com


More information about the amber-dev mailing list