this post was submitted on 30 Sep 2023
381 points (89.9% liked)

Programmer Humor

32077 readers
767 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 1 points 11 months ago (1 children)

Because it implies that synchronous code [...] [is] still quite popular.

it isn't?

[โ€“] [email protected] 3 points 11 months ago

I'm sure it is, I'm just not terribly happy about that fact.

Thing is, any code you write ultimately starts via input and funnels into output. Those two ends have to be asynchronous, because IO fundamentally is.
That means, if at any point between I and O, you want to write synchronous code, then you have to block execution of that synchronous code while output is happening. And if you're not at least spawning a new thread per input, then you may even block your ability to handle new input.

That can be fine, if your program has only one job to do at a time. But as soon as it needs to do a second job, that blocking becomes a problem and you'll need to refactor lots of things to become asynchronous code.
If you just build it as asynchronous from the start, it's significantly less painful.

But yeah, I guess, it's the usual case of synchronous code being fine for small programs, so tons of programmers never learn to feel comfortable with asynchronous code...