4 ms·
> The code is generally messy and horrible, rife with race conditions and barely holding together in parts. Writing robust asynchronous code is very, very hard
by jakobegger 10y ago
> The code is generally messy and horrible, rife with race conditions and barely holding together in parts.
Writing robust asynchronous code is very, very hard. My biggest mistake as as a beginner was that in the early days I just made up all my multithreading stuff on the spot. I made a synchronous prototype, and thought, perfect, now I just need to make it asynchronous.
Now I understand that "making it asynchronous" is more work than coming up with the initial implementation, and spend a lot more time on that.
I spend a lot more time on planning in general. I sometimes think about features for weeks or months before I start programming. I'll read all the relevant API docs, search Google to see if other people have implemented similar things before, etc.
Only then, when I'm well-prepared, I actually start coding. And the actual writing is usually pretty quick, but it needed a lot of (invisible) preparation time to get there...