by dpcan · 4y ago · 0 comments
It’s such a strange take in the coding world. I don’t know why other developers get to decide what is clean, simple, easier to understand, etc, when it comes to my code or the way I write code.
I’ve been using xmlhttprequest for YEARS and honestly, it’s pretty dang simple. It’s pretty darn clean. And when we see it, we know what it’s doing and how it works.
I’m not sure of the motivation behind changes and new API’s like this that keep trying to fix what really isn’t broken for most uses.
Please explain the latter bit again.
I too see no need to switch suddenly to this fetch api when older browser support is important to my daily driver web app. I found the tone of this article condescending when browser apis have mega committee-ware battlescars all over them and likely implement both of xyz with the same call to epoll anyway, (joke about systems programming)
if (xhr.readyState !== 4) return;
is gross and stateful. Certainly you can learn it and use it but .then((res) => res.json())
is much more declarative.Not saying XMLHttpRequest API's is brilliant, but fetch's API also doesn't exactly fill me with joy.
These strange notions of burden and beauty…
IE, this is why async / await was added to JavaScript: The code is significantly easier to read (cleaner) than promises.
They're all missing the point, frankly. The point is, we're stuck in this vicious cycle where we all get selective amnesia and forget why someone was invented, and we decide that it's old/ugly/unergonomic/ungraceful/unclean/unsimple/etc./etc. and invent something new. Woe to them that love the fetch API, and fall into a time warp to 2005 when everyone was singing the praises of "AJAX". You'd be bowled over by the sheer culture shock. (Likewise, I can't wait for 2035, when we'll have invented some emoji-based way to represent fetches, and those still using fetch() or axios() will be seen as hipsters/clueless).