Functions Redefined: How Javascript Challenged and Reshaped My Programming Methodologies

30 Aug 2023

Javascript’s Subtle but Powerful Capability

Write a function that takes in a temperature and its unit of measure. Return the temperature in another unit of measure, or if the passed in unit is not acceptable, return a message saying so. I was asked to solve this problem in a software engineering class. A straightforward problem that only took a few minutes to solve. Yet, for me this problem revealed the capabilities and practicality of javascript. I wrote a javascript function that took in the temperature and unit and returned the temperature in a different unit or a message that the passed in unit was not valid. The key piece here was that in every case I was able to return the relevant information, whether that was a number or a string. Such a small and simple detail that is easy to overlook, yet has powerful implications. Take this same problem in Java or C++ and you could not create this same functionality because in Java and C++ functions only return one data type. In javascript this phenomenon comes from the basis that “functions are first class”, meaning they are mutable objects. In practice this means that functions themselves can be passed as parameters or return values and that functions can return different data types. Learning javascript challenged these abstracted coding limitations that I had created when learning other languages.

Redefining My Programming Methodologies

I learned to code in college through classes. I took courses in C++ primarily along with classes about Java, python, and assembly to name a few. In my computer science classes I learned to “think outside the box” when problem solving, meaning break down my pre conceptualized constraints and instead look at the constraints the problem actually necessitates. Ironically, through learning these initial programming languages I subconsciously created constraints in the context of programming. I accepted the fact that functions return one data type and so if a problem required different types of returns, further processing was necessary to work around this. Perhaps on the driver code side with significant return values indicating errors, or maybe utilizing exceptions. Now when coding in some languages, yes this is true, but this is not the universal truth I initially accepted it to be. Learning javascript taught me to tear down coding constraints I once thought to be true and revealed to me what it means that different languages are better suited for different situations.

Javascript’s Potential

Taking all of this into consideration, I believe that javascript is a powerful language. This fast growing language challenges other languages in its functionality and underlying foundation. While every language has its place in its strengths and weaknesses, I am curious to see what sectors and topics javascript will continue to gain prominence in. Especially within and beyond the context of web development. As I continue to learn and use javascript I am curious to learn about the language from a security standpoint. I would like to look into what makes javascript secure or on the contrary what known vulnerabilities should be considered. Nonetheless, learning about javascript has made me much more excited to learn about web development, a statement I have not said before.