Extension methods

Archie Cobbs archie.cobbs at gmail.com
Tue Apr 23 16:43:22 UTC 2024


I can no longer resist jumping in with an opinion... :)

>From [compiler-dev]:
On Tue, Apr 23, 2024 at 10:36 AM Ethan McCue <ethan at mccue.dev> wrote:

> What's going to suck to hear, but I think that you'll come around
> eventually, is that extension methods do not improve code readability. They
> make it harder to read o.method() since it would be ambiguous whether
> .method is an instance method or an extension method.*
>
> They *do* make it easier to write programs though. Without them you do
> have to write more characters and you do sometimes have to break up method
> chains.
>
> Historically, given a choice between code readability and code
> writability/terseness, Java has erred towards the first.
>

IMHO this is the heart of the problem. Personally I'm a fanatic about this
- readability is 100x more important than writability if you're writing
code which is going to be used & maintained for a long time (think
enterprise, i.e., Java's sweet spot).

FWIW here's my previous rant on this topic
https://mail.openjdk.org/pipermail/amber-dev/2022-November/007580.html
(that was in a discussion about making all exceptions unchecked...)

-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240423/eddb1d94/attachment.htm>


More information about the amber-dev mailing list