Damian Garstecki

back end developer

What I've learned from picking another language

· 5 min read

Retrospec on my journey of learning Java as a PHP developer. You might hear that - if you know any language well, learning another one is easy. But how many developers do you know switched their main language? Not so many, why? If switching is easy, we should have seen it more often. In this post, I would like to share my experience with switching languages.

We all heard that 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 consist of the same things, you got your if, while, return, and other statements. At the end of the day, they all compile into the Assembly. So all languages are just the same with some minor differences in syntax. Right? Well... yes and no, from my experience, this quote is only true only on the ground level. If you want to go deeper than just writing basic code the discrepancies become to show up.

I would like to give retrospect on my journey to learn Java as a PHP developer with over 5 years of experience. I've made a transition from PHP to Java, but to keep this post relevant to other cases I will keep my remarks on a general level. I'm not going to comment on any specific discrepancies between PHP and Java.

Thinking in a language

This is probably the hardest part about learning a new language, and the most shocking discovery I've made. After 5 years working in PHP I thought I was a moderately competent programmer. This was not completely true, I was a moderately competent "PHP programmer" not "a Programmer". There is a difference!

To learn Java I've been doing a couple of things, among them was a daily routine of solving Kata challenges on Codewars - highly recommend. If you are 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 now you can peek how other members solved the same tasks. Super cool if you are learning a new language.

What I immediately realized: while reading the task I would rather quickly think of a solution in code - I had no problem with that. But the code in my head was a PHP code. I was thinking in PHP. And then at my mind, subconsciously I've been trying to translate my PHP solution into Java code. Often end up being annoyed that my elegant PHP solution was an ugly block of code in Java.

Thinking in Java
I finally understood the meaning of Bruce Eckel's ''Thinking in Java''

It was tempting for me to conclude that Java is simply the worst language. But the problem was not a language, but me. I've been used so much to write PHP code that PHP code was synonymous to me to code in general.

A new language comes with its baggage of good practices and ways of doing things. Switching mindest to look at the old concepts in the new light could be challenging. It will require time and that will be especially hard when you try to learn a new language after-hours while still working 9-5 in the current language. But this is doable!

Comfort zone

Writing in the same language or framework can be a comfy situation. You spend thousands of hours within a certain toolkit, you know it in and out. Everything is working great for you, there is no reason to change anything. Picking up some other language can be an eye-opening experience. You will quickly find out that dogmas that live in your world might not exist at all on the other side of the fence. Even things that you may think are universal truths may be unheard of by other developers. You might learn their side of the argument, their point of view. Which will only strengthen you as a developer. You might find yourself more knowledgeable about how some ideas came to life - when they work and when they don't. Additionally, you might find some solutions to be valuable to improve your toolkit. If you are not keen on learning any particular technology, and just want to pick up something new. I would strongly recommend picking up something distant from your word.

Do you work in a scripting language? Try to pick up a compiled language. You will be amazed how compilation time changes your workflow.

Or, are you working in OOP language? Try to pick up a language with more structural/ data-driven emphasis. It requires a complete change of your mindset.

So what I've learned

I believe that by learning another language you become a more full programmer. You learn about other ways of doing things, you can see the world in a wider picture. Exceptional people from many different disciplines are also doing similar things. Former F1 driver Robert Kubica was doing Rallying to expand his racecraft. It's healthy to do the same things as programmers.

My tips if you want to learn a new language:

  • know why you want to learn a new language. Think that through, that goal has to motivate you through the whole process
  • it's a marathon, don't expect imidate results, the start could be slow and annoying
  • be consistent with your training
  • try to engage in 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 than what you use day-to-day