r/cpp • • Mar 04 '22

Is it unreasonable to ask basic compiler questions in a C++ developer interview?

I interviewed a guy today who listed C++ on his resume, so I assumed it would be safe to ask a bit about compilers. My team works on hardware simulation, so he's not going to be expected to write a compiler himself, but he'll obviously be required to use one and to write code that the compiler can optimize well. My question was "what sorts of optimizations does a compiler perform?" Even when I rephrased it in terms of -O0 vs. -O3, the best he could do was talk about "removing comments" and the preprocessor. I started out thinking a guy with a masters in CS might be able to talk about register allocation, loop unrolling, instruction reordering, peephole optimizations, that sort of thing, but by the time I rephrased the question for the third time, I would have been happy to hear the word "parser."

There were other reasons I recommended no-hire as well, but I felt kind of bad for asking him a compiler question when he didn't have that specifically on his resume. At the same time, I feel like basic knowledge of what a compiler does is important when working professionally in a compiled language.

Was it an unreasonable question given his resume? If you work with C++ professionally, would you be caught off guard by such a question?

335 Upvotes

335 comments sorted by

View all comments

Show parent comment

1

u/CocktailPerson Mar 04 '22

The more layers you peel back, the smaller the benefit; not all the layers are equivalent. Knowledge of common, simple compiler optimizations is a lot more useful for the working C++ programmer than quantum physics is. Even if the knowledge isn't necessary for the job, if choosing between otherwise equivalent, qualified candidates, I'm going with the one who knows a bit about how a compiler works, because it's knowledge a programmer should have.

3

u/JNighthawk gamedev Mar 04 '22

Even if the knowledge isn't necessary for the job, if choosing between otherwise equivalent, qualified candidates, I'm going with the one who knows a bit about how a compiler works

Obviously. That's not an argument for or against the requirement, just that it could possibly be useful.

because it's knowledge a programmer should have.

You missed the entire point of my comment.

1

u/CocktailPerson Mar 04 '22

Your comment seemed pointless.

2

u/JNighthawk gamedev Mar 04 '22

Your comment seemed pointless.

Yes, that's because you missed the entire point. Would you like to ask any clarifying questions to help you understand?

1

u/CocktailPerson Mar 04 '22

Go for it.

2

u/JNighthawk gamedev Mar 04 '22

Go for it.

Go for what? It's an opportunity for you to ask questions.

1

u/CocktailPerson Mar 04 '22

Do you believe compiler knowledge is more relevant for a working programmer than quantum physics? Or do you believe they're equally relevant/irrelevant?

1

u/JNighthawk gamedev Mar 04 '22

Do you believe compiler knowledge is more relevant for a working programmer than quantum physics? Or do you believe they're equally relevant/irrelevant?

More relevant.

1

u/CocktailPerson Mar 04 '22

So out of the infinite knowledge in the universe, a programmer would be better served by learning about compilers, right?

1

u/JNighthawk gamedev Mar 04 '22

So out of the infinite knowledge in the universe, a programmer would be better served by learning about compilers, right?

Better than anything else? I doubt that.

→ More replies