It dawned on me as I woke up this morning that there seem to be several common “ah ha!” moments among
first learning about asynchronous programming and how milliseconds matter. When you first use
apply(), you might begin to wonder about an execution context. Or even when you first try to write a
closure or an IIFE, that would probably be one of those “ah ha!” moments.
I thought it might be interesting to identify as many of those moments as I could from my own journey as a JS developer.
The Moment When JS First Seems Cool!
From my own Journey, I guess I’m a slow learner, because I thought it was dumb for a long time. And
then I started using
bind() to pass execution contexts between functions. I learned how
React passes these contexts and far more within the application, and it’s subtle and clever.
cool all on its own. My perspective changed.
Each Language Has a Vibe
I use several languages regularly now: JS, python, bash and some ruby. I consider JS and Node the same language with different toolboxes. But I would consider using python to be like driving a Cadillac or perhaps a BMW SUV type of vibe. Everything you ever wanted at your fingertips is right there, and there are plenty of extra buttons you never thought you needed or even heard of. But they’re right there. It’s extremely easy to to express your thoughts and can do it without exerting yourself.
Ruby is sort of like driving a Lexus or something. Lots and lots of convenience and economy and good sense. Occasionally you come upon something that doesn’t make sense. You scratch your head, but there’re are ten other ways of doing what you want, so you just move on with a small question lingering in your head. I would say the Ruby Lexus has buttons that leave you with that feeling.
Bash and its predicessors have lots of weird symbols and unique attributes, sort of like a Willies Jeep in 1944. Back then, the Jeep was the only thing you had available that would carve through war torn Europe where paved roads no longer existed. Likewise, Bash is clumsy in some ways, but aside from Perl and Python, Bash (and other shell languages) are the most direct way to talk to UNIX filesystems and handle I/O from other UNIX utilities. But there are a lot of weird syntax oddities.
JS/Node is unlike any of those. It strikes me like a French Citroen or something that I would not like at first, because it looks really weird, but once you start driving it around, you wonder where it’s been all your life. I’ve never driven a Citroen, but who knows? I might get that feeling if I started driving one a lot?
JS/Node is kind of alluring, because being skillful with it can get you a job. Those skills are in demand. Also, there are shortcuts available that make it appear sexy, such as ASI and bracket shortcuts and functions with rocketship operators. There are ways of making it terse once you become fluent in it. You can eventually say a lot by writing a little, just as in Python and Ruby.
But the real power of JS/Node is in the functional capabilities. IIFE’s, closures,
apply()–those are the gateway to the majesty of the language.
Using JS/Node is like driving some kind of exotic car (or vehicle) that looks weird but has unusual and powerful technology (like, a warpdrive or something). But you have to use it for a while before you can find the right buttons to push to make it work. And it still looks weird. There’s probably nothing to be done for that.