2 ms·
Would you kindly share them? I have a few reasons why node-style callbacks are absolutely the worst possible choice, so I'd like to compare. Here are some: 1
by spion 10y ago
Would you kindly share them?
I have a few reasons why node-style callbacks are absolutely the worst possible choice, so I'd like to compare.
Here are some:
1. Not values. Values can participate in expressions, can be passed as arguments to functions, can be returned as values from functions, can be stored in variables, arrays, etc. There are no values with node-style callbacks. You are throwing away half of the language capabilities regarding values and expressions.
2. No guarantees. Callback may be called multiple times. It may be called synchronously or asynchronously. There is no way to know what will happen.
3. Bad semantics for thrown errors. Its assumed that thrown errors will simply crash the process. This is a dealbreaker in node because every uncaught thrown error provides a vector for denial of service attacks, and the thrown error semantics of most libraries and the standard node library are pretty bad.