Does the programming language you use for coding interviews matter? The answer is yes.
However, the choice you make can impact your performance much more than you'd like to believe - and this is why it is important to pick a suitable programming language early on in your coding interview preparation - and use regularly in practice.
There are 3 considerations when deciding on which programming language to use:
- Suitability for interviews
- Your familiarity with the language
1. Suitability for interviews
Some languages are just more suited for interviews - higher level languages like Python or Java provide standard library functions and data structures which allow you to translate solution to code more easily.
Personally, Python is my de facto choice for algorithm coding interviews because it is succinct and has a huge library of functions and data structures available. Python also uses consistent APIs that operate on different data structures, such as
for ... in ... and slicing notation on sequences (strings/lists/tuples). Getting the last element in a sequence is
arr[-1] and reversing it is simply
arr[::-1]. You can achieve a lot with minimal syntax in Python.
Java is a decent choice too but having to constantly declare types in your code means extra keystrokes which results in more typing which doesn't result in any benefit (in an interview setting). This issue will be more apparent when you have to write on a whiteboard during onsite interviews. The reasons for choosing/not choosing C++ are similar to Java. Ultimately, Python, Java and C++ are decent choices of languages.
- Acceptable (but prefer recommended if you are familiar): Go, Ruby, PHP, C#, Swift, Kotlin
- Avoid: Haskell, Erlang, Perl, C, Matlab
- You must be mad: Brainfuck, Assembly
2. Your familiarity with the language
Most of the time, it is recommended that you use a language that you are extremely familiar with rather than picking up a new language just for using in interviews.
If you are under time constraints, picking up a new language just for interviewing is hardly a good idea. Languages take time to master and if you are already spending most of your time and effort on revising/mastering algorithms, there is barely spare energy left for mastering a new language. If you are familiar with using one of the mainstream languages, there isn't a strong reason to learn a new language just for interviewing.
If you have been using Java at work for a while now and do not have time to be comfortably familiar with another language, I would recommend just sticking to Java instead of picking up Python from scratch just for the sake of interviews. Doing so, you can avoid having to context switch between languages during work vs interviews. Most of the time, the bottleneck is in the thinking and not the writing. It takes some getting used to before one becomes fluent in a language and be able to wield it with ease.
Valid reasons to learn a new language:
- The interview requires usage of that language (domain-specific roles like mobile/front end/data science)
- You are not in a rush to start interviewing
Poor reasons to learn a new language:
- The company you are interviewing with uses that language heavily and you want to impress the interviewer/show that you fit in
- You want to show that you are trendy