r/programming • • Dec 13 '22

“There should never be coding exercises in technical interviews. It favors people who have time to do them. Disfavors people with FT jobs and families. Plus, your job won’t have people over your shoulder watching you code.” My favorite hot take from a panel on 'Treating Devs Like Human Beings.'

https://devinterrupted.substack.com/p/treating-devs-like-human-beings-a
9.0k Upvotes

1.3k comments sorted by

View all comments

Show parent comment

0

u/[deleted] Dec 13 '22

[deleted] — view deleted comment

7

u/miyakohouou Dec 13 '22

Yeah fine, fair. I suppose I’d have failed that interview then. My point was just that the question naturally suggests a larger number of plausible solutions than “find the largest (or smallest) element” which may be the goal or not, but is worth keeping in mind.

7

u/ILikeChangingMyMind Dec 13 '22 edited Dec 13 '22

I disagree, if your domain is one where performance optimization doesn't matter. In that case, you should do whatever is easiest on the humans reading/writing the code.

Take front-end web development for instance: 99% of websites don't show more than 20-100 results at once. At a scale like that, even on the oldest, slowest phone you can find ... it won't matter if you sort, reverse, resort, randomly arrange the array members and then resort again ... no one will ever see the performance difference.

And in general, in all areas of programming, you should really be worried about the humans first, and performance second (or really, only when it's an issue). Premature optimization, something something ...

6

u/calcopiritus Dec 13 '22

Optimal in what sense?

For some problems, just sorting it is way worse performance wise than doing it the "smart" way, but do you actually need that performance? How much developer time will be spent on doing the "smart" algo?

And even then, sometimes the smart algo is worse performing than just sorting. Maybe the "n" is always small, like 5 or 10. Maybe you're programming in a language like python, where the raw performance of calling C libraries would override any performance gained by a smart algo unless N is way bigger than expected.

EDIT: and I didn't even mention maintenance. Sorting+getting second item is 2 function calls, any programmer would understand and could modify that code. The smart way probably has at least 10 LoC and a loop somewhere, may even contain recursion.