DEV Community

Cover image for Why Learning a Second Language Helps with Learning React
Kyle McKell
Kyle McKell

Posted on

Why Learning a Second Language Helps with Learning React

I started programming 3 years ago. Much like many people, I started my journey with Python, as I had taken a class in my freshman year in High School that had one section about coding in Python. I remembered enjoying making little applications using the turtle library, so I figured it would be a good choice.

I started out by making simple applications, just the basics, like making an app that has a user put in their age and if they've had a birthday this year and it spits out what year they were born, for instance. Very simple applications, but I got my feet wet, at the very least.

At some point during this Python process, I dropped coding altogether, not entirely sure why, but when I picked back up coding I decided that I wanted to devote my time to Web Development, as my job at the time prospected me to potentially start working under them as a developer.

While that never worked out, as I couldn't gain the skills needed to operate in such a codebase, in such a small company, in such a limited amount of time, I did get going with making JavaScript applications, much thanks to the wonderful curriculum at FreeCodeCamp.

Running into a wall

Over time, I found it harder to put my applications together, I was struggling more to understand what I was doing, and so many questions were left unanswered for me due to the abstraction and dynamic typing of JavaScript. I spent hours on CodeWars, and while I was able to solve these problems, I was confused on where to go next, everything seemed daunting and confusing. I felt unprepared for React, but slamming algorithm problems wasn't helping.

This was until I took Comp Sci 1: Java at my local Community College

I fell in love with programming in a whole new light. Java answered so many questions that I had with JavaScript.

The strong typing increased my understanding of how to write better code, and understood just why the strict equality was so important in JavaScript, just to name one benefit.

I eventually took the wonderful curriculum created by JetBrains Academy, since it was free for students at the time, and my knowledge of coding, computer science, and Java accelerated to an all time high.

Now, why does this have anything to do with learning WebDev and React?

Well, learning Java made learning React easier.

Connecting the dots

Java is a class based language, which put simply, separates everything in a type called a class. If you code in JavaScript, you likely are familiar with ES6 classes. These are very similar to how Java treats their classes.

React, before the introduction of hooks, was also class based primarily. If you needed to hold state, or have lifecycle to your components, you had to have a class component. These class components are strikingly similar to classes in Java

Allow me to explain:

Java relies heavily on inheritance, composition, and polymorphism, as it forces its users into an object oriented approach due to its class based nature. This teaches coders to learn best practices on how to not repeat their code, and find associations between different objects.

React is very similar in how it works. The concept of a component based framework (yes, I know React is a library) is to create components which then are reusable in the rest of your code, and to create sub components which are composed of their parents. (React does discourage inheritance, however).

As you can see, this is very similar in how both of these languages are structured. By learning a second language which forces you to accomplish the task needed by another language, you learn how to truly manage your code in a more controlled environment, which allows you to understand how to have your classes, or components, talk to each other.

What not to do

I would like to quickly take a section to mention some confusion which some of my beginner readers may need addressed.

While I do support the learning of a second language, as it helped me infinitely with my knowledge pool of coding, I do not recommend doing so until you run into a wall of questions that need answers, that can only be answered with a lower level language.

An unhealthy obsession that many beginners have is the "end be all" mentality of learning a coding language. They feel as if they need to choose the correct language or their entire career is going to be delayed infinitely, as if what they are learning goes out of "style", they'll be left with nothing.

However, this isn't the case, you should spend time with a language, learn how to make applications, learn how to solve algorithm problems, and learn the basics of programming before moving on to a second language. It is true that learning your second language is infinitely easier than learning your first, as most of the time, you simply have to learn syntax and a few quirks that the language may possess.

That being said, don't be afraid to reach out to a language (specifically lower level, such as C++, Java, C#, if you're learning JavaScript or Python), if you have questions which need to be answered, or you're struggling to write code that you feel is well written, sometimes a fresh slate is what you need to get something into your head.

Conclusion

Learning a second language saved me as a programmer, and helped me understand how to create better applications, and better code.

Do you have any suggestions? Leave them in the comments below, I'd love to hear your feedback.

Happy Coding!

Kyle

Discussion (0)