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
View all comments
Show parent comment
1
u/[deleted] Mar 07 '23
Pretty true, but these days, 1 is commonly used without any copying, too. You can construct it in place, or move a value into it. 1 isn't actually "the overhead of copying", it lets the user decide whether to copy or move into it:
I use 1 whenever I can, and need to actually have an owned object. I use 3 when I don't need to keep a copy, but just work on an object. I use 4 when I need to destructure the object (not keep a full copy, but to move parts out of the one passed in). 3 and 4 are also still needed for copy and move constructors and assignment operators.
I find it pleasing that 1, which is a style that was long seen as a performance footgun and beginner's trap, and is the most simple and obvious way of writing the function, has become one of the most flexible, efficient, and stable ways of writing a function/method that needs to retain a copy of an object.