News for hackers. Stuff that matters.
Re:The best engineering interview question I've ever gotten by notreallyserio on Sunday April 17, 2022 @07:43PM (#31065648)
I'd find this question frustrating because it feels like a trap. I was looking for the trick -- was I missing something in the question that made the obvious approach untenable? No, the answer is simple, just add a way to multiply numbers with the multiply operator.
Re:The best engineering interview question I've ever gotten by davidw on Sunday April 17, 2022 @08:12PM (#31065851)
"They gave him an intelligence test. The first question on the math part had to do with boats on a river: Port Smith is 100 miles upstream of Port Jones. The river flows at 5 miles per hour. The boat goes through water at 10 miles per hour. How long does it take to go from Port Smith to Port Jones? How long to come back?

Lawrence immediately saw that it was a trick question. You would have to be some kind of idiot to make the facile assumption that the current would add or subtract 5 miles per hour to or from the speed of the boat. Clearly, 5 miles per hour was nothing more than the average speed. The current would be faster in the middle of the river and slower at the banks. More complicated variations could be expected at bends in the river. Basically it was a question of hydrodynamics, which could be tackled using certain well-known systems of differential equations. Lawrence dove into the problem, rapidly (or so he thought) covering both sides of ten sheets of paper with calculations. Along the way, he realized that one of his assumptions, in combination with the simplified Navier-Stokes equations, had led him into an exploration of a particularly interesting family of partial differential equations. Before he knew it, he had proved a new theorem. If that didn't prove his intelligence, what would?

Then the time bell rang and the papers were collected. Lawrence managed to hang onto his scratch paper. He took it back to his dorm, typed it up, and mailed it to one of the more approachable math professors at Princeton, who promptly arranged for it to be published in a Parisian mathematics journal.

Lawrence received two free, freshly printed copies of the journal a few months later, in San Diego, California, during mail call on board a large ship called the U.S.S. Nevada. The ship had a band, and the Navy had given Lawrence the job of playing the glockenspiel in it, because their testing procedures had proven that he was not intelligent enough to do anything else."

Re:The best engineering interview question I've ever gotten by josephg on Sunday April 17, 2022 @09:31PM (#31066357)
Medical people talk about this problem as "differential diagnosis". There can be multiple reasons why some symptom is exhibited (in this case, failing the interview). Its not enough to know that the interview question was failed - you also want to know what happened.

A much more common example is that (particularly young) candidates tend to make job interviews into big, stressful things in their head. Then they don't sleep properly the night before, and during the interview they can't think creatively or access deep memories (which are both well known symptoms of stress). They can't answer your questions. You think its because they don't know, but actually the problem is that they're too stressed to think at all.

Long programming questions work great for my anxiety because I can zen out while I'm programming and forget the interviewer is there. But everyone is very different with this sort of thing.

The more general way to work around this problem is to listen and pay attention to the candidate. If you asked "Lawrence" in this story what he was thinking about during this interview, he'd tell you about fluid dynamics and partial differential equations. That tells a story. Another candidate will tell you that they felt really awkward programming through an SSH connection because they're used to Visual Studio. Or how they really do (or don't) like some aspect of the programming style on display. Or how (to crib from another commenter) the programming was easy enough, but they're worried that doing so introduces a race condition between atomic multiply and add instructions if they're interleaved. And they hate doing the work because they feel like they're introducing a bug.

None of that really helps with stress bunnies, but you learn so much about what sort of employee they'll be by asking.

Re:The best engineering interview question I've ever gotten by Eratosthenes on Monday April 18, 2022 @12:54AM (#31067575)
I had a job interview once where I was so anxious that I wasn't able to remember my own address when asked. Usually I'm smart enough to remember my own address. After the interview (no offer) I was able to remember my address and navigate back to my apartment without much trouble, so I think that lends credence to your theory that stress can cause memory lapse.
Re:The best engineering interview question I've ever gotten by nvarsj on Monday April 18, 2022 @04:25AM (#31068504)
Yep and it also reinforces biases in interviewers. They start to think people really are just incompetent despite their experience - and start to believe even more in high pressure interviews. When the vast majority of “can’t believe the candidate couldn’t even do a for loop” is due to stressors.
Re:The best engineering interview question I've ever gotten by josephg on Monday April 18, 2022 @07:58AM (#31069558)
> When the vast majority of “can’t believe the candidate couldn’t even do a for loop” is due to stressors.

This idea keeps me up at night, but do you have any evidence for it?

I've interviewed plenty of people with 15+ years of experience who really struggled to do basic programming tasks. And who didn't show any obvious signs of stress.

To this day I have no idea how many of them were not performing because they were stressed out of their minds but hiding it. Vs how many were simply not very good at programming. I have no idea how to tell the difference when they don't make it obvious to me.

Re:The best engineering interview question I've ever gotten by nvarsj on Monday April 18, 2022 @06:16PM (#31077324)
No evidence - how would you even begin to get it. Just my feeling from doing many interviews as well. I still recall a CS PhD from a top school fumbling with the most basic for loop in an interview I was doing. I just can't believe people are this incompetent. I think the simplest explanation is nerves - even mild levels of stress are known to shut down people's ability to think.

Ergo, I strongly suspect the current tech hiring culture filters out anyone who has above average sensitivity.

Re:The best engineering interview question I've ever gotten by Eratosthenes on Tuesday April 19, 2022 @11:24AM (#31084393)
Here's Michael Bay having a panic attack: https://www.youtube.com/watch?v=DeClZfVwOk4

Note that aside from some minor body language cues, there aren't a lot of outward signs of panic. How it looks and how it feels are very different.

Re:The best engineering interview question I've ever gotten by josephg on Tuesday April 19, 2022 @08:38PM (#31091338)
I believe you. The struggle is, when a candidate is failing a job interview, how can you tell the difference between someone who's good but stressed vs someone who's just not very good?

Because weak candidates need to submit a lot of applications to get a job, most job applications are from weak candidates. Its easy to feel compassion for people who have panic attacks. Its much harder to make a filter for weak candidates which doesn't also filter out people with performance anxiety.

Seems like we don't even know how big a this problem is. Is it 1% of the candidates? 10%? 50%? I have no idea. And it sounds like nobody here has any real idea either.

Re:The best engineering interview question I've ever gotten by Eratosthenes on Wednesday April 20, 2022 @01:37AM (#31093237)
>how can you tell the difference between someone who's good but stressed vs someone who's just not very good?

This is a solved problem already. Do we use whiteboard interviews for standardized tests or certifications? No.

>Seems like we don't even know how big a this problem is.

Seems like you don't know.

>Is it 1% of the candidates? 10%? 50%? I have no idea. And it sounds like nobody here has any real idea either.

How much time did you spend trying to find out before giving up?

Re:The best engineering interview question I've ever gotten by josephg on Wednesday April 20, 2022 @10:08PM (#31105348)
I'd appreciate if you expressed your opinions explicitly, rather than as snippy backhanders.

> Do we use whiteboard interviews for standardized tests or certifications? No.

Your position is not clear here. Are you claiming a written exam would be a better assessment for programming ability? That sounds bad?

For what its worth, I don't think whiteboards are the best way to assess programming skill either. My preference is for supervised programming assessments - like this article suggests. Whats your preference and why?

>> Seems like we don't even know how big a this problem is.

> Seems like you don't know.

Correct; I don't know. That is why I asked.

If the answer is obvious to you, maybe instead of insults you could link to a study?

Re:The best engineering interview question I've ever gotten by kubanczyk on Monday April 18, 2022 @05:08AM (#31068699)
I think the author made a fool of himself.

> their testing procedures had proven that he was not intelligent enough to do anything else

I see the final sentence as entirely detached from the rest of the story.

My take: Their testing procedures had detected he had lacked basic awareness of the situation. When he received a (written!) communication, he wasn't able to imagine that the author was not the smarter version of himself despite a multitude of clues. The idea didn't occur to him.

Re:The best engineering interview question I've ever gotten by jrib on Sunday April 17, 2022 @08:26PM (#31065941)
quote from Cryptonomicon by Neal Stephenson
Re:The best engineering interview question I've ever gotten by AtlasBarfed on Monday April 18, 2022 @02:45AM (#31068071)
Cryptonomicon!

Man, and that is a LONG book, but I clearly remember that section for some reason.

Re:The best engineering interview question I've ever gotten by Syonyk on Sunday April 17, 2022 @07:50PM (#31065695)
It's "Advanced FizzBuzz."

"Can you understand a complex code base, figure out how to zoom in on the section of interest, and add a function?"

Far, far too many people interviewing for coding positions can't do that. Though I question how many could whip out FizzBuzz in 5 minutes and would then fail the more complex version. At some level, either you can code, or you can't. And, importantly, at some point in your career (if you go down the standard management track), you will typically lose the ability to code. If you've not done it in 5 years, you probably can't do it, in a practical sense. Not that you can't re-learn, but you can't just jump into a coding interview and ace it, either.

If you find yourself at a point in your career where coding interviews are a thing, "having a side hobby project that requires coding" is a very useful way to be really quite good at coding interviews. Plus, if it's your hobby project, there's no "Hrm... can I talk about that?" sort of problems when you're asked about a time you X'd with Y. You can talk about your personal hobby project absolutely as much, and in depth, as you want.

Re:The best engineering interview question I've ever gotten by mikeryan on Sunday April 17, 2022 @08:35PM (#31065998)
This isn’t an “Advanced FizzBuzz” if it takes three hours or even one hour. The whole point of a FizzBuzz question is that it’s a fast, like 2-3 minutes fast, heuristic for separating the wheat from the chaff and this isn’t that at all. At some point it’s no longer a FizzBuzz and just a coding challenge. Even the author’s answer reflects that (though he calls it a FizzBuzz)

I don’t know a thing about memcached internals but, as presented here, with the potential encoding and concurrency issues means that there’s likely levels to the complexity here that will likely take someone quite a bit of time to resolve if they’re not familiar with memcached internals.

But again memcached and even C++ isn’t my thing. ¯\_(ツ)_/¯

Re:The best engineering interview question I've ever gotten by Syonyk on Sunday April 17, 2022 @10:29PM (#31066663)
"Jumping into a non-familiar codebase and being useful" is literally what someone is considering paying you for.

Years ago, I got tired of some owners of a company I worked for hiring bench techs (small business IT support and such) who'd clearly never opened a computer before (I don't know why, but as the closest person I couldn't focus on any of the work I was supposed to do when constantly being interrupted by bench techs), so I "broke" a scrap computer as an interview problem, rather extensively. RAM wasn't seated, a PCI card wasn't fully seated, I think the power switch was halfway pulled off (enough that it didn't work but was visibly wrong), and I did some terrible things to the partition tables as well. The goal, which it succeeded quite well at from my point of view, was to see where a possible bench tech's skills ended, then help them through. If you'd worked on computers a bunch, and one wasn't powering on, "reseating stuff" was a useful enough response, which would either clear the corrosion on some pins or ensure everything was actually planted in place, which would render this machine booting (after you pushed the power button connector back in), and let me observe what you did with some weird boot errors. There were Windows and Linux environment boot DVDs laying around, so, pick what you know.

The result of this was that our next bench tech hire had the skills to do stuff himself, and generally left me alone to do the stuff I was trying to get done.

Re:The best engineering interview question I've ever gotten by bombcar on Sunday April 17, 2022 @10:58PM (#31066839)
The thing with these tests that people don't seem to "get" is they're not pass/fail, not really. If someone has good work to show it may be perfectly fine - they were on the right track, hit a snag, but it's clear they know what they're doing and would get somewhere.

In my experience with these questions, it is painfully obvious very quickly those who will and those who won't.

Re:The best engineering interview question I've ever gotten by hoten on Sunday April 17, 2022 @09:00PM (#31066168)
The problem is simpler than all that.

There already exists a function that does the exact thing the question asks for, handling all the atomicity complexity.

What this comes down to is can the candidate: figure out how to build the project, grep to existing implementation and copy, paste, change a plus to an asterisk. And also, can they articulate the work-to-be-done this simply.

I've never seen the first item in that list tested in an interview and .. I don't hate the idea.

Re:The best engineering interview question I've ever gotten by mikeryan on Sunday April 17, 2022 @09:42PM (#31066409)
What this comes down to is can the candidate: figure out how to build the project, grep to existing implementation and copy, paste, change a plus to an asterisk. And also, can they articulate the work-to-be-done this simply.

While that’s the gist of it, it hardly seems that’s quite enough from the author’s solution, nor should it be enough for an interviewer. The question isn’t how to write, or copy paste a function but how to add the command interface as well which, if one doesn’t know memcached, can be more complex then the function itself and isn’t covered by this trite an answer.

https://quuxplusone.github.io/blog/2022/01/07/memcached-inte...

Re:The best engineering interview question I've ever gotten by astee on Monday April 18, 2022 @01:58AM (#31067858)
grep for "incr" and add "mult" below it ¯\_(ツ)_/¯
Re:The best engineering interview question I've ever gotten by PaulKeeble on Monday April 18, 2022 @04:44AM (#31068598)
Sounds like binary compatibility might be broken by the changes, with failing tests still its impossible to call it done at 90 minutes as well.
Re:The best engineering interview question I've ever gotten by teraflop on Sunday April 17, 2022 @07:50PM (#31065699)
This might just mean that you've been overly conditioned to expect bad interview questions that do rely on a "trick". But if so, I'm sure you're far from the only person in that position. Would you be less frustrated if it came with a disclaimer, along the lines of "this is not a trick question"?

(I realize this might sound sarcastic, but I'm serious. I think the way interview questions are presented is very important, and often overlooked.)

Re:The best engineering interview question I've ever gotten by stormbrew on Sunday April 17, 2022 @10:23PM (#31066624)
My go to interview question for the last few years has been kind of similar to this one, in that it's about looking at, exploring, and modifying code that already exists. I also let people look things up, ask stupid questions, etc.

You would not believe how many times I have to tell some people that it's not a trick, I really don't mind if they google something or use `man`. That I'm not trying to trick them into having to know what the arguments of pthread_create are by heart, or that yes they can compile the program in coderpad as many times as they want.

Really unfortunate that so much of the industry thinks interview questions should be like Shyamalan movies.

(also sadly I'm changing jobs soon and I'll have to abandon this question and I don't think it'd fly in the new job's interview policies anyways)

Re:The best engineering interview question I've ever gotten by notreallyserio on Sunday April 17, 2022 @07:53PM (#31065711)
> Would you be less frustrated if it came with a disclaimer, along the lines of "this is not a trick question"?

Definitely. That would make it more clear it's about SE and not stupid brain tricks.

Re:The best engineering interview question I've ever gotten by tantalor on Sunday April 17, 2022 @08:07PM (#31065813)
> make it more clear it's about SE

Your first clue is it's an interview for a software engineering job.

Re:The best engineering interview question I've ever gotten by andrewingram on Sunday April 17, 2022 @08:46PM (#31066071)
I’ve had plenty of interviews for software engineering jobs where I’ve been asked trick questions. Like “explain why this code is broken” when it’s not actually broken.
Re:The best engineering interview question I've ever gotten by sverhagen on Sunday April 17, 2022 @08:26PM (#31065945)
I've not been conditioned to expect bad interview questions, so I'm gonna ask: in what way would/could this be a trick question?
Re:The best engineering interview question I've ever gotten by gravypod on Sunday April 17, 2022 @08:37PM (#31066016)
I downloaded the code and had a look. For context, I've ramped up on quite a few code bases in my day in a bunch of different languages. Here was what I thought would happen in order of likelyhood:

1. The code would not build at all on a standard linux distro unless you knew exactly what packages to install. (I had an interview like this once)

2. Locking the key was going to be inexplicably linked to the operation (got very worried when I saw `add_delta` and `do_add_delta`). Turns out add_delta just calls do_add_delta wrapping it in a lock. The lock API is very simple.

3. There would be a massive amount of code duplication that would make it difficult to add this feature without doing serious refactoring. Turns out you basically just change `bool incr` for `math_op_t` or something and provide a way to map from binary/string input to math_op_t.

This would be very easy. Depending on how comfortable I was with the editing environment they talk about elsewhere in the hn comments it wouldn't be too bad.

Re:The best engineering interview question I've ever gotten by 542458 on Sunday April 17, 2022 @08:35PM (#31065997)
I was waiting to see a weird gotcha about multiplication not being atomic or something. Actually, question for people with more low-level knowledge than me: is that solution atomic?
Re:The best engineering interview question I've ever gotten by db48x on Sunday April 17, 2022 @08:45PM (#31066062)
All math operations on your ordinary everyday cpus are equally non–atomic. They read a value, potentially from memory or from cache, operate on it, and leave the result in a register. Then your program probably has to store the result somewhere, or perform more operations on the result. This is why the memcached software has an explicit locking mechanism; any operation on a cached value involves taking a lock, doing the operation, storing the result, and then releasing the lock.
Re:The best engineering interview question I've ever gotten by josephg on Sunday April 17, 2022 @09:42PM (#31066414)
Memcached shouldn't need an explicit lock to add. Unless I'm missing something, you should be able to use atomics.

For example, for adding it should be enough to use an atomic Fetch-And-Add instruction:

https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU32.h...

Multiply doesn't have an equivalent. You can work around that by reading, multiplying and then using CMPXCHG to atomically update the variable if nothing has changed while you were processing. But you need to think about the ABA problem[1]. (I think in this case its safe, but I haven't thought about it enough. Lock free algorithms have subtle bugs.)

[1] https://en.wikipedia.org/wiki/ABA_problem

Re:The best engineering interview question I've ever gotten by jhgb on Monday April 18, 2022 @12:32AM (#31067457)
Is ABA an issue here? "Replace A by X*A" should be perfectly fine if an atomic swap gives you A back, since it means it was actually A at the time when you perform the swap. That it was B a moment go doesn't seem to matter.
Re:The best engineering interview question I've ever gotten by stormbrew on Sunday April 17, 2022 @10:18PM (#31066599)
Updating an entry in a database table (which is what a memcache entry is, in practice) is not usually as simple as just "change the value from X to Y". Locking is likely necessary no matter what.
Re:The best engineering interview question I've ever gotten by notreallyserio on Monday April 18, 2022 @07:51AM (#31069518)
That's just it, I couldn't figure that out. There's "always" a trick, so I've read in some forums.
Re:The best engineering interview question I've ever gotten by lupire on Sunday April 17, 2022 @08:31PM (#31065972)
The author explained that it was a trick question -- the solution was to copy-paste code without trying to understand it.
Re:The best engineering interview question I've ever gotten by jimbokun on Sunday April 17, 2022 @09:22PM (#31066311)
I think the test is whether you can grep an unfamiliar code base to find the implementation of existing functionality, understand it, and modify it to add very similar functionality.

Like do the commands have to be registered somewhere? Is it a string mapping the operation name to a function pointer? A cascading if-then statement? Etc. etc.

It's just a test of diving in and understanding existing code in a relatively short amount of time.

Re:The best engineering interview question I've ever gotten by sanderjd on Sunday April 17, 2022 @09:58PM (#31066494)
Years of crappy tricky interview processes have broken our brains.
Re:The best engineering interview question I've ever gotten by dist1ll on Sunday April 17, 2022 @08:08PM (#31065817)
> that made the obvious approach untenable

What's the obvious approach? You do have to dig into the source of memcached and understand some internals. With good use of grep and vim it can be done quite quickly, but I wouldn't call it obvious.

Re:The best engineering interview question I've ever gotten by notreallyserio on Monday April 18, 2022 @09:53AM (#31070587)
The obvious approach would be to copy the code for an existing function, I think.
Re:The best engineering interview question I've ever gotten by Tao331 on Sunday April 17, 2022 @09:14PM (#31066255)
The only trick I see is that the copy-paste-find-replace solution is preferable to the one that attempts to maximize reuse.
Re:The best engineering interview question I've ever gotten by melony on Sunday April 17, 2022 @07:50PM (#31065693)
And correctly dealing with arithmetic overflow.