JavaScript - Cure for the Common Code

18 Jan 2022

Every course I’ve taken on computer science has focused on a different programming language. The CS course that I’m currently taking has provided me with my first exposure to JavaScript. The first thing I noticed about this language that was different from Java, C, C#, and C++ is that variables are not of a set type. As I learned more about the syntax of this language, I noticed more differences about it that sets it far apart from anything else that I’ve seen thus far. While it seems a bit over-the-top in terms of user-friendliness, I would guess that this means there is a lot more going on behind the scenes and that it isn’t the most efficient language. While developing in JS seems simpler, it probably isn’t the ideal language for computationally heavy software and I’m guessing is better suited for user interface programs.

Too Easy?

One of my first impressions of JavaScript is that it seems rather forgiving to the developer. What I mean by this is that while learning this language through freeCodeCamp.com, I was able to solve most of the problems on my first try without gaining a robust understanding of what exactly my code was doing. To contrast this, I’d like to bring up the C programming language, which is what my last CS course focused most on. In that course, I gained a rather precise understanding of how C operated, from exactly how data was stored and all the possible ways to store and access it, to the subtle differences between the built-in output functions and how to use them without breaking the code. A lot of bugs I created were due to a lack of understanding of how exactly the language operated, and in these cases, the way that it operated was very unintuitive. JavaScript on the other hand seems very intuitive. While taking the lesson provided by freeCodeCamp.com on the extra syntax introduced in ES6, I was able to guess my way through some of the problems provided without having a clear understanding of the syntax. While obviously this means that I should study more, I think this is also a testament to just how intuitive JavaScript is.

Variables Are Whatever You Want

Applying my previous understanding of C makes me curious about how data is stored in JavaScript. In C, variable names have a data type associated with them when they are declared, and this association is what is used to interpret the data which is stored as bits. My guess is that in JavaScript, stored data must include a signature which indicates its type. Disregarding the details of how it works, I think it is pretty cool that this language offers the possibility of storing data of different types in a single array as well as allowing functions to return a non-predetermined data type. This feature would also reduce the burden of the developer in many cases, such as when integers would need to be converted to strings and vice versa.

Something’s Different About the Arrays

Something else that I noticed about this language is that it seems as though all arrays are dynamic by default. I think this might be an indicator of suboptimal data storage, but from a developer’s perspective, this is super neat! This relieves the burden of having to create arrays of variable size on the heap. Working with arrays has often been a hassle, but arrays in JavaScript along with their built-in functions seem almost too easy to use.

What’s Going on With the Functions?

One final topic I’d like to address is the use of functions in JavaScript. I was made aware through the lessons I took on freeCodeCamp.com that there is a lot of fancy minimalist syntax related to the creation of functions. I also noticed that functions can be assigned to variables. I am currently unaware of the significance of these things, but I have the impression that functions are used a little differently in JavaScript than any other language I’ve been exposed to.

Not Just Learning, Training

The professor of the CS course I am currently taking is very enthusiastic about his unique pedagogy. He applies concepts of athletic training to learning software engineering. The way this comes into practice is that rather than just learning a concept, we are expected to practice applying it multiple times. The concept is similar to how one would not just learn the motions of a workout and expect to benefit from that alone, but rather would repeat those motions over and over again so as to build those muscles and become better at that movement. I think this is a pretty neat idea. I typically have little trouble grasping new concepts, but being able to confidently apply those concepts while coding takes practice, and without that practice those concepts fade quickly. So far, the “Workouts of the Day” (WODS) have been pretty easy, but even so, they provided a good warmup for this course and I expect that I will get more out of them when they get harder. If you’d like to know more about this education practice, enter “athletic software engineering” into a search engine.