I want to be very clear about something before I begin: I am a smart person. I have shipped apps to the App Store. I debugged a Core Data migration on a deadline and survived. I have read Apple's Concurrency Programming Guide and retained portions of it. I am telling you this so you understand the magnitude of what I'm about to confess.
I thought Node.js was a programming language. For four months.
"JavaScript isn't a bad language. It just has bad parts. And some of those parts are the whole thing."
The Callback Horizon
My introduction to Node was a simple REST API. "It'll be quick," they said. "JavaScript is everywhere," they said. Three weeks in, I had written something that worked, technically, if you traced the execution flow with a whiteboard and a quiet room and nobody asking you questions.
// Week 3. I thought this was normal. getUser(id, function(err, user) { if (!err) { getProfile(user.profileId, function(err, profile) { if (!err) { validateProfile(profile, function(err, valid) { if (!err && valid) { renderProfile(profile, function(err, html) { // We're 5 levels deep. This is fine. // I miss types. I miss knowing what anything is. }); } }); } }); } });
At one point my node_modules folder was 847 MB. I was building a to-do list API. I had a transitive dependency on a package called is-odd that had 14 million weekly downloads. It checks if a number is odd. It has 47 open issues. Nothing was okay.
The Reckoning
I am now back on iOS full-time. I still maintain the Node API. It works. I don't know why it works. I don't add features; I only apply security patches, gingerly, the way you might apply a band-aid to a wound you're afraid to look at directly.
I have been told Promises fix the callback problem. I have been told async/await fixes the Promises problem. I assume there is something that fixes the async/await problem and that it will be announced at a conference and everyone will be very excited about it.