Javascript: The Best Coding Language?

17 Jan 2024

Programming languages are never perfect. They all have elements that are great about them and elements that make them quite frustrating to work with. Additionally, not everyone interacts with the different languages in the same manner. One person looks at Python and sees how it can be very user-friendly, others (like me) look at it and wonder where the semicolons are. C, Java, Python, Javascript and other languages vary in accessibility, capabilities, limitations, and libraries of functions. This variety can make different languages hard to compare in a way where one is “better” or “worse” than another. This essay will therefore not examine the “goodness” of Javascript, but rather its pros, cons, and unique functionalities. Javascript has great flexibility in its variables, functions, and notation, especially given the expanded ES6 version.

Javascript often seems to adopt a one size fits all approach and this is definitely the case for its variables. Javascript variables don’t have types. Instead the language opts to only specify a variable’s scope and mutability (i.e. var, let, const). This makes Javascript variables quite unique. For example, a variable could be an integer for the majority of a program and suddenly change to a string. This can be quite a shock to coders who came from backgrounds in languages such as C or Java. I, however, actually learned Javascript basics before learning other languages. So not having variable types was nothing new to me to learn. I’ve also experienced how this convention can be useful. It can reduce the amount of variables used and make the coding experience more dynamic, allowing variable types to change on the fly. But this does not come without a cost. Variable types being left unspecified can make code harder to read, trace, and ultimately harder to understand. These negatives, though, can be reduced by good coding habits such as adopting helpful naming conventions and having a healthy supply of comments. Thus, the Javascript’s variable types open up a new world that carries potential risk with it.

In addition to variables, functions in Javascript also have a fair amount of flexibility in comparison to other languages. In Javascript, functions are treated like variable types. This means they can be returned within functions and even passed as parameters. This is a functionality that many other languages do not have. These dynamic capabilities create a powerful tool in implementing tricky algorithms. As is seen with the variables, it seems like the Javascript developers wanted to give programmers flexible tools to use for software development. However, although I have not had much opportunity to use these unique function rules, I can think of potential problems that could arise with them. Functions as parameters, etc, will lead to complexity in the code, making it hard to read. It also seems that it could easily lead to mistakes, because code becomes too complex to understand well, or function within function calls causing runtime errors. Therefore, the complexity of Javascript functions can be daunting, but there also is a lot of potential here as well.

The final functionalities that will be discussed here are features brought by the ES6 version of Javascript. There are many changes that were implemented by ES6, but many of them share a common theme in simplifying or shortening code. For example, the destructing assignment allows assigning multiple variables from an array without explicit iteration. This saves a coder from writing many lines of code. It is helpful for programmers to implement however, for a reader it hides a lot of what is going on behind the scenes. Another new functionality in ES6 are arrow functions. This allows shortening function declarations and shortcuts in simple functions. This kind of feature reminds me a little of conditional operators in that it reduces the amount of code, but is harder to read. ES6 provides what much of Javascript is designed to provide, a lot of functionality. ES6 can be summarized as a bunch of new notations to learn that at first can seem difficult and unintuitive, but once mastered can lead to expedient programming due to the code’s brevity.

Javascript and the ES6 version update provide many unique tools to the table for software developers. As with any coding language, these benefits are accompanied by disadvantages as well. While the possibilities for these features are great, so are the possibilities of mistakes. Javascript’s features can give flexibility, however they can jeopardize readability at the same time. It really boils down to what a developer wants. Do they want to be constricted by a harsher compiler with more easily traced code or do they want the great potential that Javascript provides? Javascript isn’t a “good” or “bad” language. For those who are looking for flexibility though, it may in fact be exactly what is needed.