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

-2

u/[deleted] Mar 04 '22

Sadly there are way way too many schools with Computer Science degrees that never get to real hardware issues. Also, if you hired him to be a C++ programmer to do X, and they can talk about X... does it matter if his school shorted him on his degree? If he has a computer science degree then they shoudl be able to at a high level make the code more efficient, and some training on the hardware if it is specialized shouldn't be that hard.

Now if it was a degree in computer engineering or something like that, yeah.. giant red flag.

3

u/idontappearmissing Mar 04 '22

Now if it was a degree in computer engineering or something like that, yeah.. giant red flag.

I don't know about that, my computer engineering program is much more focused on hardware. The most my CS classes have taught me about compilers was how to use GCC from the terminal and basic CMake. I'm not required to take the course on compilers, but I believe that computer science majors are.

1

u/[deleted] Mar 04 '22

But I haven't seen a computer engineer degree that didn't cover cache and fetch optimizations, which is what a lot of compiler optimizations target.

2

u/CocktailPerson Mar 04 '22

Now if it was a degree in computer engineering or something like that, yeah.. giant red flag.

Yeah, actually, his undergrad was in computer engineering, but from a school in India, so I have no idea what that counts for.

2

u/[deleted] Mar 04 '22

I doubt many computer engineering curricula put a heavy emphasis on compiler optimizations.

those that do probably leave out other content that other universities thought important.

3

u/CocktailPerson Mar 04 '22

If you take a compilers course, it should include discussions of compiler optimizations. Whether you think a compilers course should be required for a CE degree is a different question.

1

u/[deleted] Mar 04 '22

But they should at bare minimum have a computer architecture course and VHDL/Verilog course on CPUs that cover the basics.

2

u/[deleted] Mar 04 '22 edited Mar 04 '22

I took a computer architecture course. We design our own cpu in vhdl.

I don't think it would have been feasible to fit in writing our own compilers, into the same course. Especially with optimization.

1

u/DanielMcLaury Mar 04 '22

Sadly there are way way too many schools with Computer Science degrees that never get to real hardware issues.

TBF computer science is about a lot more than micro-optimization. I don't even know for sure that someone like Scott Aaronson has ever written a computer program.

1

u/[deleted] Mar 04 '22

But they should at bare minimum cover things like fetch look ahead, cache, and things like that which would likely mention things like loops optimizations.