JEP 495 Question
Stephen Colebourne
scolebourne at joda.org
Fri Nov 8 09:20:59 UTC 2024
On Thu, 7 Nov 2024 at 21:10, Brian Goetz <brian.goetz at oracle.com> wrote:
> Here's the bar we're envisioning: methods that are automatically imported in this way _effectively become part of the langauge_. The bar for that is very high.
Making a method like readInt() "effectively part of the language" is
clearly wrong. And therefore obvious why it should be rejected.
But maybe the answer is to take a step back and reconsider whether the
"automatically imported" part of the sentence is a bad choice (which
therefore nullifies the "effectively become part of the language"
claim, effectively allowing readInt and friends).
The JEP ("Growing a program" section) asks users that migrate from a
simple source file to a normal one to add two imports:
import static java.io.IO.*
import module java.base
I'm OK with `import module java.base`, but I'm afraid I think `import
static java.io.IO.*` is a really terrible idea. Most production code
should not be using the console at all, it should be using some kind
of logging system. System.out is a hack. IMO, the "growing the
language" approach described in the JEP will end up over time
normalising console output in the minds of developers, with a negative
effect on production Java code.
Given this, and working backwards (IMO):
- Encouraging `import static java.io.IO.*` is a Really Bad Idea
- Therefore migrating from simple source file should therefore only
require `import module java.base`
- Therefore, simple source files should use IO.println(String), not
just println(String)
- Therefore, more methods can be freely added to IO, like readInt()
Yes, yes, yes. I know. `IO.println(String)` is more complex than just
`println(String)` for a beginner. But is it really that bad for a
beginner given the risk of normalising console usage?
Stephen
More information about the amber-dev
mailing list