2 ms·
What I like about async and promises is there’s just enough bookkeeping to keep people from violating Keenighan’s law by too wide a margin. A little goes a long
by hinkley 2y ago
What I like about async and promises is there’s just enough bookkeeping to keep people from violating Keenighan’s law by too wide a margin. A little goes a long way, especially when any process could be handling several requests at once and make better use of the dead space between steps.
But a friend recently showed me how coroutines work in Kotlin and from my rather extensive experience helping people debug code that’s exceeded their Kernighan threahold, this seems a lot less footgun than nodejs. It’s far too easy to inject unhandled promise rejection in Nodejs. I think await should be the default not the exception, and Kotlin is closer to that.
- wruza 2y agoHow do they work in Kotlin? If it’s just: result = co_func() Then that creates an invisible yield point which messes with your “is this a critical section” sense. Suddenly anything may yield and your naive pt.x = getX() pt.y = getY() turns into the concurrency hell wrt pt’s consistency. I think await should be the default not the exception, and Kotlin is closer to that. I somewhat agree in that it should be an await/nowait keyword pair required at async calls. Not realistic though even in typescript, considering that Promise{} is just a continuation shell that may be passed around freely and doesn’t represent a specific function’s asynchronicity.
- hinkley 2y agoThe biggest problem with the Node/Javascript solution is that if I call a function and don’t need the result, if that function is changed to async (or I missed that it always was) end up with bugs because we didn’t await the result. When I say things like this people typically claim I’m bringing up some hypothetical, so let me be clear: I’m tired of fixing this bug. Not in my code (mostly), but in the code base. It happens too often both in a numerical sense and in a sense that it’s so stupid that it happens at all. It’s how I started thinking about this problem in the first place. The solution we have isn’t working very well.