JavaScript is a common first programming language because of how easy it is. However, I learned Java, C, and C++ before JavaScript. I’ve always heard of JavaScript but never learned it until I took ICS 314 at UH Manoa. Our professor told us that the language was going to be a piece of cake. He was right, going through the material wasn’t hard for me, but I was a bit shocked at JavaScript’s rules because they were utterly different from what I was used to.
Java and C++ are statically type languages meaning you need to declare a variable type or return type explicitly. On the other hand, JavaScript is a dynamically typed language, so you don’t have to do that at all. It automatically declares the type for you, allowing for functions to take multiple data types of input and return multiple data types of input. It sounds convenient because there is less code to write for declaring data types. In my opinion, this feature makes it less convenient for me. Trying to understand the functions took more time since I was forced to figure out the input and output based on what was written instead of knowing it immediately. Therefore, the functions can cause unexpected behavior if not analyzed properly.
Additionally, you can use functions as parameters or return functions. Using functions as variables introduced asynchronous programming. With functions being able to be passed as parameters, it’s possible to have functions be called at particular times instead of sequentially. I found this pretty cool how code can be run from different points, and it made me realize how features on a website such as buttons worked.
I also thought that scoping rules for all languages were the same. For some reason, I came to that conclusion after learning C++ when I noticed the language used the same scoping rules as Java. That was debunked when I learned JavaScript. Variables are declared with var, let, or const, which each has its own function-level scope and closures.
Overall I feel that JavaScript lets you be creative with its flexibility of dynamic return types and variable declaration, and changing scoping rules with var and let. However, JavaScript’s flexibility can make the code hard to understand, so errors may arise at runtime in areas where I thought the automatic typing would be fine. Asynchronous programming using the concept of using functions as parameters is somewhat confusing for me to read too, especially since I’m still used to the rule of not allowing functions to be parameters. This is only the beginning though, so with practice and time, JavaScript will be like second nature.
In ICS 314, our professor taught us the term Athletic Software Engineering, focusing on solving timed coding problems. The coding problems are called WODs, known as workouts of the day. This analogy was very relatable to me because I used to be a soccer player and practices were workouts that improved my soccer skills. This process applies to programming too. When I learned Java in AP Computer Science my teacher gave us many timed coding problems. I applied this to my C++ learning by utilizing Leetcode for coding problems. Now I’m practically doing the same for my JavaScript learning. My Java and C++ skills improved fast when solving various coding problems and I’m sure my JavaScript will improve at a fast rate too. Alongside improving my skills, I find solving coding problems enjoyable because I love logical thinking. The intellectual challenge of figuring out what I need to use and how to use it really gets me in the zone.