← Back to context

Comment by nielsbjerg

6 years ago

Productivity in this case being in the eye of the beholder? I’d argue that people experienced in how node works, wouldn’t have to think too much, since async is the default. I agree with your general sentiment though.

Async by default can often lead to weird race conditions if you are not careful.

  • Yes; you still need to lock/synchronize shared resources in an async context. Even if the environment is single-threaded.

    • Do you have an example?

      If it is single threaded, and we are talking about shared variables, I thought I can assume the runtime is not going to pause my code execution, switch context, and run other code midway through my call back handler.

      If we are talking about shared external resources (e.g. who can update a cloud blob) then we could have a proxy for that as a variable. You might need retry logic, and it could get tricky in that respect.

      3 replies →

  • I’d then have node handle the “simple” socket part, and the complexity which is race condition prone, handled by a language better suited for that, responding to the async node implementation? Edit: spelling