Damian Garstecki
5 min read

What I've learned from picking another language

Retrospective on my journey of learning Java as a PHP developer. You often hear: if you know any language well, learning another one is easy. But how many developers do you know who switched their main language? Not so many. Why? If switching were easy, we’d see it more often. In this post, I’d like to share my experience with switching languages.

We’ve all heard this quote:

It doesn’t matter what programming language you learn first, they are all similar. Later on, you can pick up any other language in a month.

It seems logical. All languages have the same building blocks: if, while, return, and so on. At the end of the day, they all compile into assembly. So all languages are the same with minor syntax differences, right? Well… yes and no. From my experience, this quote is only true at the ground level. If you want to go deeper than basic code, the discrepancies begin to show up.

I’d like to share a retrospective on learning Java as a PHP developer with over five years of experience. I made a transition from PHP to Java, but to keep this post relevant to other cases, I’ll keep my remarks general. I’m not going to comment on specific discrepancies between PHP and Java.

Thinking in a language

This is probably the hardest part of learning a new language, and the most shocking discovery I’ve made. After five years working in PHP, I thought I was a moderately competent programmer. That wasn’t completely true—I was a moderately competent “PHP programmer,” not “a programmer.” There is a difference!

To learn Java I did a couple of things; among them was a daily routine of solving kata challenges on Codewars—highly recommended. If you’re not familiar with the kata concept: you get a short task to solve, for instance “Write a program that will calculate the area of a triangle.” You submit your answer in a browser and your code is validated against a set of hidden tests. If your submission is good enough, you get points and can now peek at how other members solved the same task. Super helpful when you’re learning a new language.

What I immediately realized: while reading the task, I’d quickly think of a solution in code—that part was easy. But the code in my head was PHP. I was thinking in PHP. Then, subconsciously, I tried to translate my PHP solution into Java. I often ended up annoyed that my elegant PHP solution turned into an ugly block of Java.

Thinking in Java by Bruce Eckel
I finally understood the meaning of Bruce Eckel’s “Thinking in Java”

It was tempting to conclude that Java is simply the worst language. But the problem wasn’t the language—it was me. I was so used to writing PHP that PHP code became synonymous with code in general.

A new language comes with its own good practices and ways of doing things. Switching your mindset to look at old concepts in a new light is challenging. It takes time—and it’s especially hard when you learn after hours while still working 9–5 in your current language. But it’s doable!

Comfort zone

Writing in the same language or framework can be comfy. You spend thousands of hours with a certain toolkit; you know it inside out. Everything works, so there’s no reason to change anything. Picking up another language can be an eye‑opening experience. You’ll quickly find that the dogmas from your world might not exist on the other side of the fence. Even things you consider universal truths may be unheard of by other developers. You’ll learn their side of the argument—their point of view—which will only strengthen you as a developer. You might end up more knowledgeable about how some ideas came to life—when they work and when they don’t. Additionally, you might find solutions worth adopting to improve your toolkit. If you’re not keen on any particular technology and just want to pick up something new, I strongly recommend choosing something distant from your world.

Do you work in a scripting language? Try a compiled language. You’ll be amazed how compilation time changes your workflow.

Or, do you work in an OOP language? Try a language with a more structural or data‑driven emphasis. It requires a complete change of mindset.

So what I’ve learned

I believe that by learning another language you become a more well‑rounded programmer. You learn other ways of doing things and see the world through a wider lens. Exceptional people from many disciplines do similar cross‑training. Former F1 driver Robert Kubica did rallying to expand his racecraft. It’s healthy to do the same as programmers.

My tips if you want to learn a new language:

  • know why you want to learn a new language; think it through, and let that goal motivate you through the whole process
  • it’s a marathon; don’t expect immediate results—the start can be slow and annoying
  • be consistent with your training
  • engage with the community (discussion forums, local user groups, conferences, etc.)
  • if you want to learn a new language but don’t know which, try something different from what you use day to day
learningcareerlanguages