There are updates to this page that haven't been applied because you've entered text. Refresh this page to see updates.
Hide this message.

Do interviewers frown at potential hires when they use Ruby or Python to solve an interview question?

People often suggest answering interview questions in C, C++ or Java. Do interviewers frown at you if you use Ruby or Python instead to solve an interview question?
Edmond LauEdmond Lau, Engineer at Quip
292 upvotes by Quora User, Quora User, Shrikanth Shetty, (more)
Having interviewed a few hundred candidates across Google, Ooyala, and Quora, I would contend that the situation is quite the opposite, particularly if you're interviewing at the faster-moving end of companies like the typical startup.  The choice of programming language matters, and most candidates I've interviewed who can only code in C, C++, or Java put themselves at a competitive disadvantage relative to those who use Ruby or Python.

In an engineering interview, you typically only have thirty minutes to an hour to impress your interviewer and to demonstrate that you can solve technical problems and get things done quickly.  The faster you can complete a problem correctly, the more quickly I, as an interviewer, can move onto harder problems or assess your other skills.

Your choice of programming language is therefore important to the extent that it affects the speed with which you can solve problems.  Languages like C, C++, or Java tend to be significantly more verbose than more productive languages like Python or Ruby that come with more powerful built-in primitives like list comprehensions, functional arguments, destructuring assignment, etc.

Research by Prechelt that compared 80 implementations of the same set of requirements across 7 different languages showed that solutions written in C, C++, and Java were on average 2-3x longer in terms of non-comment lines of code than scripting languages like Python.  [1]  Paul Graham has also written extensively that one of the competitive advantages of his Viaweb startup was a more powerful and productive programming language.  [2]

The research lines up with my personal interview experiences, and I'd estimate that it takes the typical candidate roughly 3 times longer to express the same algorithm on the board in a non-scripting language than it does in a scripting language.  In interviews where a candidate actually needs to write executable code on a computer, the time that a person spends compiling C, C++, or Java code is time that another candidate who's proficient at Python or Ruby is using to address the actual problem itself. Once you factor in the additional time needed to recover from mistakes or bugs, the absolute time differences start to compound.  Each minute spent writing boilerplate code or additional syntax for a less productive language is a minute not spent tackling the meatier aspects of a problem.

The ability to choose the right tool for the job is an important skill.  Choosing a less productive language makes me wonder as an interviewer whether you'd choose less productive tools on the job, like trying to write C++ or Java code to parse and format files when someone can be orders of magnitude faster using shell scripts or a scripting language.

There are two exceptions I would make for candidates that use C, C++, or Java on a problem that could be more quickly solved with a language like Ruby or Python:

  • If you're a fresh college grad who hasn't picked up a scripting language, I tend to be more lenient and evaluate whether I think you can pick one up quickly on the job.
  • If you're more experienced, really proficient at C, C++, or Java, and can solve a problem as quickly as a good programmer who uses Python or Ruby, then that's a strong a skill to have, and I'll take into account that it'd probably be easy for you to pick up a scripting language.  Still, there would be a lingering doubt in my mind wondering why you didn't learn a more productive language over the years, since you would've been able to solve the problem that much more quickly.

All that said, there are probably certain interview situations where using a non-scripting language might be desirable.  If you're interviewing for a search company or a company that focuses on iOS or Android development, using C++, Objective-C, Java, or whatever the core language is at the company would certainly help demonstrate that you could be effective on the job quickly. If you don't know a scripting language well, it's better to use a language you're proficient at, though it'd be even better to just get proficient at a scripting language.  Ultimately, you want to pick the programming language that most effectively demonstrates that you'd be productive.  My advice would be to ask your interviewer if he or she has a preference, and if not, to choose the most productive programming language for the problem.

----------

[1] http://page.mi.fu-berlin.de/prec...
[2] http://www.paulgraham.com/avg.html
I think Python (and maybe Ruby, but I have no experience with it) is a strongly superior choice to C, C++, and Java in interviews.

Using a high-level language let's you write more code with fewer lines; as a result you can focus on the logic of the algorithm you're implementing rather than manual memory management. And it's quicker to write a list comprehension than a for-loop. For whiteboard coding, this can really save time.

I would only use C or C++ for situations that demand it (e.g., systems questions) or if you don't feel comfortable with a higher level language like Python. (In the latter case, I'd strongly recommend you learn.)
Quora UserQuora User, Software Engineer
20 upvotes by Quora User, Quora User, Eric Brunstad, (more)
I agree with Edmond Lau's answer to some extent, but I think this really depends on the kind of interview question you get, and what the interviewer expects from you. And both of those things are heavily determined by the company you're interviewing with. What Quora expects from their interview candidates is significantly different from what VMWare would expect from their interviewees because most likely Quora and VMWare engineers spend their time in different levels of the stack.

Sample interview problems:

  • Implement a lock-free queue => there's no way to do this in Python/Ruby (you need a CAS primitive). The obvious choice here would be to do it in Java, or C/C++ if you like.
  • Implement a simple slab allocator => It's natural to do this in C/C++.
  • Any graph-search problem => you can do this in Python/Ruby because it's a high-level problem. But the risk with doing it in Python/Ruby is you've to know the internal details of all the basic data-structures (for instance Python dicts, lists), and the big-O runtimes of the operations supported on these data-structures. Usually when you write Python/Ruby, you're in the scripting mode and you most likely don't give a lot of thought to this. Also unlike the Java JDK which clearly documents the implementation details of most of its datastructures, and runtimes, the Python documentation is light on these details.

So in short, it depends; pick something that seems right in that context.
Gayle Laakmann McDowellGayle Laakmann McDowell, Author of Cracking the Coding ... (more)
68 upvotes by Quora User, Quora User, Sumit Bisht, (more)
In theory, it shouldn't really matter what language you're using.

That said, I still recommend that candidates use java in general. Here's why:
  • You need to use a language that both you and your interviewer are comfortable with. Almost everyone can read java, even if they don't use it regularly (or even if they've never used it). Obviously, if you've never worked in java, an interview is not the appropriate time to learn it. Pick another language.
  • You don't want to make problems too hard. Java is faster to write programs in than C++, and less error prone. Do you really want to deal with memory and pointer errors?
  • You also don't want to make problems too easy. Python has a way of "simplifying" common operations into one statement. A less-careful candidate could mistake an O(N) operation as O(1).
  • You don't want to use a language that some interviewers might look down upon. It's not necessarily right, but some people don't respect python and ruby as real languages.

So, Java is generally best. But, if you know that your interviewer regularly works in another language, you can use that language as well (presumably they wouldn't be biased against whatever language they use). If you're interviewing a start-up, there's also going to be a preference towards working with that start-up's language.
Quora UserQuora User, Engineer by day. Dad by nite. ... (more)
5 upvotes by Quora User, Praveen Ram Chandiran, James Power, (more)
Background on me: I've interviewed hundreds of engineering candidates for Google. Have been on and observed many resume and interview boards.

In my opinion, Java is a terrible interview language. Its much more verbose than Python or Ruby. I've watched hundreds of candidates spend so much time simply writing out syntax than presenting your ability to understand and solve a problem via code. The flexibility and brevity of a non typed language such as Python/Ruby is a huge advantage in interviewing.

A candidate being able to use a language of their choice to solve a problem quickly and easily should never be a detriment. Any company or interviewer who fails you for using the most efficient (or your most comfortable) means for solving is not a place you should work at anyways. I'd be insanely impressed with a candidate who can show me a quick simple solution in a new language than an insanely long one in Java.

All good companies know that good engineers will be able to adapt to any language. So spend time showing that you're a good engineer, by answering in the language(s) you're most comfortable in.
Akash AgrawalAkash Agrawal, Principal Engineer at Slideshare
If you deeply understand what you use then any language will work for you. For example:

  1. If you think sorting an array in ruby is a O(1) operation, it will shoot you in the foot. But if you understand the algorithm used behind the scenes, it will be in your favor.
  2. Similarly just using C++ won't help you. For example: if you are using STL vectors/map/list and don't know pros/cons of various built-in methods.

In my opinion, choice of language is something which doesn't matter much but your logic and understanding of it matters.
Write an answer