I’m going to start this post with what will appear to be a tangent. I assure you, it’s not.
My wife, wonderful as she is, is not
a very technical person. She is very caring, though, and will often listen to me talk about the technical things I am working on. This often means I need to use metaphors and similes to get my point across. I want to take a recent one I shared with her and share it with you.
Imagine two similar, but slightly different, worlds that both required you to use two languages to communicate. In both of these worlds, one of the two languages is your common tongue, your lengua franca
. You know it very well. Have studied it for years. You’ll never forget it. Sure, this language can seem, at times, primitive and without polish, but you know how to use it well, be expressive with it.
In both of these worlds, the second language, while based, in part, on the other language, is much more foreign to you. You haven’t used it as long. Fewer people speak it conversationally, it’s specialized and, to an outsider, might even sound like gibberish.
Now, in both worlds, in order to start any conversation, you must
use the second, more specific language before
you can use the first language. In these worlds, the first language lacks almost all context for understanding with out the second language. There is one catch, though, one major difference between these two worlds. In one world, only one word
from the more difficult language is needed to start your conversations. In the other, you might need to use hundreds
What On Earth Are You Talking About, Kyle?
APIs are the second language in the metaphor. By starting a dialogue, or rather a program or algorithm with them, we gain access to whatever methods have been expressed within the API. Once we are in the domain of these methods, we often can revert back to our native tongue, but not always.
The Two Worlds
Currently, I have myself in two worlds at the same time. For my day job, I work with Ember, and for all my side projects and talks, I work with React. To me, React is the first world. I only have to use a few words and some idioms from the language to get it to work. Ember, on the other hand, is the second world, where there are hundreds of words you need to know.
The First World
With React, the only word you must
know is “Component”. If you’re using ES6 classes and JSX, then the
method is the only “word” you need to know to get started. Sure, there are idioms like
The Second World
With Ember, there are many words to know. For starters, there are 40+ classes off the
module (according to the docs). There are methods upon methods to learn. Many having the same name as native data structures. Do I need
? When I use
am I getting? If an
, why do I need special getters and setters to get properties (two-way data binding, of course, I’m being rhetorical). Some of these methods are really
important to the overall ecosystem, like
isn’t enough to know, as there are methods on that method, such as
(literally, you have to write
Which Is Why…
I think this is why React devs speak with such passion about the library and why they feel so productive. Once you get started, you virtually never need to consult the documentation again because there are significantly fewer “words” to know. There are also fewer quirks to know (setState is async, that’s really the biggest one). You want to try something crazy? Just go for it with the language you already know. It’s how we’ve gotten great patterns like HOCs and render callbacks.