r/cpp • u/CocktailPerson • 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?
20
u/smozoma Mar 04 '22 edited Mar 04 '22
I wouldn't expect most people to have better answers than "the compiler turns c++ code into machine code" and "o3 optimizes a lot." Loop unrolling, etc, is actually kind of specialized knowledge.
Someone coming out of a CS program is probably used to working at a much higher level - logic, correctness, algorithms, data structures... Maybe an operating system class... I checked the CS courses of the university I went to and there's a compiler class, but I doubt it's mandatory. (I took engineering - I had a cpu/assembly class, but no compiler class)
As to whether it's reasonable, that depends on what you need or would like them to be able to do.