5 ms·
As a C programmer working with a large codebase, I have come to HATE callbacks. Seriously, the worst feeling ever is tracing through a huge function tree, only
by zump 10y ago
As a C programmer working with a large codebase, I have come to HATE callbacks.
Seriously, the worst feeling ever is tracing through a huge function tree, only to run into function pointer dereference. Then you have to go on a wild goose chase to find out when, where and what it will be assigned to.
STATIC TYPES PEOPLE.
- MrBuddyCasino 10y agoAs a C beginner I don't like them either. But are there techniques to avoid them? Take for instance nghttp2 which needs callbacks to handle I/O.
- pwdisswordfish 10y agoWhat does it have to do with static typing? Function pointers are perfectly valid types. Also, can't you just use a debugger?
- dahart 10y agoC/C++ callbacks are fairly different in practice than what the article is talking about. You might like callbacks in JavaScript. You might really like promises -- no wild goose chase to track down the chain, because promises chain things explicitly and make async code look more synchronous. What's most interesting about your point is that what the article suggests -- naming and de-nesting callbacks -- is in a way what you're warning against. By naming it and physically moving it, execution that was contained within a single block of code is now jumping around, and can move to other places where you have to go looking. Even though it's considered an anti-pattern for good reasons, there are some advantages to nested callbacks.
- dllthomas 10y ago> STATIC TYPES PEOPLE. What you are asking for is much more closely related to static dispatch than static typing.