Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
ultrafilter
Aug 23, 2007

It's okay if you have any questions.


MrMoo posted:

Oh yay I have a five round interview in Philly on Thursday and another five rounder in Manhattan on Friday, and these are supposed to be small startups. One of the rounds is a debugging session which admittedly sounds pretty cool, another one slightly concerning is called a "behavioral interview".

Behavioral interviewing is just asking questions like "Tell me about a time you [did something]". It's good if it's done well.

Adbot
ADBOT LOVES YOU

Cast_No_Shadow
Jun 8, 2010

The Republic of Luna Equestria is a huge, socially progressive nation, notable for its punitive income tax rates. Its compassionate, cynical population of 714m are ruled with an iron fist by the dictatorship government, which ensures that no-one outside the party gets too rich.

ultrafilter posted:

Behavioral interviewing is just asking questions like "Tell me about a time you [did something]". It's good if it's done well.

Yeah Ive always used the STAR way of answering (Situatuon, Target, Action, Result) helps frame your answer and tick the boxes especially if you remember result includes not only what you learnt but how you then passed your learning on to help others learn as well.

MrMoo
Sep 14, 2000

3 × interviews in Philly, 1 included CSS questions of all things and coding in Java, another included a dynamic programming problem in C++, and another a complex dynamic programming algorithm for image analysis on a whiteboard. So I asked the CSS interviewer questions about cheesesteak :derp:

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

MrMoo posted:

3 × interviews in Philly, 1 included CSS questions of all things and coding in Java, another included a dynamic programming problem in C++, and another a complex dynamic programming algorithm for image analysis on a whiteboard. So I asked the CSS interviewer questions about cheesesteak :derp:

If it doesn't have whiz it's not authentic.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


leper khan posted:

If it doesn't have whiz it's not authentic.

Not a believer in provie wit?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

ultrafilter posted:

Not a believer in provie wit?

Whiz wit out or :frogout:

MrMoo
Sep 14, 2000

4 × interviews in NYC, some dynamic programming in Java but not to worry about the DP bit, something that appears a classic zig-zag array walk on a white board, debugging some Java AWT game-of-life app with way too many off-by-one errors, "have you experienced burdensome colleagues" question session and some chillax time at lunch. I even got an interview phone call on the train home.

A lot of interviews using a Macbook Air shared around. Someone decided to set it up with a super high resolution, non-natural scrolling, and Eclipse with the most awful and broken autocomplete popups ever. The CEO apparently dictated that the entire office is grey, grey carpets, grey walls, grey tables, no signage anywhere, at least the dining area has a nice view onto Madison Square Park.

Philly cheesesteak history is apparently: cheddar cheese, replaced with provolone as cheddar did not go well with beef, then the prodigal milk product made an appearance later.

MrMoo fucked around with this message at 14:23 on Aug 22, 2016

MrMoo
Sep 14, 2000

Yay, so the results are coming in. One tech interview said to "use any language" in a Python shop so I started with Java and changed course when the problem domain was a high level data structure, to JavaScript and finished quickly. It was clearing designed with Python in mind and I mentioned that as both Java and C++ would have been terrible choices to solve promptly. That was a belated "no".

Philly cheesesteak company says "we're going in another direction", :shrug:

MrMoo
Sep 14, 2000

A couple more interviews today, a time warp back 10 years. Seriously tenuous questions, like is this valid?
C++ code:
new A();
Will this compile and will this run in a ctor, dtor, member function, static function, const function?
C++ code:
delete this;
:bang:

The best one was, if you have a single source file app and you add this line to the top will it build and will it run?
C++ code:
#define struct

csammis
Aug 26, 2003

Mental Institution
Asking a candidate about the potential consequences of delete this; is a perfectly good C++ question :shrug:

#define struct...not sure where they might have been going with this, maybe wanting the candidate to recognize that #defines are just text replacement so if you and the files you include don't ever use the word 'struct' you'll be fine?

MrMoo
Sep 14, 2000

csammis posted:

Asking a candidate about the potential consequences of delete this; is a perfectly good C++ question :shrug:

A single question ok, but laboring the point in every permutation of usage is just too much. Having coding standards and following them is more acceptable than C++ rule lawyering that some developers love a bit too much. Using delete this; in a constructor is valid apparently but that does not make it not stupid.


quote:

#define struct...not sure where they might have been going with this, maybe wanting the candidate to recognize that #defines are just text replacement so if you and the files you include don't ever use the word 'struct' you'll be fine?

The interviewer was trying to replace class with struct and ask me where it would break.

hobbesmaster
Jan 28, 2008

MrMoo posted:

A single question ok, but laboring the point in every permutation of usage is just too much. Having coding standards and following them is more acceptable than C++ rule lawyering that some developers love a bit too much. Using delete this; in a constructor is valid apparently but that does not make it not stupid.

You can use it anywhere technically, https://isocpp.org/wiki/faq/freestore-mgmt#delete-this
I'm not sure its ever a good idea though?

quote:

The interviewer was trying to replace class with struct and ask me where it would break.

Then thats #define class struct
And it should always work.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

hobbesmaster posted:

Then thats #define class struct
And it should always work.
It's UB if you include any standard library headers afterwards, and members of classes are allowed to have different name mangling from members of structs. The compiler could also decide to lay out the sections differently.

csammis
Aug 26, 2003

Mental Institution

hobbesmaster posted:

You can use it anywhere technically, https://isocpp.org/wiki/faq/freestore-mgmt#delete-this
I'm not sure its ever a good idea though?

You couldn't use it in a non-member function because this isn't defined. Sounds from Mr Moo's response like that's the (bad) question that was being asked.

I have written code a couple of times where delete this; was used but each time I ended up redesigning in such a way that it's not necessary. It's unexpected behavior for an object to commit suicide in C++ so IMO it's best avoided unless you absolutely positively can't hold on to an owning pointer with a reasonable lifetime.

hobbesmaster
Jan 28, 2008

Plorkyeran posted:

It's UB if you include any standard library headers afterwards, and members of classes are allowed to have different name mangling from members of structs. The compiler could also decide to lay out the sections differently.

Yes, I meant in your own code compiling your own classes. This is why I screw up interviews!

Why can't C++ questions be more like Hashmap vs Hashtable

b0lt
Apr 29, 2005

hobbesmaster posted:

You can use it anywhere technically, https://isocpp.org/wiki/faq/freestore-mgmt#delete-this
I'm not sure its ever a good idea though?

It's illegal in a constructor for a type with non-trivial destructor, and in destructors always:

3.8.1 posted:

The lifetime of an object of type T begins when:
— storage with the proper alignment and size for type T is obtained, and
— if the object has non-trivial initialization, its initialization is complete

The lifetime of an object of type T ends when:
— if T is a class type with a non-trivial destructor (12.4), the destructor call starts, or

3.8.5 posted:

Before the lifetime of an object has started but after the storage which the object will occupy has been
allocated40 or, after the lifetime of an object has ended and before the storage which the object occupied is
reused or released, any pointer that refers to the storage location where the object will be or was located
may be used but only in limited ways.
[...]
The program has undefined behavior if:
— the object will be or was of a class type with a non-trivial destructor and the pointer is used as the
operand of a delete-expression

12.4.15 posted:

Once a destructor is invoked for an object, the object no longer exists; the behavior is undefined if the
destructor is invoked for an object whose lifetime has ended (3.8).

sarehu
Apr 20, 2007

(call/cc call/cc)
Notably the standard also implies when describing exception unwinding that the object isn't "initialized" until after the constructor body has finished. I didn't find a place that explicitly said that, but I didn't look exhaustively.

Imagine what happens if you call delete this in a constructor and then throw an exception after that.

MrMoo
Sep 14, 2000

hobbesmaster posted:

Then thats #define class struct
And it should always work.

The interviewer was looking for something in templates, e.g.
C++ code:
template <class T> // template argument
void qux() {
    T t;
}
Although I guess one should be able to template a struct there is probably some conditional operator that breaks.

Maybe something like nested templates:
C++ code:
template <template <typename> class Store, typename T>
struct CachedStore2 {
  Store<T> store;
  Cache<T> cache;
};

MrMoo fucked around with this message at 18:57 on Aug 23, 2016

b0lt
Apr 29, 2005

hobbesmaster posted:

Then thats #define class struct
And it should always work.

code:
#ifdef class
#error lol
#endif

GeneralZod
May 28, 2003

Kneel before Zod!
Grimey Drawer
Seems to work with recent clang and gcc:

code:
#include <type_traits>

#define class struct // Comment me out for compilability!

class A
{
    static int f()
    {
        return 0;
    };
};

template <typename T>
class B
{
    public:
        template <typename U, typename = decltype(U::f())>
        static void g(U u);

        static int g(...);
        typedef decltype(g(std::declval<T>())) bloo;
};

int main()
{
    B<A>::bloo x;
}
Maybe using type traits is cheating, but here's another one anyway:

code:
#include <type_traits>

#define class struct // Comment me out for compilability!

class A
{
    int i;
    private:
    int j;
};

template <typename T>
class B
{
};

template <>
class B<std::false_type>;

int main()
{
    B<typename std::is_pod<A>::type> b;
}

GeneralZod fucked around with this message at 20:40 on Aug 23, 2016

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

sarehu posted:

Notably the standard also implies when describing exception unwinding that the object isn't "initialized" until after the constructor body has finished. I didn't find a place that explicitly said that, but I didn't look exhaustively.

Imagine what happens if you call delete this in a constructor and then throw an exception after that.

Is the answer that you'll need to find a new job?

hobbesmaster
Jan 28, 2008

MrMoo posted:

The interviewer was looking for something in templates, e.g.
C++ code:
template <class T> // template argument
void qux() {
    T t;
}
Although I guess one should be able to template a struct there is probably some conditional operator that breaks.

Maybe something like nested templates:
C++ code:
template <template <typename> class Store, typename T>
struct CachedStore2 {
  Store<T> store;
  Cache<T> cache;
};

A struct is a class. Full stop.

Take a look at the C++14 standard starting on page 226. You may be surprised at the keywords they use when describing class declarations.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

hobbesmaster posted:

A struct is a class. Full stop.

Take a look at the C++14 standard starting on page 226. You may be surprised at the keywords they use when describing class declarations.

I have walked out of interviews because the :airquote:lead engineer/CTO:airquote: interviewing me tried to argue that there were significant differences between class and struct in C++11 other than default public/private.

Because that's the only difference.

hobbesmaster
Jan 28, 2008

Unions are also classes if we're talking about C++ trivia.

I have no idea why.

SeXTcube
Jan 1, 2009

Are companies actually looking to round out their office Jeopardy or pub quiz teams? That's the only scenario I can imagine where hiring people based on how many trivia questions they can get right makes sense.

b0lt
Apr 29, 2005

hobbesmaster posted:

Unions are also classes if we're talking about C++ trivia.

I have no idea why.

More fun trivia: typedef is a storage class.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

Steve Jorbs posted:

Are companies actually looking to round out their office Jeopardy or pub quiz teams? That's the only scenario I can imagine where hiring people based on how many trivia questions they can get right makes sense.

This thread circles the point, but for hiring up to a mid-senior developer/engineer, there's only so much you can do in a limited time to screen a candidate's technical knowledge. I'm currently involved in tech screening for two positions - one a senior/lead, and one a mid-senior seat - and I find that I'm having reasonable success by having a mix of stuff. Some soft "oh hey just tell me about stuff" to get a feel for whether you're bullshitting by putting it on your resume - does your answer to "So tell me about F#" sound like a stack overflow/wikipedia page? But also mixed in some hard technical trivia around the languages - if they're physically present I'll ask for whiteboarded code, but that isn't always possible.

I mean, when is trivia *too* trivial?

Should a C# developer with 10+ years of experience be able to explain the difference between Reference and Value types and when creating a Value type is appropriate? What about the differences between IEnumerable & IQueryable?

Should a developer with 15+ years of experience be able to describe various IOC options, beyond just 'Dependency Injection'?

Should a developer with a master's degree be able to be asked the classic "n machines, one is faulty, using only 1-to-1 comparisons how do you find the faulty machine?" question and provide a reasonable answer? Or is that trivia?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Cuntpunch posted:

I mean, when is trivia *too* trivial?

I think if a valid answer to a question is "I don't know, why the hell would you do that in the first place" (as in the case of the "#define class struct" thing) then it is not a suitable interview question. I mean, if it's never going to come up with a sane team writing sane code then why do you care whether the candidate can work out on the spot what would happen? I think the examples of questions you gave in your post are solid, with the possible exception of the faulty machines one.

b0lt
Apr 29, 2005

Hammerite posted:

I think if a valid answer to a question is "I don't know, why the hell would you do that in the first place" (as in the case of the "#define class struct" thing) then it is not a suitable interview question. I mean, if it's never going to come up with a sane team writing sane code then why do you care whether the candidate can work out on the spot what would happen? I think the examples of questions you gave in your post are solid, with the possible exception of the faulty machines one.

You should never do #define class struct, but you should be able to reason about what it would do, because you know the difference between a class and a struct.

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug
The thing of it is, though, how much actual programming relies on people knowing bizarre trivia like that?

hobbesmaster
Jan 28, 2008

In C++? A surprising amount!

sarehu
Apr 20, 2007

(call/cc call/cc)

ToxicSlurpee posted:

The thing of it is, though, how much actual programming relies on people knowing bizarre trivia like that?

Like, I definitely needed to have been able to know to question whether calling "delete this" from a constructor might be a terrible idea, because that's a plausible thing that makes sense to do, if not for exceptions and the possibility that you aren't the bottommost subclass. I've done it from a member function of course, and reasoning through whether it works from a const member function is just trivia about whether you deleting a pointer to const object in general will compile.

Of course there's other gotchyas like virtual destructors, the rule of three, explicit constructors, exception safety, and C gotchyas, that are more mundane stuff that you have to know.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

hobbesmaster posted:

In C++? A surprising amount!

Yeah, things which sound like useless C++ trivia turn out to be relevant far more often than you'd hope.

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

Plorkyeran posted:

Yeah, things which sound like useless C++ trivia turn out to be relevant far more often than you'd hope.

I'll admit that's a fair point but I haven't written C++ since college.

C# and Java have spoiled me. :v:

Sex Bumbo
Aug 14, 2004
C++ has probably crossed the threshold where it's more bullshit trivia than a language at this point. The rabbit hole of nonsense goes on seemingly forever.

Cuntpunch posted:

This thread circles the point, but for hiring up to a mid-senior developer/engineer, there's only so much you can do in a limited time to screen a candidate's technical knowledge. I'm currently involved in tech screening for two positions - one a senior/lead, and one a mid-senior seat - and I find that I'm having reasonable success by having a mix of stuff. Some soft "oh hey just tell me about stuff" to get a feel for whether you're bullshitting by putting it on your resume - does your answer to "So tell me about F#" sound like a stack overflow/wikipedia page? But also mixed in some hard technical trivia around the languages - if they're physically present I'll ask for whiteboarded code, but that isn't always possible.

I mean, when is trivia *too* trivial?

Should a C# developer with 10+ years of experience be able to explain the difference between Reference and Value types and when creating a Value type is appropriate? What about the differences between IEnumerable & IQueryable?

Should a developer with 15+ years of experience be able to describe various IOC options, beyond just 'Dependency Injection'?

Should a developer with a master's degree be able to be asked the classic "n machines, one is faulty, using only 1-to-1 comparisons how do you find the faulty machine?" question and provide a reasonable answer? Or is that trivia?

Trivia is pointless because you're not getting much if you hire someone whose main selling point is not having to do two second google searches. As weird as C++ is, once you get a vague understanding of the rules you can make fairly reasonable assumptions about performance and memory and you can easily verify your assumptions by looking at the assembly it generates. You can just bang on a lot of things until they come out how you want them to.

Rather than ask trivia you can ask more senior people about projects they've worked on, the complications they ran into, and how they solved them. You're giving them a prompt, a ton of rope, and an opportunity to hang themselves or not. You can work even if you personally don't have a great understanding of the platforms they were working on.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

b0lt posted:

You should never do #define class struct, but you should be able to reason about what it would do, because you know the difference between a class and a struct.

If you want to determine whether the candidate knows the difference between a class and a struct, why not ask them "what's the difference between a class and a struct?"

return0
Apr 11, 2007

Hammerite posted:

If you want to determine whether the candidate knows the difference between a class and a struct, why not ask them "what's the difference between a class and a struct?"

Because this tells you if they know what #define is, and their comments on the line of code beyond the immediate answer can provide additional insight into their practical experience?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

return0 posted:

Because this tells you if they know what #define is, and their comments on the line of code beyond the immediate answer can provide additional insight into their practical experience?

Well, okay. I feel like if you want to test the candidate on whether they know how the preprocessor works you have better ways of doing that than asking them stupid questions. Like for example, you could ask them what's wrong with this:

code:
#define ADD(x, y) x + y

qntm
Jun 17, 2009

Hammerite posted:

Well, okay. I feel like if you want to test the candidate on whether they know how the preprocessor works you have better ways of doing that than asking them stupid questions. Like for example, you could ask them what's wrong with this:

code:
#define ADD(x, y) x + y

What is wrong with that?

Adbot
ADBOT LOVES YOU

GeneralZod
May 28, 2003

Kneel before Zod!
Grimey Drawer

qntm posted:

What is wrong with that?

There are probably other examples, but try:

code:
#include <iostream>

using namespace std;

#define ADD(x, y) x + y

template <typename T>
T add(const T& x, const T& y)
{
    return x + y;
}

int main()
{
    // The fact that I'm having to use printf instead of cout is bug #1 :p
    printf("Normal add %d Macro ADD: %d\n", add(3 & 3, 4), ADD(3 & 3, 4));
    printf("Normal add %d Macro ADD: %d\n", add(3, 5 & 3), ADD(3, 5 & 3));
    printf("Normal add %d Macro ADD: %d\n", 5 * add(1, 2), 5 * ADD(1, 2));
}


edit:

For further fun, try:

code:
#include <iostream>

using namespace std;

#define ADD(x, y) x + y

template <typename T, typename U>
class TwoTemplateTypes
{
    public:
        const static int value = 1;
};
template<typename T, typename U> 
const int TwoTemplateTypes<T, U>::value;

template <typename T>
T add(const T& x, const T& y)
{
    return x + y;
}

int main()
{
    printf("Normal add %d Macro ADD: %d\n", add(TwoTemplateTypes<int, int>::value, 2), 
            ADD(TwoTemplateTypes<int, int>::value, 2)
            );
}

GeneralZod fucked around with this message at 13:37 on Aug 24, 2016

  • Locked thread