r/java • • 7d ago

Evolving the Java Language: An Inside Perspective

https://www.youtube.com/watch?v=fJP3s1A5jGY
122 Upvotes

29 comments sorted by

View all comments

Show parent comment

45

u/brian_goetz 7d ago

Don't flatter yourself; folks here have no monopoly on this disease :)

1

u/aonymark 2d ago

Since we’re talking about syntax, and you mentioned that the proposal for collection literals failed for syntactic reasons (reserves too much syntax for too little gain)… may I propose an idea? (Yes, I remember, ideas are cheap but bare with me anyway)

Just use target typing! That is, {1,2,3} on its own is a syntax error, but I can use it when initializing an int[]. Why not a CopyOnWriteArraySet of int? Just need some rules for what this desugars into, maybe with a fallback chain (prefer static of() method if exists, else constructor, else sequence of calls to add(), or something)

Map is maybe a bit trickier but hopefully doable.

2

u/brian_goetz 1d ago

“Just” indeed :)

Also, ten billion yard penalty for non-consensual syntax pestering.

1

u/aonymark 1d ago

Fine you don’t want syntax pestering? I can pester about something even more annoying. Ever since the mailman upgrade, there’s no self service way to unsubscribe from a Java mailing list, or switch to digest mode. This discourages outsider contributions, since they can’t count on being able to ever unsubscribe so they’re don’t dare to subscribe in the first place.