4 ms·
I'm a bit uncomfortable with the overtly broad use of the term "callback" in the article ... most examples aren't callbacks per se, just higher order functions
by tpoacher 6y ago
I'm a bit uncomfortable with the overtly broad use of the term "callback" in the article ... most examples aren't callbacks per se, just higher order functions expecting function expressions as inputs (which may or may not act as "callbacks").
Is this a "in the javascript world everything is a callback" thing, or is the author just using the term loosely?
- Noumenon72 6y agoI agree. I started my notes on this under the heading "callbacks" but ended up under "functions". The article could be titled "Pass arrow functions and partials, not objects you don't control."
- kall 6y agoYep that‘s it. Most of the javascript world is very open to beginners and not that worried about being strictly technically correct, when it doesn‘t really matter. A callback is pretty much any function that you pass as an argument. It‘s still not as much a programming language community as it is a website making community.
- spion 6y agoCallback is technically correct. The specific type of callback that parent has in mind is a continuation callback. Maybe you should check your bias about the JS world (as well as your definitions).
- deleted 6y ago[deleted]
- Twisell 6y agoThanks for pointing out this confusion i'm a backend guy and anytime i have to deal with JS i keep wondering wtf people are talking about and if I'm dumb. Apparently they just switch words for free. This is not helping beginners and it make documentation and qa especially hard to search.
- spion 6y agoWhat would be the strict definition of "callback" ?
- z3t4 6y agoA function that will be called... a continuation. eg. "call me back when you are ready". or "call me when you are outside", "call me when you have arrived", "call me later".
- interblag 6y agoThe term "callback" is usually used to refer to a function that you want called after the completion of an async operation (like a database read, a file read, a network call, etc). This article uses the term callback but then uses functions passed to "map" as its examples; "map" is synchronous and so this usage of the term "callback" is atypical, probably atypical to the point that we can just say it's incorrect :).
- bryik 6y agoFWIW, Wikipedia's defines "callback" as "any executable code that is passed as an argument to other code; that other code is expected to call back (execute) the argument at a given time" and synchronous callbacks are mentioned explicitly [0]. I don't think Jake's usage of the word is atypical. 0 - https://en.wikipedia.org/wiki/Callback_(computer_programming) https://en.wikipedia.org/wiki/Callback_(computer_programming...
- Chris_Newton 6y agoThe term "callback" is usually used to refer to a function that you want called after the completion of an async operation I’m not aware of any authoritative definition, but the term “callback” has been used for functions passed in as parameters to higher-order functions since long before the modern idioms for asynchronous code were around. The first use of the term I can remember personally was for the comparator function passed to qsort in C. That was probably sometime in the 1980s. Another common usage that goes way back is for event handlers in event-driven systems.
- z3t4 6y agoIt's not exactly wrong as map does call the function passed to it. Maybe the topic was named such as to get up-votes as many people do not like callbacks (which is only a convention to higher order functions used extensively in Node.js for async, as JavaScript by itself does not have any async functions!)... The proper title would be something like: "Unexpected parameters when using Array.map and new Promise"
- paul_f 6y agoIt is articles and comment threads like this that make me glad I am not a Javascript developer :-)