this post was submitted on 21 Apr 2024
719 points (97.0% liked)

Programmer Humor

32371 readers
583 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
[–] zea_64@lemmy.blahaj.zone 2 points 6 months ago (1 children)

You really should be doing your IO async. Do you specifically mean callback hell?

[–] yogthos@lemmy.ml 1 points 6 months ago (1 children)

No I meant having to do async as opposed to having threads like you would in Java for example. In vast majority of cases a thread pool will work just fine, and it makes your code far simpler. Typically, Java web servers will have a single thread that receives the request and then dispatches it to the pool of workers. The JVM is then responsible for doing the scheduling between the threads and ensuring each one gets to do work. You can do async too, but I've found threads scale to huge loads in practice.

[–] zea_64@lemmy.blahaj.zone 1 points 6 months ago (1 children)

Green threads are functionally the same, especially in languages that can preempt.

[–] yogthos@lemmy.ml -1 points 6 months ago

Sure, but the scheduler figures out the scheduling automatically so you don't have to worry about stuff like blocking.