🍫 CocoaPatterns — iOS & Mac Development Since 2009 RSS
🍫 CocoaPatterns
Because someone has to write this stuff down
"We ship apps. Sometimes they even work."

How I Forgot Everything I Knew About Programming and Thought Node.js Was a Good Language

Node.js is a runtime, not a language. I did not know this for almost four months.

EB
Elliot Baxter
@ebaxter_dev · CocoaPatterns

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.
            });
          }
        });
      }
    });
  }
});
📦 NPM

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.

3 Comments — Powered by Disqus
NP
n_patel_fullstack · 3 days ago
is-odd is CRITICALLY important infrastructure. You take that back.
EB
ebaxter_devAuthor · 3 days ago
@n_patel_fullstack I found is-even in my dependency tree as a SEPARATE package. The abstraction is what gets me.
ZQ
zach_q_ios · 2 days ago
847MB for a todo API is disrespectful to everyone involved including the disk.