JEP-476 module import considered harmful
Brian Goetz
brian.goetz at oracle.com
Tue Nov 19 15:26:58 UTC 2024
Indeed, Archie. There are a lot of folks out there that would like the language to be in the business of enforcing stylistic choices, but this is frequently a misguided motivation. If you want to impose a stylistic preference on your own code, use a style-checking tool.
On Nov 19, 2024, at 10:12 AM, Archie Cobbs <archie.cobbs at gmail.com<mailto:archie.cobbs at gmail.com>> wrote:
I'd like to throw out a note of hope...? :)
I think there is a reasonable debate about whether star imports are "good" or "bad" but from the POV of language design that debate is made almost entirely moot thanks to the robust ecosystem of style checkers.
In other words, this is, in effect, just a policy decision that your particular organization can enforce, just like other style preferences such as whether to allow switch case fallthrough, whether to require curly braces around a one-line if/else branch, etc. If you don't like star imports, then have them cause your build to fail. Problem solved!
In this case, just because (a) Java enables a coding practice you don't like doesn't mean (b) you have to tolerate it in your own organization. The (a) and (b) are two separate issues with two separate debates and two separate resolutions.
-Archie
On Tue, Nov 19, 2024 at 8:38 AM Pedro Lamarão <pedro.lamarao at prodist.com.br<mailto:pedro.lamarao at prodist.com.br>> wrote:
Em ter., 19 de nov. de 2024 às 11:09, Cristian Mocanu <cvmocanu at gmail.com<mailto:cvmocanu at gmail.com>> escreveu:
Knowing that code is being read many time more often than written, I don't think it makes sense to optimize writing an import by hand (which no one does anyway - the IDE writes it for us) to the detriment of introducing confusion when reading the code outside an IDE (like a GitHub PR review).
Optimizing Java for GitWeb-like readers does not seem to me the way forward.
GitWeb-like products are themselves moving toward "AI powered web IDE" status.
--
Pedro Lamarão
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20241119/0855cca6/attachment-0001.htm>
More information about the amber-dev
mailing list