posted 8 months ago
OK let me ty this again. I posted this 2 hours ago, previewed for the usual glaring typos, published it and now it's gone without a trace.
I don't recall exactly what my main task model has been for Swing, but in more primitive times, there was an event loop and you dispatched off that loop. Swing internalized that loop, I think and uses callbacks. But it's still about the same thing, and for that matter, so are webapps, allowing for certain obvious differences.
Most UI actions are light enough to run synchonously, so a Swing app can directly issue I/O reads, database queries, and even some network interactions without any special support code in the callback/action processor. And a simple "x = stream.readLine()" is a LOT simpler than an awaited equivalent.
Here's one of the nightmares I've worked on, apologies for the length:
It's worth noting that someone has actually attempted to make a synchronous MySQL interface for NodeJS, but it was broken when last I checked.
You can tell how much pain it caused me to get to this point by looking at the commented code/log tracing.
Nor is it the only such abomination I've had to create. I have another that provices a ReST service. And another one in Python that has to do much the same thing in order to handle incoming Bluetooth Low Energy events. They were excruciating to write and no less so to maintain.
I'm a basically linear person. I can deal with fork/join and general multi-tasking, but the mess that systems like JavaScript employs is a real stresser. I can't just fork off a child and check on it whenever, I have to deal with the results in code that can actually precede in source form, though not in time, with what comes back. Which means that I have to keep the consequences in my head while I should be working on other operations. I get in constant fights about what methods to tag as async and await and where to put them. And when I design libraries like the one above, their callers have to be aware of the sync/async nature of the methods they call and code accordingly.
In short, it takes a lot of the fun out of software design.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.