• Hey Guest. Check out your NeoGAF Wrapped 2025 results here!

My company is trying to hire competent developers

Status
Not open for further replies.
It was kind of serious, kind of semi-troll itself. If anyone's asking how to do something incredibly artificial and unnecessary, then the question of why they're asking that is important too. The best answer to the question "how would you swap two integer variables without using a temp variable" to my mind would be "I wouldn't, unless you have a situation that actually requires it."

Again, this is why I hate developer interviews. It's all about the e-peen and that's really not helpful.

Once I was asked "If you were to design a bike for a blind person how would you do it.?"

I was like "I wouldn't. It's a bad idea."
 
Except, of course, that they don't necessarily test these skills in a way that actually works well. Especially when people (like the OP) are concerned about them getting the right answer. The best interviews I've attended have included simple real-world coding cases.

Yeah, I mean in the OP's case he should probably be asking more practical questions. I work in very large scale systems so it is impossible to find real questions if I want to ask more than one in a single interview.
 
All this talk of string reversal made me come up with an awesome interview question. I might even use it next time I interview someone.

Consider the following two functions:

Code:
void reverse1(char* str, int len)
{
     int mid = len/2;
     for (int i=0; i < mid; ++i)
          swap(str[i], str[len-i-1]);
}

void reverse2(char* str, int len)
{
     char* other = new char[len+1];
     other[len] = 0;
     for (int i=0; i < len; ++i)
          other[len-i-1] = str[i];
     memcpy(str, other, len);
     delete[] other;
}

1) Which is faster, and why? If your answer is "it depends", elaborate.
2) Whichever version you decide is faster, discuss some additional changes that might make it even faster.

Your first instinct may not be correct

I don't understand how the second function could possibly be considered faster, even by initial inspection. Memory related activities would make it noticeably slower. It's a basic tenet of programming and embedded systems.
 
for mobile / web / backend and it's nearly impossible to find any that are currently looking for a job. We've been searching for a year for candidates that can reverse a string and do the fib sequence recursively and we'll only found three.

Any one else experiencing the same talent drought at their company?

My company, IAC, is based in NYC.

I can reverse a string and do recursion. I understand object oriented programming. I don't have a 4 year degree though. Just a 2 year from a junior college and 2 years of junior DBA experience.
 
I can reverse a string and do recursion. I understand object oriented programming. I don't have a 4 year degree though. Just a 2 year from a junior college and 2 years of junior DBA experience.

Here's the thing I tell my students: no employer is going to expect a low-level engineer, programmer, or technologist to re-invent the wheel. That's what libraries and the overall programming team is for. The interview process is to identify the candidates that demonstrate problem solving skills (ie. how they approach a problem), programming literacy, and trainability.

I'd say your two years of junior DBA experience will get you far. Practical experience is always an asset.
 
Do you mean that the second writes to a different place than it reads from? I'd expect that would result in better optimizations. Copying large blocks of data like that would probably be more optimized (though you'd do it twice), and you could be pretty sure you'd never stall the pipeline. I'm not entirely sure that would be the case, but it's my bet.

Though, I still think the first would probably be faster. Allocating that extra memory and doing two copies is not something I'd expect to be cheap. Profiling might be interesting.

Hmm... I'm thinking the 2nd one is faster because it encapsulates(sp?) the process whereas the 1st one your calling another swap function who knows how many times. I see you also allocating/deallocating dynamic memory in the 2nd one so after you make the memcpy you just return that memory to the system. Pretty cool. I like it.

Idk, how you make it faster. I'm too tired to think "see" clearly. lol. Also, the code like[ len-i-1] takes me awhile to see so I have to always work it out in my head with an example lol :(

I don't understand how the second function could possibly be considered faster, even by initial inspection. Memory related activities would make it noticeably slower. It's a basic tenet of programming and embedded systems.

Slavik81 is almost correct. But to elaborate, basically it comes down to the fact that the first makes horrible use of the L1 cache, and the second version makes perfect use of the L1 cache. If you think this is a micro-optimization then it is, but believe it or not there are cases where the difference is so large that it dominates the difference between going down an algorithmic order of complexity (for example from n^2 to n log n, or from n log n to n, etc).

Let's suppose your L1 cache is 128 bytes, as this is a pretty common size. Now let's suppose your string is less than or equal to 128 bytes. In that case the first version is clearly faster because the entire string fits in cache. Your very first read to the first byte of the string causes a cache miss and then 128 bytes are loaded into L1. At that point, you are free to read from the end of the string and it doesn't matter because it's in L1 cache, meaning that the read is practically as fast as reading from a register, 1 cycle.

On the other hand, let's say your string is like 256 bytes. Things start to get ugly here.

swap(s[0], s[255])
- Read s[0] (cache miss, load s[0] - s[127] into L1 cache)
- Read s[255] (cache miss, load s[255] - s[382] into L1 cache)
swap(s[1], s[254])
- Read s[1] (cache miss, load s[1] - s[128] into L1 cache)
- Read s[254]) (cache miss, load s[254] - s[381] into L1 cache)

As you can see, every single read is going to generate a cache miss. Do not underestimate the performance penalty of this. Yes, it's a micro-optimization, but if your string is long it will be an orders of magnitude difference. In particular there are (processor specific) thresholds at which the string stops fitting even into L2 cache, and if you have to hit main memory for every single one of these reads it's going to be just awful.


Compare this to the second version of the function. The read location is only ever incremented by a single byte. Thus, you will always have 1 cache miss followed by 127 cache hits, until the string is exhausted

So, as for the "it depends" part. If your string is long enough then the performance penalty from all the cache misses will trump the performance penalty from doing the alloc and free at the beginning and end of the function, and the second version will be faster.


How to use this information? Ideas:

1) Put an if statement at the beginning of the function to check the length, and use a different algorithm depending on if it's greater than some hardcoded value. You might determine this value by profiling the function on strings of differing lengths and determining where the threshold is at which v2 becomes faster. If you know that due to the way you use it, one case is significantly more probable than the other one, check if your compiler has LIKELY() and UNLIKELY() intrinsics that allow the compiler to optimize branch prediction better.

2) Use a statically allocated global memory buffer instead of a new/delete every time. There are some negatives here, which is that you now can't use reverse from multiple threads, and also that you can't use reverse on strings that are larger than your globally allocated memory buffer.
- The first problem can be solved by putting this buffer in thread local storage.
- If it's small enough, you can also put this buffer on the stack (e.g. declare a very large array as a local variable, and use that as your second buffer)

3) Investigate ways of using a single fixed size buffer to work on strings of arbitrary length. For example, suppose your buffer is 128 bytes. You copy the first 128 bytes in reverse into the temporary buffer. Then you do a memmove operation on the rest of the buffer to the beginning, then copy the 128 bytes into the end of the string. Then repeat this process until the whole thing is done. There's no guarantee this would be more performant, it's just an idea.

I'm also surprised at the number of people in the thread saying this is a stupid question because why would you ever reverse a string. I just looked in our codebase at work which is for a PC game with a few hundred thousand lines of code, and I found many, many instance where a collection was being reversed. It doesn't have to be a string, it can be an array, or anything else where things come after other things.
 
I'm also surprised at the number of people in the thread saying this is a stupid question because why would you ever reverse a string. I just looked in our codebase at work which is for a PC game with a few hundred thousand lines of code, and I found many, many instance where a collection was being reversed. It doesn't have to be a string, it can be an array, or anything else where things come after other things.
Reversing strings and reversing arrays are completely different things. It's not even remotely the same except for the word use "reverse".
 
Reversing strings and reversing arrays are completely different things. It's not even remotely the same except for the word use "reverse".

You know strings are arrays of characters right? Reversing a string is reversing an array. Your comment is quite the exaggeration.
 
Slavik81 is almost correct. But to elaborate, basically it comes down to the fact that the first makes horrible use of the L1 cache, and the second version makes perfect use of the L1 cache. If you think this is a micro-optimization then it is, but believe it or not there are cases where the difference is so large that it dominates the difference between going down an algorithmic order of complexity (for example from n^2 to n log n, or from n log n to n, etc).

Let's suppose your L1 cache is 128 bytes, as this is a pretty common size. Now let's suppose your string is less than or equal to 128 bytes. In that case the first version is clearly faster because the entire string fits in cache. Your very first read to the first byte of the string causes a cache miss and then 128 bytes are loaded into L1. At that point, you are free to read from the end of the string and it doesn't matter because it's in L1 cache, meaning that the read is practically as fast as reading from a register, 1 cycle.

On the other hand, let's say your string is like 256 bytes. Things start to get ugly here.

swap(s[0], s[255])
- Read s[0] (cache miss, load s[0] - s[127] into L1 cache)
- Read s[255] (cache miss, load s[255] - s[382] into L1 cache)
swap(s[1], s[254])
- Read s[1] (cache miss, load s[1] - s[128] into L1 cache)
- Read s[254]) (cache miss, load s[254] - s[381] into L1 cache)

As you can see, every single read is going to generate a cache miss. Do not underestimate the performance penalty of this. Yes, it's a micro-optimization, but if your string is long it will be an orders of magnitude difference. In particular there are (processor specific) thresholds at which the string stops fitting even into L2 cache, and if you have to hit main memory for every single one of these reads it's going to be just awful.


Compare this to the second version of the function. The read location is only ever incremented by a single byte. Thus, you will always have 1 cache miss followed by 127 cache hits, until the string is exhausted

So, as for the "it depends" part. If your string is long enough then the performance penalty from all the cache misses will trump the performance penalty from doing the alloc and free at the beginning and end of the function, and the second version will be faster.


How to use this information? Ideas:

1) Put an if statement at the beginning of the function to check the length, and use a different algorithm depending on if it's greater than some hardcoded value. You might determine this value by profiling the function on strings of differing lengths and determining where the threshold is at which v2 becomes faster. If you know that due to the way you use it, one case is significantly more probable than the other one, check if your compiler has LIKELY() and UNLIKELY() intrinsics that allow the compiler to optimize branch prediction better.

2) Use a statically allocated global memory buffer instead of a new/delete every time. There are some negatives here, which is that you now can't use reverse from multiple threads, and also that you can't use reverse on strings that are larger than your globally allocated memory buffer.
- The first problem can be solved by putting this buffer in thread local storage.
- If it's small enough, you can also put this buffer on the stack (e.g. declare a very large array as a local variable, and use that as your second buffer)

3) Investigate ways of using a single fixed size buffer to work on strings of arbitrary length. For example, suppose your buffer is 128 bytes. You copy the first 128 bytes in reverse into the temporary buffer. Then you do a memmove operation on the rest of the buffer to the beginning, then copy the 128 bytes into the end of the string. Then repeat this process until the whole thing is done. There's no guarantee this would be more performant, it's just an idea.

I'm also surprised at the number of people in the thread saying this is a stupid question because why would you ever reverse a string. I just looked in our codebase at work which is for a PC game with a few hundred thousand lines of code, and I found many, many instance where a collection was being reversed. It doesn't have to be a string, it can be an array, or anything else where things come after other things.

Very good writeup. I learnt something from this explanation.
 
Reversing strings and reversing arrays are completely different things. It's not even remotely the same except for the word use "reverse".
It is the same. The only difference is the size of the objects in the array.
Now, you can argue that different types of collections will require different methods of reversal to maximize performance.

However, reversing a string is definitely the same as reversing an array in most languages though you may need things like stringbuilder or stringbuffer depending upon mutability of strings in your language of choice.
 
You know strings are arrays of characters right? Reversing a string is reversing an array. Your comment is quite the exaggeration.

I think they meant that most modern languages have an array.reverse() function, while strings dont and involve a bit more thinking.

Then again I could be completely wrong, as I never bothered to look up if something like that exists for C# or Java.
 
I think they meant that most modern languages have an array.reverse() function, while strings dont and involve a bit more thinking.

Then again I could be completely wrong, as I never bothered to look up if something like that exists for C# or Java.
StringBuilder has a reverse method in Java.
You can export a string to a character array, use a collection reverse method, then append to a stringbuilder in C# as one way though it's not the best method by a long shot.
 
I think they meant that most modern languages have an array.reverse() function, while strings dont and involve a bit more thinking.

Then again I could be completely wrong, as I never bothered to look up if something like that exists for C# or Java.

Maybe that's what they meant, not sure. Either way, under the hood the strings are almost certainly implemented as contiguous chunks of memory with the characters of the string embedded in that memory, whereas arrays are implemented exactly the same way. Algorithmically, reversing one is the same as reversing the other.

I guess for those interviewers that would accept String.reverse() as a suitable answer to the question, they might seem like completely different things. Personally I value understanding how code works more highly than being able to give an answer to the question that produces the right output, so for me such an answer would be a pretty big negative.
 
Ah, the caches. I still need to learn about that.

If you're doing high-level stuff, you don't really need to.

But if you're getting towards C++, and especially C or lower, you do really need to.

And either way, you need to have enough knowledge to have a sense of optimization. If you don't know the caches exist, you'll never understand cpp's optimization, but if you're doing Java-style garbage-collected code you should be more concerned with how to best deallocate resources. It's a good idea to know about the internals but it's a better idea to know what is and isn't applicable for your environment in the first place.

And you also need to consider the battle between computer-optimized code and human-optimized code. Nobody's gonna love you shaving 2ms off an infrequently-used function by turning it into alphabet soup. Someone's gonna have to maintain that shit.
 
I had my C++ class final today, and one of the extra credit questions was the one about swapping two integers without using an extra variable. I just read that post in this topic last night, so thanks for helping me get some extra credit, GAF! =D
 
I had my C++ class final today, and one of the extra credit questions was the one about swapping two integers without using an extra variable. I just read that post in this topic last night, so thanks for helping me get some extra credit, GAF! =D
Which method did ypu use? Subtraction or xor'ing

I dont know if the xor method was mentioned here so i wrote the xor version below

Code:
a = a ^ b;
b = a ^ b;
a = a ^ b;
 
If you're doing high-level stuff, you don't really need to.

But if you're getting towards C++, and especially C or lower, you do really need to.

And either way, you need to have enough knowledge to have a sense of optimization. If you don't know the caches exist, you'll never understand cpp's optimization, but if you're doing Java-style garbage-collected code you should be more concerned with how to best deallocate resources. It's a good idea to know about the internals but it's a better idea to know what is and isn't applicable for your environment in the first place.

And you also need to consider the battle between computer-optimized code and human-optimized code. Nobody's gonna love you shaving 2ms off an infrequently-used function by turning it into alphabet soup. Someone's gonna have to maintain that shit.

I know they exist and all that but my courses so far have dealt with just programming and ADTs in C++. I'm gonna take that course next semester though.
 
I had my C++ class final today, and one of the extra credit questions was the one about swapping two integers without using an extra variable. I just read that post in this topic last night, so thanks for helping me get some extra credit, GAF! =D

Maybe your professor reads NeoGAF :)
 
For the person in the OP, my experience in computer engineering at a supposedly good university 10 years ago was that we were asked to do a lot with little or no instruction. Essentially all engineering school did was put us in a position to learn everything on our own under harsh time pressures.

When an engineer with no professional experience performs badly on a technical interview question it only means that he or she hasn't necessarily faced that problem before. For example, we were never taught anything about or required to program in C++ at all, which is required for almost any job, leaving us totally unprepared for interviews. Given the opportunity, any new engineer averaging 75%+ in university would be perfectly capable of self-teaching any programming language or skills if allowed a short time to do it. With some assistance from an employer, new people can learn programming even faster so minimal programming skills shouldn't be the reason why a creative, inventive person is overlooked for an entry level job.

If you are finding entry level people don't have the programming experience you are looking for, perhaps better interview questions would be to discuss how the candidate might logically solve particular problems instead of having to write code on the spot. You may also want to look at candidates from Canada as engineering jobs in Canada are extremely hard to get unless you start your own company.
 
Is that a common programming example/problem?

Nope. It's definitely more of a C/low-level problem. I don't think there's a native way to do that in Java, though I could be wrong.

It's not a very useful problem, though. It might save a tiny bit of memory in an embedded application, but at what cost to performance (maybe none, I don't know how costly XOR is vs. swapping w/ temp variables)?

edit: hmmm Java does have a bitwise XOR operator. I guess it must work, in that case. I have used the XOR operator in Java, but only on booleans...I've never had a use for applying it to integers.

It's more of a problem that challenges creative thinking or thinking outside the box, so it's well suited to a bonus question.

If I were asked that question, I would have done it this way:

Code:
a = a + b;
b = a - b;
a = a - b;

That's what intuitively came to mind, for me.
 
Nope. It's definitely more of a C/low-level problem. I don't think there's a native way to do that in Java, though I could be wrong.

It's not a very useful problem, though. It might save a tiny bit of memory in an embedded application, but at what cost to performance (maybe none, I don't know how costly XOR is vs. swapping w/ temp variables)?

edit: hmmm Java does have a bitwise XOR operator. I guess it must work, in that case. I have used the XOR operator in Java, but only on booleans...I've never had a use for applying it to integers.

It's more of a problem that challenges creative thinking or thinking outside the box, so it's well suited to a bonus question.

If I were asked that question, I would have done it this way:

Code:
a = a + b;
b = a - b;
a = a - b;

That's what intuitively came to mind, for me.
The xor method works in almost all languages as well as the subtraction method.
The xor method is faster than subtraction due to the processor not needing to do amy carry or overflow checks.

The advantage of such a solution without a temp variable is in the lower memory requirement which can be vital on embedded platforms with a small stack.
 
I graduated a year or so ago in Comp Sci, and while I have been working as a developer (in a limited fashion), algorithmically off the top of my head I couldnt do the tests mentioned, I am good at logic tests, but at writing algorithmic functions ive not exactly memorized them. Unfortunately I think that theoretically my knowledge will limit me. So outside of school what would you recommend to learn and further develop my knowledge?

When I do program, I usually know what to do and if not google helps, but because I havent been part of a large scale Software Engineering project im worried that theoretically im going to struggle. I havent really programmed in a OO manner since graduating and well I think I had better get on top of my programming ability.

Any books you would recommend, my background lies in Java rather than C if that helps.
 
So today we interviewed an individual that the phone screener said was among the best people he phone screened. Not like those hacks we had face-to-face interviews with last week, this person was legit.

So we brings the guy in. We sits the guy down, and we says to him... we says to the guy... we says we says we says, he's sitting there, we're sitting here, and we says to the guy...

Oops, fell into a little Hank Doodle.

Long story short, it was yet another bombed interview. I don't know what gives, if the people are just so incredibly nervous that they can't form coherent sentences on the basic questions, or what. These people have years of experience listed on their resumes. 5 years, 8 years, 20 years. Can't answer the most basic of questions. I'm talking basic. "Difference between X and Y and if you've even made it to chapter 3 of your 'Intro to C#' book you couldn't possibly not know the answer" type questions. Database 101 type questions. "Do you even have a pulse" type questions.

We had a guy who supposedly worked at a community college as an instructor on a language. He didn't know the language.

:/

It hurts when these people bomb so hard.
 
So today we interviewed an individual that the phone screener said was among the best people he phone screened. Not like those hacks we had face-to-face interviews with last week, this person was legit.

So we brings the guy in. We sits the guy down, and we says to him... we says to the guy... we says we says we says, he's sitting there, we're sitting here, and we says to the guy...

Oops, fell into a little Hank Doodle.

Long story short, it was yet another bombed interview. I don't know what gives, if the people are just so incredibly nervous that they can't form coherent sentences on the basic questions, or what. These people have years of experience listed on their resumes. 5 years, 8 years, 20 years. Can't answer the most basic of questions. I'm talking basic. "Difference between X and Y and if you've even made it to chapter 3 of your 'Intro to C#' book you couldn't possibly not know the answer" type questions. Database 101 type questions. "Do you even have a pulse" type questions.

We had a guy who supposedly worked at a community college as an instructor on a language. He didn't know the language.

:/

It hurts when these people bomb so hard.

What kind of questions are we talking about? Also, what are the responsibilities of the position?
 
What kind of questions are we talking about?

Trivial stuff, like an example to see if they even understood variable assignment: given

Code:
string x = "fred flintstone";
string y = x;
x = "barney rubble";
Console.WriteLine(y);

What's written to the screen?

The answer we received : "Neither fred flintstone or barney rubble."

Say what?
Of the ways I already expected to hear a wrong answer, this one caught me completely off guard.

Also, what are the responsibilities of the position?

To wade through some of the most horrible code you've never even imagined and somehow keep your sanity. It's because of people like the ones we've interviewed that the code is so beyond horrendous and essentially unmaintainable (*Microsoft's words, not just ours).


*They did a code review of our application. I wouldn't have blamed them if they yanked our Visual Studio license on the spot.
 
Trivial stuff, like an example to see if they even understood variable assignment: given

Code:
string x = "fred flintstone";
string y = x;
x = "barney rubble";
Console.WriteLine(y);

What's written to the screen?

The answer we received : "Neither fred flintstone or barney rubble."

Say what?
Of the ways I already expected to hear a wrong answer, this one caught me completely off guard.

Pretty sure it's Fred Flintstone.

But what about Pebbles and Bambam?
 
To wade through some of the most horrible code you've never even imagined and somehow keep your sanity. It's because of people like the ones we've interviewed that the code is so beyond horrendous and essentially unmaintainable (*Microsoft's words, not just ours).


*They did a code review of our application. I wouldn't have blamed them if they yanked our Visual Studio license on the spot.

Aha. Reminds me of one of the places I used to work at. They had an old legacy application that would issue a query from a batch file and write the result to a text file. The text file would be opened from the Visual Basic application. The Visual Basic Application would then write it into an xml file. That xml file would then be parsed by an application written in C++. Then, that xml file would be written to yet another xml file by another application written in C++. Repeat two more times. Then, finally, it would be added to an archive. I spent a fair amount of time debugging that application so that I could identify its dependencies. The program was a mess to say the least.
 
What's written to the screen?
Let me walk through this and correct me if I'm wrong anywhere.

x is initiated to "fred flintstone".
y is initiated but points to "fred flintstone".
x then points to "barney rubble"
y, which still points to "fred flintstone" is written.
 
So I am now seriously intrigued... how much does a senior programmer earns? I have 6 years of experience in .NET mostly.

Depends really... At the end of next year, I'll be making close to 70k with three years experience (Dallas area). I've had several significant raises at my current place though with two contractually obligated raises coming in June and December of next year.

On the other hand, I have friends with 5 or 6 years experience making around 55k.
 
Just to give you an idea of what is literally all over our code base, just as sort of an appetizer as to the sick, twisted, depraved mind of the individuals who have worked on this code. Not the most egregious example in the code base, not anything insanely complicated, just a simple line of code to take a peek into dementia:

Code:
long id = Convert.ToInt64(null);

Now, when I first saw this in the code, I was convinced it wasn't real. Like it was an insanity effect from Eternal Darkness or something. I was like, this has to be in a section of code that is basically on an unreachable path, because there's no way this even executes.

I came to learn, of course, the the Convert.ToXXX methods are documented to return the default value for the type XXX when the input is null for all types except System.String. So the above example is going to return 0. If you want 0, just write 0!

The contractor who happened to check this particular line of code was still there, so I went to him and asked "what the fargo is this? why did you write it?" And he said, ahem "don't look at me, I just copied and pasted that whole surrounding snippet of code!"

Which brings us to another problem in our code, something I rail against to the new developers that come through. I tell them, "don't write bad code. People will see it, copy it, paste it all over the place, and now your one little piece of bad code is all over the application. If people are going to copy and paste your code, at least give them code worth copying."

And, indeed, that horrible little snippet of code is in our application hundreds of times.
 
Let me walk through this and correct me if I'm wrong anywhere.

x is initiated to "fred flintstone".
y is initiated but points to "fred flintstone".
x then points to "barney rubble"
y, which still points to "fred flintstone" is written.

Yes, this is pretty much all I wanted to hear. The little snare I inserted in there was the misdirection of reassigning x, some people seem to (for whatever reason) think variable reassignment does some magic voodoo when dealing with classes, as if variables that share a common value (a reference to an object) are somehow linked for all time. I wanted to simply find out if I was dealing with such an individual. I expected a wrong answer of "barney rubble" if one was to come. The answer I got was truly surprising.
 
Yes, this is pretty much all I wanted to hear. The little snare I inserted in there was the misdirection of reassigning x, some people seem to (for whatever reason) think variable reassignment does some magic voodoo when dealing with classes, as if variables that share a common value (a reference to an object) are somehow linked for all time. I wanted to simply find out if I was dealing with such an individual. I expected a wrong answer of "barney rubble" if one was to come. The answer I got was truly surprising.

Well, I think how references in C# and even Java trip some people up especially those coming from native languages.

As a nice mirror to that question, it would be good to have a question like

Code:
StringBuilder x = new StringBuilder("fred flintstone");
StringBuilder y = x;
x.Replace("fred flintstone", "barney rubble");
Console.WriteLine(y);

The interviewee's reasoning behind why y prints "barney rubble" in this case but not in the prior case can be very enlightening.

Edit: Also, to test the interviewee's knowledge of string immutability. Do something like.

Code:
string x = "fred flintstone";
string y = x;
x += " barney";
Console.WriteLine(y);
 
So I am now seriously intrigued... how much does a senior programmer earns? I have 6 years of experience in .NET mostly.

Anywhere from 70k - 200k depending on experience and location. Part of it is that everyone has a different definition of senior, because every company has to have at least 1 or 2 senior developers just to look good. But when you compare senior programmer from some crappy company that nobody gives a shit about to a larger company making stuff that everyone knows about it, there's many orders of magnitude difference.

mugurumakensei said:
Depends really... At the end of next year, I'll be making close to 70k with three years experience (Dallas area). I've had several significant raises at my current place though with two contractually obligated raises coming in June and December of next year.
You're underpaid. I started my career in Texas so I'm pretty familiar with the payscales. Best way to get a raise is to change jobs. Best way to build experience is to work on a "high impact" project. The more people / customers / clients / users of the thing you work on, the better. A million is a good mid to long term target.
 
Edit: Also, to test the interviewee's knowledge of string immutability. Do something like.

Code:
string x = "fred flintstone";
string y = x;
x += " barney";
Console.WriteLine(y);

True story: If someone tried to sell me on string immutability having anything to do with this, I would chalk it up as still not understanding variable assignment, albeit somewhat less offensive than some other examples.
 
True story: If someone tried to sell me on string immutability having anything to do with this, I would chalk it up as still not understanding variable assignment, albeit somewhat less offensive than some other examples.

Well, the issue is, in C++, the "+=" is an append operation. For C#, it creates a new string object with the text " barney" at the end. I like that one because it tells me whether or not the programmer can realize if they're adding unneeded garbage to the heap.
 
Well, the issue is, in C++, the "+=" is an append operation. For C#, it creates a new string object with the text " barney" at the end. I like that one because it tells me whether or not the programmer can realize if they're adding unneeded garbage to the heap.

Interesting about C++. If someone wanted to talk to me about string immutability in .NET, I would instead simply focus on actual methods the string object has, and how those return new strings and do not modify the existing one. Operations such as .Remove, .Insert, etc. People do use those and think they're modifying the string in place, and of course they are mistaken.
 
So I am now seriously intrigued... how much does a senior programmer earns? I have 6 years of experience in .NET mostly.

A senior programmer and someone with 6 years of experience are not necessarily the same thing. Some people gain experience in dog years... 1 year is worth somebody else's 7. Some people (the people we're interviewing!) apparently do not age at all.

As for myself, I have 4 years of professional, dedicated programming experience (although I used programming in my work before that, it wasn't technically my job). I believe I have a healthy understanding of both my strengths and weaknesses, I'm well aware of areas I need to improve. Others, sadly, seem to adequately prove the negative end of the Dunning-Kruger effect.
 
"Can you write your own name on the whiteboard? Good. You're hired."
Your interviews are starting to sound like SNL's Celebrity Jeopardy.

tumblr_lbbtto1rx71qaevcvo1_500.png



EDIT:
long id = Convert.ToInt64(null);
AHAHAHAHAHAHA
 
I feel like an old man reading this. I'm in IT, been doing it for just over 10 years but I'm a mainframe programmer, well I deal more with data transmissions now but I still do some. Had some C in college and did some VB for awhile(self taught) when I first started out of school. I looked it up and there is a canned command for this Cobol, I've never used it.

Some of the issues you all are running into especially with us more experienced folks is that we aren't allowed to code anymore. If you popped a question on me like that I'd be rusty. Yeah I'm serious, except for production down situations I may only actually physically code like four times a year. This week I'll have to figure out how to bind DB2 programs, been a year since I've done that.

Basically it is too 'expensive' for me to code. They would rather have me go to meetings with the business and bring them back to reality on what they want to do. If a project goes forward then write out the specs at a high level(sort of) and send it to India. It sucks I miss the work and as evident from this thread I'm rusty as fuck or in the case of a lot of this languages .NET, Java etc, I can't do anything at all. Also the code coming back from India or even written by our onshore staff is basically shit.
 
Interesting about C++. If someone wanted to talk to me about string immutability in .NET, I would instead simply focus on actual methods the string object has, and how those return new strings and do not modify the existing one. Operations such as .Remove, .Insert, etc. People do use those and think they're modifying the string in place, and of course they are mistaken.

However, to create an example in C++ where another variable is updated by a change in a string, it'd be like

Code:
std::string x = "fred flinstone";
std::string *y = &x;
x += " barney";
cout << (*y) << endl;

However, pointers and reference markers are explicitly shown in this code. With C# and other managed languages, details behind the references are hidden from sight and require understanding of how the VM manages things, how operations are performed, how strings are stored (literals are pooled), etc.

Some of the issues you all are running into especially with us more experienced folks is that we aren't allowed to code anymore. If you popped a question on me like that I'd be rusty. Yeah I'm serious, except for production down situations I may only actually physically code like four times a year. This week I'll have to figure out how to bind DB2 programs, been a year since I've done that.

DB2 programs? I'm guessing you're working with an iSeries/System i ? (though I guess it could be an AIX or Linux server)
 
However, to create an example in C++ where another variable is updated by a change in a string, it'd be like

Code:
std::string x = "fred flinstone";
std::string *y = &x;
x += " barney";
cout << (*y) << endl;

However, pointers and reference markers are explicitly shown in this code. With C# and other managed languages, details behind the references are hidden from sight and require understanding of how the VM manages things, how operations are performed, how strings are stored (literals are pooled), etc.

Well, sure, if I had an actual pointer (which you can do in C#, just go into unsafe code) versus a variable that simply happens to contain (for however long) the same reference that another variable contains, that's something else entirely. In C#, .NET, it's simply a matter of "I have a piece of paper, it has the address to my house. I'm going to write that address on your piece of paper. Now we both know the address to my house. The house is the object, our pieces of paper just contain its address. Good? Good. Now I'm going to erase my piece of paper and scribble another address on it. Do you still know how to get to my house? Of course you do, you still have its address on your piece of paper. (Now kindly give me back the paper, I don't want you at my house, you sick freak.)"
 
Well, sure, if I had an actual pointer versus a variable that simply happens to contain (for however long) the same reference that another variable contains, that's something else entirely. In C#, .NET, it's simply a matter of "I have a piece of paper, it has the address to my house. I'm going to write that address on your piece of paper. Now we both know the address to my house. The house is the object, our pieces of paper just contain its address. Good? Good. Now I'm going to erase my piece of paper and scribble another address on it. Do you still know how to get to my house? Of course you do, you still have its address on your piece of paper. (Now kindly give me back the paper, I don't want you at my house, you sick freak.)"

Interesting analogy. The sad reality is most people don't comprehend that going by the skill of most of my classmates back in college.
 
Interesting analogy. The sad reality is most people don't comprehend that going by the skill of most of my classmates back in college.

I can't lay claim to it, it's paraphrased based upon something Eric Lippert (C# compiler team) often has to write on StackOverflow as he's explaining classes and objects and references and copy-by-value semantics to other confused developers.
 
Status
Not open for further replies.
Top Bottom