I Made My First JS Library. Here's What I Learned.
Tags: javascript, jslibrary, showdev
Published: 2021-07-09 22:15:02

I'm fairly new to programming, in fact, I've started to get the gist of JS in the last few months. So I never thought I could create a well functioning web app let alone a library. Here's how I did it and what I learned from that experience.


## The Problem 

It all began 3 months ago, around March 10th. I had no intention of creating a JS library. At the time, I was trying to learn how to use the command-line, when I realized that **the command-line was quite intimidating for newbies like me.** 

## The Solution
My idea was simple, create a web app that serves as a playground for CLIs, but a lot friendlier and holds the user's hand while they develop their skills.

## but...
How was I going to create the command-line aspect of the web app? I had some initial bad ideas, so... I went with the least bad one I had.
I could technically use JavaScript to emulate the most common commands I could think of, and go from there. 

## Overcoming the Challenge
After a month of trying, failing, then trying again, I had something. I managed to create the v1 of a simple "Bash Simulator" with JavaScript. I won't get into the details but here's how it worked. 

First, you type up your command and press enter. Then, your input is converted into a list of words. The first word would be the command name, and the rest would be parameters. The command name would reference a function that would be executed with the parameters from your input. Simple right?  
 

## great, now what?
Well, at this stage, I realized I could do so many different things and go so many different ways with it. What if I decided to create something like it in the future? Or projects with the same features?


## The Library
After really taking my time and humming over the idea for 2 seconds, I decided to turn the JS code I had into a library. This way, I could create something else with it in the future, and I wouldn't have to reinvent the wheel. 


## ahh... sh*t
I had something working, but now I had to make it flexible enough to be able to use it in a variety of different projects. Also... turns out libraries are bundled a bit differently. AND... it didn't have a way for a developer to extend and build upon it. 

So I had to rewrite everything from scratch with new type of users in mind, the developers that might use this library in the future.

So I spent few more weeks to creating v2.


## Conclusion
So I spent 2 months creating something that no one else will probably use. But that's not all to it.
1. My skills in JavaScript improved a ton, though I still suck at it.
2. The way I approach problems and go about solving them has definitely improved as well.
3. My project management skills have also improved, though I'm still messy. 
4. AND... now I have my problem solved and can proceed to creating that website I mentioned earlier.

Wheather someone will actually use it or not, it feels incredible to create something and make it open source. And I wouldn't have learned and gained more skills if I hadn't taken on this project. 

Anyway, here is the [link](https://github.com/anas2479/bash-mirror) to the project if you want to check it out.    


Any comments?