5 ms·
I agree with you—I prefer explicit synchronization. But this isn't an accidental flaw in Java's design, it's the entire purpose of their chosen model. A lot of
by lolinder 3y ago
I agree with you—I prefer explicit synchronization. But this isn't an accidental flaw in Java's design, it's the entire purpose of their chosen model. A lot of people dislike the fact that async/await causes function coloring [0] and as a result may lead to duplication of sync and async version of functions. These people see Java as dodging a bullet and learning from past mistakes in other languages, so it's unlikely that Java will have anything comparable to async/await.
[0] https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
- lambda_garden 3y agoJava 21 is colorblind - but the colors still exist
- lolinder 3y agoYep, I agree. I tend to be a type system maximalist: I'd rather have everything that is possible to encode statically be encoded statically, even if it leads to less flexibility later. If you're starting a new Java codebase from scratch, you can create the structure where the language doesn't using classes, but it'd be nice to have syntactic support for it.
- kaba0 3y agoThis property is not really part of the type system though. Also, as mentioned by another commenter below - is a file exists operation async? Sync? Why, why not?
- wiseowise 3y agoWhat if file exists operation MUST be sync?
- lolinder 3y agoIn TypeScript at least, async-ness is encoded in the type system, because async/await is just syntactic sugar for Promise/then/catch.
- samus 3y agoVery simple - in Java, almost any IO operation in blocking. Exceptions are the stuff in the NIO package, thread interruption and signalling, and maybe process termination.
- jayd16 3y agoI wonder if we'll see Lombok markup for @OnVirtualThread or whatever the pattern shakes out to be.
- andrewaylett 3y agoLombok is unfortunately a separate programming language, albeit insufficiently distinct from Java. (Why? Because it uses internal compiler APIs to change the behaviour of code you write in ways that are not valid: annotation processors are supposed to generate new classes, not mutate existing classes.)
- samus 3y agoI went looking on their because for some reason I thought that an `@Async` annotation would already exist. But no such luck. If you want to use something like this today, then you could take a look at Spring 's Async support. It also lets you supply the Executor.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]