Improving My Work in Vanilla JS Despite Working Through a Library
I’m having to write commands in such a way that will help me better understand the tools available in a library I’m working in.
A few days ago, I wrote about frameworks and libraries versus base code. In discussing Express and Mongoose, I wrote:
… while the two frameworks make things easier in terms of the tasks they’re built to handle, relying on them makes me feel like I’m utilizing a tool without really understanding how it works, and I don’t like that. Part of me wants to just push forward with these tools because they’re easy and it means I’ll be up and running with my bot faster. However, the rest of me considers this and thinks “at what expense?” Nay, I want to really truly understand what’s happening under the hood of what I’m working with.
Over the course of a series of articles and tweets, I’ve expressed my distaste for this reliance on frameworks and libraries to handle absolutely everything. Articles I read about tools being developed require the use of two or more libraries: “Let me show you how to do this thing, and we’re going to do it with this library and that library.” It seems like the only time I come across articles and videos that aren’t reliant on some library or framework are those that deal with the objects and methods of the vanilla language specifically. If want to learn about the .reduce()
method, there are plenty of articles that discuss it. However, if I want to learn how to parse a url, well, there are plenty of libraries that will help me do it if I follow along with the tutorials.
The general idea, then, becomes about learning libraries rather than getting good at building shit with the base language. And I don’t want to focus on that.
However, I’m beginning to feel as if I have to. In doing research on building a Discord bot, I learned that there are a handful of libraries that are approved to use the Discord API, and to attempt to develop a separate library from these is discouraged. Reading through the documentation, I can understand why. Part of me wants to be able to use vanilla JavaScript to build the thing, but I also don’t want to be permanently banned from development should I mistakenly do something that is not permitted. So I feel I find myself in a state of hypocrisy: rail against the reliance of libraries to do your work, but also let me rely on a library to do my own.
Were I an experienced programmer, I probably wouldn’t have this dilemma. Knowing enough about what I’m developing and how to go about it, I may be able to forego using a library, or perhaps I’m library-happy as well. Whatever the case, that’s not where I’m at, and I find myself begrudgingly utilizing a library because I have no idea how to go about what I want to build otherwise.
“Fine, I’ll go, but I’m going to complain the whole time.”
The added challenge to this is that I have to learn all the working mechanisms of the library. What are Collections? How are objects organized? This method is supposed to produce an array, but the array comes up empty, and it shouldn’t. Over and above the struggle I have with vanilla JavaScript, I’m now in a position to learn and understand how the methods and tools in this library work. It’s not necessarily a bad thing, I suppose, but it’s certainly far more than I expected when I started down this path.
As it stands, I created a new command that serves one function only: to log everything to the console so I can understand wtf happens when I use whatever tool. It feels a little laborious, but there are two things that are happening as a result:
- The obvious, I’m learning what everything is and does in the library. But also,
- I’m becoming better versed at understanding means and methods in JavaScript. When something calls up a
.map()
method, I’m coming to have a better idea of what’s going on without having to wade through pages of documentation.
Ultimately, the way things are going is not ideal. However, I can still find opportunity to learn and improve my understanding of vanilla JS despite working within a library. I’ll take it.
79/100