Not All Companies Give You a Choice of Programming Language

Curt Corginia
7 min readOct 29, 2021

--

Photo by Kelly Sikkema on Unsplash. For this post, I decided to just look up the word “disaster” to see what I would get.

For the sake of personal pride, I will not state when this experience took place — whether it took place five years ago, in college, or…um…last Tuesday. In the second half of a 45-minute technical interview, I was given a problem description that went something like this:

Let’s say you have a list of names (device names). A user inputs a device name (can be just a parameter). I want to search the name, to make sure it’s in the list.

This company was interested in hiring a Java developer, specifically to do backend work using Spring Boot. HR sent me a clarifying email about my resume, which had nothing on Spring Boot or Java, and I sent them descriptions of some experience I had. I thought they had also said I would have a choice of programming language in the coding portion, but now I am not so certain.

The conversation that followed went something like this:

Me: Is it okay if I do this in C++?
Interviewer: That question makes me concerned…I just want a very simple Java class
Me: Okay *writes the Java public static void main, to show I am willing to play ball* How many strings does this have to process?
Interviewer: It does not matter
Me: How efficient does this have to be?
Interviewer: It does not really matter

What followed was a disaster. I suggested using a hash map, then quickly decided to use an ArrayList instead because the device IDs would be unique. I used the wrong call to insert into an ArrayList and did not know the Java 8 method for searching it. I tried to create a constructor that returned void and instantiated incorrectly, which was even more embarrassing because it also would have been an issue in C++. At the end of the interview, the interviewer asked me if I had ever used Java before.

I ran the story by Smack, who suggested that maybe not being allowed to use C++ put me in a weird headspace. I wrote some C++ the morning after (“morning after”? Sounds like I am already referring to this like some kind of bender), but this was with a text editor, time to reflect on the whole thing, and a cup of Java…I mean coffee. In the real thing, there was no text highlighting, no editor, and no button to test run. It was as close to a white-boarding interviewer as we could get in these days.

My first pass after the real thing, hosted on my personal GitHub here.

I sent it to Smack, who said that a device ID like “iphone” was weird to him. Probably what the interviewer meant was to have unique IDs, and using a hash map or hash table would still have been reasonable. Suggesting that the existence of unique IDs made a hash map a bad choice probably confused the interviewer.

He also said the following:

  • He would have asked for example inputs. This is a completely reasonable question
  • He would not have asked how efficient it should be, at least not explicitly like I had
  • He would have asked if the device IDs were unique or not
  • He would have asked how the list was populated

Finally, he said that when I said a hash map would be a poor choice for unique IDs, I probably “lost” the interviewer.

Taking a Step Back

Though Clement suggests using a language you are familiar with, he adds that YOU REALLY NEED TO CHECK. At some companies, for example, you are only allowed a choice between Python, Java, or C++. In my case, it had to be Java and it had to be without any sort of text editor.

The concept of blogging about technical topics is…interesting. YouTube at least provides a downvote button for anything inaccurate or unclear, but on Medium the only police system is the comment box. One reason for my “Repeat Code with Leetcode” series is that, in the case of Leetcode, if you submit code and get it accepted then you are probably right. You may not have the best solution, and my solving the Leetcode sorting question by simply calling std::sort comes to mind, but at least you know you are teaching something that will guide someone else correctly. Cracking the Coding Interview is similar; the answers are in the back.

This problem is its own unique case. The only indication I have that it is correct are some simple test cases I wrote myself on the fly, but I do not know if it is the best. Smack suggested one edit fairly quickly — if these are unique device IDs, then use a set instead of a map.

Though the first chunk of code was something I could come up with, without Google, the above uses an unordered_set and a const iterator to traverse it. This code was new to me. Find it here

I should probably write an entire post about the hash map and her cousins, since this experience highlighted some gaps in my understanding of them. I could write about Cracking the Coding Interview, Question 16, question 2, as this asks the comparable question of mapping words in a book which the assumption that some words will be repeats. Then I could maybe write about FizzBuzz, since I thought maybe this was like the class equivalent of a FizzBuzz question. I think I have my work cut out for me.

The hash map

Hash map? Hash table? Unordered map? Unordered set? What?

In C++, an unordered map is a hash table.

In Java, Hash maps and Hash tables have some differences…but neither exists as a keyword in C++. To add to the confusion, I called my unordered maps above inputHashmap’s. I could argue that the unordered map is the C++ implementation of the hashmap, even if C++ does not use hash_map as its preferred keyword.

An unordered set contains keys and no values.

Notice this post made no attempt to explain the internals of how a hash map actually works.

This guide by InterviewCake provides a good explanation of what a hash map is, and how it works.

My subsequent conversation after writing the code was that a hash map or hash set was the way to go. An ArrayList would not have had adequate lookup time. I also suggested an O(n lg n) sorting call before I started, but the interviewer said that would come with a cost.

The World of Java

Jombo owns the tech side of YouTube.

Okay, well then I guess that it is then. We have no where else to turn. There are no options left.

Here I have the Java equivalent I wrote.

As I recall, the code I actually gave him used an ArrayList, line 27 was using an incorrect call to push, line 31’s instantiation was trying to use class as a keyword for some reason, the constructor was returning void, and the method call simply had the method itself called on nothing. I have named the gitrepo JavaDebacle

Is that…acceptable? I am not sure if the interviewer would have been thrilled about import java.util.*

Trying to Get Over This

I had a pretty rough week after this, solely because of this. Excuses in my head abounded.

Excuse: I should have had a choice of programming language!

Not necessarily. They had every right to only allow Java for a position that would be in Java.

Excuse: But we would never write code like this in real life! Spring Boot? We would use Spring Initializr, not just write this from scratch! And under what circumstances would we be forbidden from Google, basic web tools, and a decent IDE?

If you write Java, you are going to write constructors and instantiate classes left and right. If you cannot do that, then it is a serious red flag

Excuse: That interviewer was a JERK! He gave me unhelpful answers to my questions. His response to “can I do this in C++” was the most condescending response imaginable. He did not clarify key things and he mostly just glared at me and looked baffled the entire time! This was his fault, not mine

Was he a jerk? He actually lighted up a little bit when I spent the last five minutes asking him about his own career, and more on their tech stack. Also, he tactfully criticized what I gave him with “your Java is very rusty,” implying that I may have been competent in it at some point.

Smack’s response, on the other hand, was to suggest a Java project I could do on some weekend in my own time.

On Owning Your Failures

Closing Thoughts

My thoughts after this was that maybe I was one of those candidates Jeff Atwood describes…people who supposedly code for a living but can’t code. So I pulled up a text editor and wrote some code. Create a hashset…okay. Make a constructor, fine. Yes, this seems to work. Shut up, voice in my head telling me I don’t know anything, I just did it.

I followed some threads and articles with complaints about how many candidates can’t solve FizzBuzz. I read some critiques I really liked, and want to feature that in some future blog post.

I think what can make interviewing hard is not that it is inherently unreasonable to ask about things like promises, or palindromic substrings, or making a get call…what is frustrating is they can potentially ask any of those things. And unless they want to restrict themselves to a niche, candidates have to widen their skill set.

The failure experiences that weigh candidates down are not the unreasonable interviews…the failure experiences that weigh candidates down are the ones that seemed completely fair, because then they have only themselves to blame.

But I can keep writing here about all of it. The worst interview experiences. The failures. The mistakes.

And maybe, at some point, someone who reads this blog will learn from it, and succeed.

--

--

Curt Corginia

Founder, CEO, CTO, COO, and janitor at a company I made up called CORGICorporation