A friend of mine was teaching herself React and got confused by how the this
keyword worked in JavaScript. Someone told her it was like self
in Python. It’s not. So I typed up a longish Gist on how this works and how it applies to React. It’s not the only explanation of this
out there, but I couldn’t find one that tied into React, so … there it is.
Hopefully, that’s accurate.
Anyhow, the bigger problem here is that she started learning React from a bunch of tutorials without a solid grasp of JavaScript fundamentals. My guess is that she wanted to learn React, learned just enough JavaScript to understand the React Hello World tutorial, but never got to the part about how this
works and got really frustrated when she started running into weird behavior related to how React does (or used to do) auto-binding.
It’s not a new problem. Every so often, a new library or framework takes off and everyone goes, “Oh, I should learn that *thing* now.” And that *thing* is often built on other libraries or languages or abstractions but no one really wants to learn all of underlying fundamentals of the hot new thing, but the fundamentals aren’t really all that hot themselves. Like JavaScript and React, and before that, JavaScript and jQuery (cue all the Stack Overflow searches for “how do I do this in jQuery” when jQuery isn’t at all necessary, or useful). Or Python and Django. Ruby and Rails. Databases and ORMs.
Basically, folks read the tutorial for the new thing, and learn just enough of the old thing to get going with the new thing, but not enough of the old thing to really understand what’s happening behind the scenes of the new thing and get frustrated or bogged down when things stop working.
But I can’t really fault people for that. It’s tempting to say that everyone should understand every last intricacy of a foundation before moving on to a higher abstraction or interface. But that just isn’t realistic. I like to imagine I have a pretty strong grasp of how JavaScript works, but every so often I get the terminology wrong or encounter something new about the language myself. And while I might know JavaScript, I don’t really know how the various compilers out there work. I haven’t touched C or C++ in a really long time. And Assembly is a complete mystery. Understanding every last step from machine code to JavaScript would probably make me a better developer. But depending on the application I’m developing, it’s hard to say that it’s the most efficient use of my time to learn Assembly.
Which is all to say — it’s tempting to think of programming as this exercise in mathematics where we start with axioms and build up super fancy theories from there. But in practice, it’s more like archaeology. You start from the top and work your way down. You’ll probably never reach bottom. All you can do is just o reconstruct things and create theories of how everything works as you go along.
Comments