Life after JavaScript: The Benefits of Learning a 2nd Language

Share this article

Silhouette of a person made from programming terms and language names

How many programming languages do you know? According to our recent survey, around 80% of readers know at least two. Well over half of you use PHP on a regular basis, and I’d be willing to bet a significant number started web development with the language, as did I.

Recently I decided it was time to think about adding another language to my resume (as if I didn’t have enough on my ‘to learn‘ list already). I ended up working my way through an online Scala tutorial. For anyone who isn’t familiar with it, Scala is a general purpose compiled language (like Java, it compiles to portable bytecode) with static typing. Although like JavaScript it’s a multi-paradigm language, it has a lot of advanced functional programming (FP) features found in purely functional languages like Haskell. If the recent popularity of FP has struck a chord with you, there’s much in Scala to get your teeth into.

Silhouette of a person made from programming terms and language names

You might be thinking “Why would I want to start learning another language now? I’m planning to work with JavaScript for the foreseeable future!” You probably also have a laundry list of JavaScript related things to learn. There are some good reasons to consider picking up a new language, though. A good way to really get to grips with concepts, such as static typing, or programming paradigms, such as FP, is to work in a language that forces you to use those things. JavaScript’s flexibility is part of its appeal for a lot of people, but it also allows you to side-step certain problems. Learning to write idiomatic code for that language will teach you different ways of looking at and approaching problems that will change the way you write JavaScript. Additionally, having the language restrict you to programming in a certain style will really help you to understand its strengths and weaknesses.

Exposure to these new paradigms, concepts, and styles of programming can be especially useful for those of us who are self-taught and don’t have any formal training. Computer Science graduates are likely to have seen many of these ideas as part of their studies. To get the most benefit, consider studying languages that are quite different from JavaScript.

It’s worth mentioning, too, that some currently popular libraries and patterns are based on ideas drawn from other languages. Redux, a state management library for React, is based on the data flow system in Elm. Elm itself is a transpile-to-JS language inspired by Haskell! Learning other languages can help you better understand these libraries and the concepts behind them. By staying within your JavaScript comfort zone, you’re relying on others to bring these insights from other language ecosystems and present them in a digestible way.

Learning new languages can also affect the way you see your primary language. When I started learning Portuguese, it changed the way I looked at English. When you are confronted with different ways of doing things, it forces you to look at how those things work in your native language. Instead of taking things for granted, you start asking why things are done one way and not another. Depending on the language, you may see similarities; with Portuguese and English, some verbs are close enough for you to easily guess the meaning, thanks to their Latin origin. The same is true of programming languages, especially if you are still on your first. Exposure to other languages will help you to think about the design choices that were made when JavaScript was designed. A concrete example of this is learning a language that supports classical inheritance and being able to compare and contrast with JavaScript’s prototypal object system.

WebAssembly (WASM), an experimental low-level language, is soon to begin shipping in browsers. Higher-level languages, such as C and C++, will be able to compile to WASM and benefit from smaller file sizes and better performance than code written in JavaScript. This will open up the browser to other languages, and you can bet it won’t be long before many of the most popular ones are able to compile to WASM. JavaScript creator Brendan Eich recently said he could foresee the possibility of JavaScript becoming obsolete at some point in the future. In all likelihood, JavaScript will continue to be important for many years to come, but having another language under your belt certainly won’t hurt your employment prospects and may help to avoid you being pigeon-holed as a JavaScript developer.

If you really don’t have time to dedicate to learning a new language, you don’t have to stray too far from JavaScript to get some of the benefits I’ve mentioned. Last week we published the second part of our Angular 2 tutorial series, written entirely in TypeScript. TypeScript is a superset of JavaScript, so most of what you know still applies. It adds static typing and concepts like interfaces and decorators (the latter will be making its way into a future version of JavaScript). Setting aside some time to experiment with TypeScript will give an insight into the difference between statically and dynamically typed languages, and will broaden your knowledge and employability as a JavaScript developer. As the default language for Angular 2 development, job prospects are good, and the concepts you learn will make it easier to pick up a language like Java or Scala in the future.

Can you program in a language other than JavaScript? What would you recommend as good second language for a JavaScript developer? Will WebAssembly change the game? I’d love to hear your thoughts, so leave me a comment below!

Frequently Asked Questions about Learning a Second Programming Language

What are the benefits of learning a second programming language after JavaScript?

Learning a second programming language after JavaScript can significantly enhance your problem-solving skills. It allows you to understand different programming paradigms and concepts, which can help you write more efficient and cleaner code. Additionally, it can increase your employability as many companies look for developers who are proficient in multiple languages.

How does learning a second language improve my understanding of JavaScript?

Learning a second language can provide a different perspective on programming concepts, which can help you understand JavaScript better. For instance, if you learn a statically typed language like Java or C++, you might appreciate JavaScript’s dynamic typing more. Similarly, learning a functional language like Haskell can help you understand JavaScript’s functional programming features better.

What should I consider when choosing a second programming language?

When choosing a second programming language, consider your career goals, the language’s popularity and demand, and its applicability to the projects you want to work on. For instance, if you’re interested in web development, a language like Python or Ruby might be a good choice. If you’re interested in system programming or game development, consider learning C++ or Rust.

How can I effectively learn a second programming language?

The best way to learn a second programming language is by doing. Start with the basics, then build small projects to apply what you’ve learned. Use online resources, books, and tutorials to guide your learning. Don’t rush the process; take your time to understand the concepts and syntax of the new language.

Can learning a second language make me a better JavaScript developer?

Yes, learning a second language can make you a better JavaScript developer. It can help you understand different programming paradigms, which can improve your code’s efficiency and readability. Additionally, it can help you understand JavaScript’s unique features and quirks better.

Is it necessary to learn a second programming language?

While it’s not strictly necessary to learn a second programming language, it can significantly benefit your career and programming skills. It can increase your employability, improve your problem-solving skills, and give you a broader perspective on programming.

How long does it take to learn a second programming language?

The time it takes to learn a second programming language depends on several factors, including your prior programming experience, the complexity of the language, and the amount of time you can dedicate to learning. However, with consistent practice, you can expect to become proficient in a new language within a few months.

What are some good second languages to learn after JavaScript?

Some good second languages to learn after JavaScript include Python, Ruby, Java, C++, and Rust. These languages are popular and in-demand, and they each offer unique features and paradigms that can enhance your programming skills.

Can I learn more than one programming language at the same time?

While it’s possible to learn more than one programming language at the same time, it can be challenging. It’s generally recommended to focus on one language at a time to avoid confusion and ensure a solid understanding of each language’s concepts and syntax.

How can I stay motivated while learning a second programming language?

Staying motivated while learning a second programming language can be challenging, but setting clear goals, working on projects that interest you, and celebrating your progress can help. Remember, learning a new language is a marathon, not a sprint, so take your time and enjoy the process.

Nilson JacquesNilson Jacques
View Author

Nilson is a full-stack web developer who has been working with computers and the web for over a decade. A former hardware technician, and network administrator. Nilson is now currently co-founder and developer of a company developing web applications for the construction industry. You can also find Nilson on the SitePoint Forums as a mentor.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week