5 ms·
I am a team lead in c++ shop. Every interview, I ask: tell me about c++’s std::move(). Not a single interviewee has even had a good guess in 2 years of open j
by schaefer 4y ago
I am a team lead in c++ shop. Every interview, I ask: tell me about c++’s std::move().
Not a single interviewee has even had a good guess in 2 years of open job recs.
It really has me reconsidering. I’m a language nerd through and through. I love C++. But I also have to be honest and say there’s such a thing as “the average amount of c++ the team knows”.
To me, the biggest threat to C++ isn’t rust, but rather the speed at which the language is changing. It’s already past the tipping point.
In my domain, embedded programming, I’m keeping an eye on zig with fingers crossed.
- assbuttbuttass 4y agostd::move is kind of essential, no? You can't really use std::unique_ptr without it.
- yeputons 4y agoOne can get really far without ever touching `std::move` or `std::unique_ptr`. Especially when taught about `new`/`delete` first. Lots of courses still teach C-esque C++ first and students just keep to it because it's more explicit.
- johannes1234321 4y agoYou can use std::unique_ptr without explicit std::move for scope bound pointers, with class members and you can even return unique_ptrs without std::move due to RTO. The only time you need std::move is when passing ownership via a function call. That's quite a lot of practicla use cases available. But I think the concern is not about being able to use it, but to understand what it does, std::move is nothing but a cast. Itself it doesn't move anything. And then there is the whole fun with the state of the noved-from object afterwards. Quite some depth to uncover.
- sidlls 4y agoYou might be surprised at how little some (many?) programmers with C++ experience actually know about the language. Or any language, really. Our industry doesn't reward that kind of knowledge very much.
- rolenthedeep 4y agoI have the same issues with C#. I came up in the days of .net 4.5, in the years since I've watched Microsoft bolt an entire language worth of features on top of C#. I didn't use the language for the last five or so years, and I feel so lost that I avoid using it now. And that doesn't even begin to touch on the absolute disaster of the net framework/core/standard/mono/uwp runtime situation. C# as a language just doesn't seem very stable. I really don't enjoy using it anymore.
- shrimp_emoji 4y agoThat anyone could ever have enjoyed Microsoft Java seems crazy to me. :p (I can't justify why I feel that way. I have middleware-corporate-lang dysphoria for some reason.)
- kmac_ 4y agoI have quite opposite opinion. Every extension increased readibilty and cut the cruft. For example, even simple changes, like native tuples or expression bodied members tremendously changed how the language should be used and how the "correct" code looks.
- metaltyphoon 4y agoAgreed, C# was too verbose and its way less now.
- programmer_dude 4y agoC# syntax is gradually approaching F#. I'd say just use F# and skip the bloat.
- GiorgioG 4y agoMaybe if Microsoft bothered to invest in and promote F#.
- teh_klev 4y ago> C# as a language just doesn't seem very stable In what way do you think it isn't stable? I've upgraded code written in C# v1 to the latest and greatest and never had a breaking change (well except for one time where it was my own fault for abusing reflection). Ultimately you can use as much of the language as you want to, the "old" ways haven't been removed and you can still code like it's 2002 :)
- lunfard000 4y agoman I use C++ on personal projects for opencv (and python perfomance is pretty bad for my use case) but oh god, I don't I could ever get a C++ job, there is a universe of features I won't dare to touch anytime soon. I just use the "modern" and simple stuff and code look pretty good (imo), don't have to deal with gibberish compiler errors (except when std::format goes crazy). std::move is cool though, rvalue and lvalue is bit too much but the performance, clear "giving up" resource and dont having to use pointers is worth it (I just use it for rvalue passing, prob there is more to it).
- jpace121 4y agoYou could get a C++ job. One of the issues with C++ is most people using it for anything useful only need to know some particular subset, only actually know that subset, and then get bit when the subset they know changes.
- WalterBright 4y agoI've been reading through the proposed C23 spec. Looking at what's happening with enums, it's amazing how suddenly a simple feature became a far more complicated one. I read the spec on enums over and over, and still don't understand it. They're just enums, geez.
- Animats 4y ago> I read the spec on enums over and over, and still don't understand it. That's from someone who has written C++ compilers. Some of the insane complexity being added to C++ comes from trying to emulate Rust move semantics without a borrow checker. An xvalue is what's left behind after you do a move. In Rust, the compiler guarantees that you can never access the remnants after a move. But in C++, someone will somehow manage to leak a raw pointer to something, then move it. So users have to know about xvalues. (Could be worse. Trying to emulate Javascript async semantics in everything else has resulted in some real horrors. Only Go has a sane solution.)
- adrianmsmith 4y ago> Only Go has a sane solution. And Java Project Loom IMHO, which copies a lot of Go's sane solution. (Not released in an LTS version of Java yet, but hopefully soon!)
- dehrmann 4y ago> Not a single interviewee has even had a good guess in 2 years of open job recs. Unless a good explanation is an insta-offer, why do you still ask a question you've gotten zero signal from?
- deleted 4y ago[deleted]
- josephg 4y ago> why do you still ask a question you've gotten zero signal from? Interview questions aren’t just for comparing candidates with each other. It’s also useful to know how a candidate’s knowledge compares to the knowledge of the team. The best of a bad bunch might still be unhirable. It’s often better to leave a role vacant than fill it with someone mediocre. If the GP can’t find anyone in the hiring pool who knows C++ well, that’s a valuable insight. Maybe they need to expect less C++ from candidates and plan for more on the job training. Or change languages.
- archsurface 4y agoZero answer is not zero signal.
- smitty1e 4y agoNobody knows it all. If they did, would they be showing up for your interview? How someone handles that inevitable "I don't know" moment is an important data point.
- qsort 4y ago> I ask: tell me about c++’s std::move() Honest question: what do you expect the answer to be? Pedantically, the "correct" answer is that it statically casts its argument to an xvalue. Is this a way to tell if the candidate understands value categories?
- saurik 4y agoI think it would be more elucidating to consider the myriad common incorrect answers you expect to get when asking that question--which is what I expect they are dealing with, given the more about how rare even having "a good guess is"--as opposed to whether they are expecting a single particularly-correct answer.
- saagarjha 4y agoAnything that’s not that is generally incorrect in some way, though. std::move doesn’t move, or take ownership. People use it anyways. The same applies to constructs like std::forward, or the dozen ways to do initialization. C++ has a standard that incomprehensible to most people because it bends over backwards to try to come up with a unified set of rules for disparate behavior. Unless you’re a library author knowing these things off the top of your head doesn’t show much about your ability to understand some sort of understanding of the how C++ works, because there is no consistent understanding to be made. It might make sense to ask how std::move might work in Rust but it’s basically trivia for C++.
- saurik 4y agoYeah, but like, the egregiously wrong answers you are likely to get that aren't even close--not to the underlying behavior but even to the way it is commonly used--are apparently so wrong you don't even list them in your list of wrong answers ;P. Someone who doesn't know how it works but successfully have ever written a move constructor (which is a bit more advanced than merely using one) are going to come up with an answer that I would personally (as not the person who said this... for all I know they also will be super pedantic) claim is "close". But, I would fully expect the majority of people you ask that question to will, for example, actually claim stuff like that the prior value is completely destroyed... not even merely deconstructed (which is already problematic), but somehow deallocated even if located on the stack, which is way more wrong than merely thinking std::move "takes ownership". I don't know if you play chess at all, but a book I really enjoyed (and read probably about when I was your age? and the existence of which--honestly more than the specific content--massively informed my teaching style) was The Amateur's Mind, which was a chess master going back and attempting to not as much teach chess from his vantage point to an amateur but to go back and explore the misunderstandings amateurs have about chess by way of interviews with amateurs about games and then trying to work within that mental model. I think that, even though we were all amateurs at one point--or even might have a long way to go still--it can be difficult to really conceptualize the gulf between what an amateur thinks and what you might even assume is the mistake they are making.
- deterministic 4y agoPerhaps that should be a hint that you are asking the wrong questions. The job of a software developer is to solve customer problems. Not being C++ language experts. So instead ask how they have solved real customer problems, what the tech trade-offs were, why they chose the solutions they ended up with, what other possible solutions they could have used, the hardest bugs they have fixed, how they fixed it etc. I have 30+ years of experience, and have hired many C++ developers, while working for different companies around the world. And my success rate in hiring good developers have been very high. Using exactly the questions I mentioned above.