Learning Another Language: JavaScript Edition

Posted by Andrew Alteri on December 9, 2020

When I started learning to code, I was told that after your first language, other languages come much more easily. After spending almost a year on Ruby, I thought I would pick up JavaScript with relative ease. However, it turns out that each language has its quirks, and learning a new language is more difficult than I anticipated. I was disappointed that JavaScript did not automatically “click.” I wanted it to be Ruby, but it’s not Ruby. I wanted it to be fully object-oriented, but it’s not quite that either. JS is the most popular front-end programming language. I knew I needed to learn JavaScript. It was the necessary path and that path led me to appreciate JS more and that I should embrace new languages.

JavaScript was created as a scripting language, a mix of Java and Scheme. It was designed as a companion language to Java, where Java would do all the heavy lifting. Eventually developers realized that JavaScript could handle web development by itself, and they added the option to code in an object-oriented style. The rest is history. This history is important, because I found myself unprepared to tackle a language that is both functional and object-oriented.

My project is a simple trivia game. The player chooses a category, answers ten questions, and then submits their score to the high score table. The backend database is handled entirely by Ruby, so I only needed JS to handle the front-end rendering. At first, I had all of my code in index.js. It got messy very quickly, and I got lost in my own code. I was fetching from my local database and rendering questions, but the functionality wasn’t there. I did not build a single class, and I probably could not even explain my own code at that point. I had to start separating functions and creating directories that separated different elements of my game. Once I had a class that handled API requests, a class for my trivia game, and a class for my high score table, I was starting to feel more confident about my project. I could not only understand my code but also explain my code. I was still just getting my feet wet with JS, but I was doing it. I was building a game with JavaScript!

I felt confusion and frustration at times with this front-end language, but I also felt rewarding pride when I got my trivia game to work. I discovered that I enjoy the development process even when I don’t fully enjoy the language. I have a new curiosity for learning a language better suited for game development. I’m even wondering what it would be like to rewrite my trivia app with something like C#, Java, or Python. I have no idea what the outcome would be, but I am excited to attempt something new. That is what I learned from JavaScript: development is not easy and is not always fun, but it can be extremely rewarding when you venture into the unknown.