At the start of my career, I often got the advice to learn PHP and stick with it — of course, sprinkled in a little bit of JavaScript. My colleagues reasoned that PHP had enough depth to learn.

Sometimes, I meet this argument in a different costume, arguing that it is bad that there are so many programming languages out there. This was the case just recently, so I decided to write down one of my main reasons why this is a blessing, and why we as software developers should make use of this and keep on learning new languages.

One of the most important reasons why I personally think that we should learn more languages is this: every good language makes you think in a different way about a problem or teaches us something about software engineering.

What does this mean? Let me tell you a personal example here.

From PHP To Ruby

As stated above, I started as a web developer with PHP some ten years ago. I worked on an old codebase that we were about to migrate to PHP 7 and Code Igniter.

It was about this time when I started to learn Ruby. At first, I really struggled with it.

The way Ruby iterates its collections was so different — and I struggled. The object-oriented (OO) concepts were so much more advanced — and I struggled. Metaprogramming was, and still is, really prevalent in the ecosystem — and I struggled. Yielding something from a method was something I never even dreamed of — and I struggled.

But I kept going and with time it made more and more sense to me. This was also the time when I really started to understand the good parts of object-oriented programming.

Then I applied more of the concepts I learned in Ruby to PHP, and my code got better and was more maintainable.

Benefits

I started to use the various Iterator interfaces for collection classes we had, and I saw a nice improvement in the readability of the code. I also dug a little bit deeper in PHP to use other more advanced OO features as well.

For the past couple of years now, I have been a Ruby/Rails developer, and I still love the language. The way you can express solutions with it is really impressive and I’m looking forward to using this language for quite some time.

Still, I always look at other languages and play with them a little bit. And sometimes, when a language really sparks my interest, I take a deeper look.

Functional Programming With Elm

Rails recently made some big improvements with the way you can write frontend code with it. It added a new framework called Hotwire (HTML over the wire). Still, I decided to learn Elm because I know it would teach me a lot of new concepts and ways to think about software engineering.

Since Elm is a functional programming language, this is a big paradigm shift that I am still getting used to. But I noticed that I can write very stable code when working in a functional way. This is the reason why I am using even more FP techniques in my Ruby code these days, which leads to better code and fewer bugs.

Elm is also the first statically typed language I really started to learn. I don’t like the way Java/C# work with static types, but I love Elm’s types and how extremely expressive they are.

Benefits

I’m still struggling with Elm’s types a bit, but I already see what they are able to do, and I’m fascinated by that. You can describe the state of your app in such a detailed way that it is highly encouraged to plan ahead so it is impossible to create an invalid state. Thinking this way about my problems helps me in Ruby as well!

When writing code these days, I also try to make as many functions as possible pure because I know I don’t have to worry about those.

Conclusion

From personal experience, I have to say new languages are great! They taught me a lot about how to write good code and how to make it more maintainable.

Of course, this could be done with a book about architecture as well, and in fact, I read some and really enjoyed them too, but a new language offers more because it keeps me more motivated to continue than a book.

In the end, this is a personal experience. It might not be the same for you. If so, this is perfectly fine. But, if you have never tried to learn a new language — and possibly one that is quite different than your main language — I encourage everyone to give it a shot. You really might enjoy the experience and learn quite a bit.

Happy coding!