Hey, did you feel something? I hope not.

I've deployed a new version of the One Post Wonder source code. And it should be... exactly the same, for you. If not, please let me know.

For avoidance of confusion: if something seems busted, it's not you, it's me. Let me know. Thanks! I did lots of testing. But... software is hard.

Just in case, my email is tommybgoode@gmail.com. If stuff broke, tell me things ASAP. Thanks!

What Changed

"So... if everything is the same... what's different?"

I rewrote the code using a modern idiom that other programmers will be able to follow. Which makes it more practical for others to help me move OPW forward. It's a hell of a lot easier for me to maintain the code as well.

You see, back in the Bad Old Days, Node.js programming was like this:

"Hey Jane, fetch me some blog posts, then call me." [Hand-sign of phone]

"Hey Jack, when Jane calls me, fetch some comments, then call me." [Hand-sign of phone]

"Hey Joe, when Jack calls me after Jane calls me, fetch some images, then call me." [Hand-sign of phone]

Except dozens of requests are coming in at once so it's like a telethon in there with only one person manning the phones and everybody wants a fucking tote bag and theoretically that's OK because you don't actually speak continuously to one person right, so...

AAAAAAAA yeah complete madness.

In the New Idiom, Node.js JavaScript programming is like this:

MOTHER MAY I fetch some blog posts.

MOTHER MAY I fetch some comments.

MOTHER MAY I fetch some images.

Behind the scenes, it's the same telethon, but the management of all that parallel madness is encapsulated in the magic words "MOTHER MAY I," which allow us to express what we need to do as a simple series of steps and let JavaScript sort it out behind the scenes.

An astute observer will note that I still have to say "MOTHER MAY I" before each thing. I can't just do the fucking things. Which is still weird and unintuitive. However, in modern JavaScript "MOTHER MAY I" is expressed in the single word "await," which is at least convenient and readable. Crucially, it's at least readable by people who don't do this all day and who don't know this particular codebase by heart.

And the performance benefits are real enough that these days, Ruby, Python, PHP and even Rust optionally offer the same thing for those who need the speed.

So, we've got that going for us.

[Waves tattered flag]

Wait. Why do we do this?

A person might ask why programmers put up with any of this. Java and Python and Ruby and frickin' PHP all let you just write:

Do a thing

Do another thing

Do a third thing


So why would you put up with this "MOTHER MAY I" bullshit from JavaScript?

Well... because it's fast. Most languages for the web give you a separate thread, aka basically a completely separate telethon volunteer, to think about each request, aka person calling to get a tote bag. Which is enormously convenient. But, also slower because you're not maximizing the throughput of your telethon volunteers.

And... you have to write JavaScript for the browser anyway. To a first approximation, at least. So you may as well double down and use those skills on the server too, right? Less mental context switching. Which gives you plenty of energy for typing MOTHER MAY I! This is sane. [Nods firmly]

Um... great! What's next?

"So what's next?" New features? Probably new features. I promised alt attributes a LONG time ago.

Probably also breaking up that massive "routes.js" file into separate collections of API routes by topic, so I can find stuff.

Probably also TypeScript, just so I can put "8 billion years TypeScript experience" on my resume.

Thank you sir, may I please have another?

"What's TypeScript?" It's a new flavor of JavaScript that is "strongly typed." That means you have to say "MOTHER MAY I" even more often and in twisty new ways... but, if you fail to say it in exactly the same way when you try to call that same code later, it'll stop you and say "uh-uh, that's going to introduce a bug."

So it's a good thing.

One may well ask: does that mean TypeScript can check the original "MOTHER MAY I" incantations (aka "await" keywords) to make sure none are missing? That would be seriously useful.

Oh gosh no, it can't do THAT.  Who would want to catch by far the most common source of bugs in a Node.js program? No, it only stops you if you pass a string instead of a number (*), which I practically never do.

But I hear you can do it if you combine TypeScript and eslint and a roll of duct tape. So maybe I'll give that a try.

(*) Yes, yes, and a thousand more complicated but ultimately similar things.

2/2 '23 2 Comments
Test. Hi.
Looks like it works. Success!