- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
void main() { deque<int> a; deque<int> b; bool remove_duplicates; // populate arrays copy(b.begin(), b.end(), a.end()); sort(a.begin(), a.end()); if (remove_duplicates) { deque<int>::iterator new_end = unique(a.begin(), a.end()); a.resize(distance(a.begin(), new_end)); } // profit? }
Admin
I haven't coded in a while, let's see how I do in Perl.
Perl array merge
@combined = @first_array + @second_array;
Gosh that was hard.
Let's try a Perl fizzbuzz. Let's use Map just to be a pain.
@integers = (1..100); map {&carbonate($_)} @integers;
print @integers;
sub carbonate{ $n = $_ if ($n %3*5 == 0) {$n = 'FizzBuzz';} elsif ($n %5 == 0) {$n = 'Buzz';} elsif ($n %3 == 0) {$n = 'Fizz';} return $n; }
Am I hired for succeeding, fired for using Perl, or mocked for some obvious failure in the above?
Admin
Hmm, I just read the cited Atwood article. Maybe I'm missing something here, but if I'm reading this correctly, they gave the students this pre-test without first explaining how assignment in C-like languages works, and then graded students on their ability to guess correctly. This seems really, really pointless to me.
Now if what he means is that they explained it, and then gave the quiz, and some students couldn't grasp the idea, okay, that's a different story.
Admin
One particular job where you are definitely never asked to perform a task for free is if have a qualification in mathematics. You frequently get asked to help with the kiddies' homework - but guess what, they're prepared to pay you big bux for the privilege.
Admin
Yes, you are missing something. The article claims there are 3 groups of students. The first one are the students that could make up a consistent model of what those symbols meant. It doesn't matter if they get it right or wrong, just if they can imagine any way in which the questions/answers made sense, and used that to answer.
This means it doesn't matter if they used "Let a = b" or "a := b" or "a <- b" or whatever. The model students could form may very well change, but the fact that they used one would not.
Admin
Sorry, AC, the students didn't get to pick their operators. They are already there on the test.
And also, there was no option (as far as I can tell) for those who consistently refused to continue after reading the third line, assuming it to be an error and thus reflective on the whole test.
Admin
I can't believe he bluffed his way through the initial interview process. You need to get past the buzzwords, unless the people interviewing are equally oblivious. I've interviewed people, and I've been interviewed. When the person gets into the intimates of C++, and can't give me a good explaination of what I'll be doing, I know I'll be cleaning up the WTF's of someone who did good at the coding test, but spent their time finding exciting code solutions to boring problems. Much rather have someone who can look at a problem, and break it down logically. Often, the code written reflects the structure of the problem in real life. I freely admit I try very hard to write boring code.
Admin
That would be the third group:
Admin
I'm surprised that there aren't a bunch of comments saying that Avi is an idiot, and that Fred is smart in googling for code rather than trying to write his own.
I don't know how many times I've heard people say that it's ALWAYS better to search the web for code to solve a problem rather than trying to write it yourself, because "why re-invent the wheel?"
Which analogy always baffles me, because in real life, manufacturers re-invent the wheel in this sense every day, and for very good reasons. It's not like there's one factory in the world that makes exactly one kind of wheel and everybody buys and uses those wheels.
There are many good reasons to make your own wheels rather than buy from someone else.
Most obviously, your requirements may be different. A wheel that works well on a child's tricycle may not be ideal for a thousand-ton earth-moving vehicle. For that matter, a wheel that works well on a passenger car may not be the best for a pick-up truck or a race car.
Even if someone else's wheels would work on your vehicle, it may still be more economical to make your own. You eliminate the other guy's markup, shipping costs, etc. You are not vulnerable to disruptions in his operations -- like if your supplier's employees go on strike, you have no control over the situation, but must wait for them to resolve it while your assembly line grinds to a halt.
Getting back to the case at hand: Software downloaded from the web is not really "free". Whether we're talking about a complete software package or some small code snippet, the same considerations apply. You may not have to pay the people who wrote it, but it takes time to search the web to find an applicable product or code sample. Then you have to learn how to install, configure, and run it. Then you have to figure out if it really meets your requirements. The more complex the problem is, the less likely that someone else's software EXACTLY meets your requirements, so you have to decide if it is close enough. If the software turns out to have bugs, you have to rely on someone else to fix it. Even if you have the source code, you have to figure out somebody else's code. You may need to integrate it into other code that you have. If software that you found turns out to not be suitable, you have to begin the process all over again.
I've had a number of times when I was searching for a software product to meet some requirement and I had to review several available products before finding one that was suitable. This process often took days or weeks. For complete, complex software packages, it sometimes took months.
If the requirement is both very general and very complex, the effort of finding software written by someone else can be well worth it. I would be very, very unlike to write my own database management system to support one application. There are plenty of good DBMSs out there that I could get for far less than the cost of developing my own.
But at the other extreme, I once got into a strange argument on Stackoverflow where someone posted a question asking if Java had a built-in function to concatenate an array of Strings with some delimiter between them. Like, turn the array ["x", "y", "z"] into the string "x,y,z". I replied that I wasn't aware of one but gave him a ten-line function that would do it. I got a bunch of comments saying that I was an idiot to try to write such a function myself, that the smart thing to do would be to search the web for a library that provides such functions. The phrase "re-inventing the wheel" was used several times. Why is that a good idea? I doubt it took me ten minutes to write the function and, while I didn't test it, I could surely have debugged such a simple function in, what, half an hour? Surely it would take me longer than that to do a Google search for a similar function written by someone else, download it, figure out how to use it, and integrate it into my code. And there'd be no guarantee that it wouldn't have bugs.
In manufacturing, it's called "make or buy". The right answer is NOT always "buy".
Admin
First, in the context of using such a question in a hiring decision, how many people (1) are good programmers and (2) would not understand the code snippet because they've never worked in any language (C, C++, Java, Python, Javascript, Ruby, Basic, etc. etc. etc.) that uses = in that way?
It is theoretically possible that a competent programmer could have come along and only used (1) imperative languages like Pascal and TI-BASIC (literally the only two I can think of off the top of my head that use something other than = for assignment), (2) other programming paradigms that don't really have assignment (like ML, Prolog, or Factor). But really, what are the chances, especially in this day in age? And even if you find a competent programmer who that applies to, what's the chance that they'll be really good or great, and never have been exposed to = for assignment?
Remember that, at least many places, the goal of hiring is as much to prevent bad people from being hired as to find great people.
The second objection is to the study in context. In context, they did it during a course that was explicitly teaching about the material. What they say in the paper* is "So we planned to administer a test just after the students had begun to be taught about assignment and sequence, at the very beginning of their course, then a second time to the same subjects after the topic had been taught, and then a third time just before the examination." My take away from that is that, in other words, those students which received that treatment almost certainly had already seen the notation = for assignment. (Another group was administered the test before seeing any programming instruction, and the authors believe without prior programming experience.)
Another observation in support of the study is that the authors were less interested in correctness as they were in consistency. If a student guessed wrong on how things worked but appeared to make a similar mistake on all of the questions, they were marked as "consistent" instead of "inconsistent". (For instance, TI-BASIC writes something like "y -> x" for "x := y". If people always interpreted "x = y" backwards, then they were marked consistent. Disclaimer: I'm not sure how this interacts with questions involving statements like "x = 3" where one of the directions is nonsensical.) Final course scores vs consistency on their study test was what the paper was investigating, not final scores vs correctness on their study test.
On one hand it's not that the study is terribly convincing, for a variety of reasons. (For starters, doing a decent study to answer the questions they were trying to answer is extremely difficult.) On the other hand, like a lot of journalism related to scientific studies, you're responding to a somewhat poor statement of what the study analyzed rather than the study itself.
Admin
Suppose a student said after
that a = 20 and b = 0, if that student then said after that a = 30 and b = 0, that student would be consistent, even though that is not actually what the code does. If instead he said a = 60 and b = 30, then he would be considered inconsistentAdmin
Many issues with this code:
Nothing is pulling information from the cloud (or at least from a RESTful web service) so that can't possibly be right
Does not appear to be serializable and can therefore not be used in a properly scalable architecture
None of the references include anything that seems related to JSON or jQuery, making this code unusable IRL
Admin
Admin
Hmm, again, just going on what I read in the Atwood article, I don't think that they said that they asked students to invent a notation, but rather that they gave them questions using an existing notation and asked them to guess what this notation meant.
We're mostly programmers here, so we're already way ahead of these students. Suppose you took a class in some new programming language you had never seen before. And on the first day, you're given a pretest with questions like:
What is the result after this code sample?
17 ; x 4 ; y x () y
(a) x is 4 and y is 17 (b) x is 21 and y is 4 (c) x is 0 and y is pi-squared
I think such a question is just as fair as what it sounds like these students were given.
Given that most students are entering the class presumably "knowing" that the equal sign means something very different from the meaning that C gives it, you are not only asking them to guess the meaning, but to guess a meaning that to many will contradict what they already know.
Like in my example above, I had in mind that the semi-colon is an assignment operator where the value precedes the variable name, and "()" means the same as C "+=", so the right answer is (b). If you think that's bizarre and ridiculous to expect someone to figure out, is it any more bizarre than expecting someone who was taught that "=" is a logical operator giving a result of true or false, to guess that here it indicates assignment? Or to guess that "int" is a data type and that putting it before a variable name indicates the type of the variable? Etc.
Yes, maybe if you were given a test with 20 such questions, you could study the choices in the answers, look for patterns, and apply inductive logic to determine what the operators must mean. That is, you might be able to come up with a "consistent theory" of how the operators work.
But wow, that's not an easy problem. Even if you were told the right answer to the first couple of questions, figuring out what the operators mean from the results is not an easy problem. And the students didn't even have that much to go on -- they had a list of possible results for each problem. So they had to piece together, of all the problems and all the possible results for each, if they could come up with a theory that would make exactly one of the possible results for each problem a correct answer. Hmm, I can see this being an amusing logic puzzle, on a par with Sudoku puzzles and problems like "how can you determine which door to open by asking only one true/false question".
Admin
Honestly, the real problem with that test is the lack of critical reasoning. Assuming people who see int a = 10, int b = 20, a = b, and then assume the test itself is wrong are naive. If anything this test can weed out those thinkers who can't readily adapt to change. If only because they assume the test is wrong, and not there perception of what is being asked. If you look at the way the numbers are introduced its pretty clear what is happening.
Without using any programming knowledge and just reading the expressions at their words. A equals 10, B equals 20, A equals B. When it askes what they are all someone has to do is read the last statement at face value. A equals B, its a choice. And its simple. But everyone has preconceived notions of what it should be, thats what this test better predicts. Ones ability to throw out his own biases.
Of course this is assuming the taker assumes the question is valid and has an answer. Even if its not what he might expect. Like a riddle.
Admin
Admin
Admin
First of all, in the declaration lines like int x = 5;, that equality sign pretty much matches up with equality as used in math classes. (Specifically, the "let x = 5" type of equality, or the "defined to be" equality that's sometimes written with, e.g., a triangle over the equals sign.)
That leaves the assignment use of =. But even there, = as assignment is not totally divorced from the definition of = as people are familiar with -- a correct if somewhat unspecific description of the behavior of "x := y" is that it "makes x == y after the line" (using := and == to be specific about what I mean). While I'll admit to preferring := myself, I mean, = was chosen for assignment in the first place for a reason, and it's not just because "well, I need a symbol and = is as good as any." That's a lot different from just inventing some syntax that doesn't have any familiarity at all.
I'll be the first to admit that in some ways the familiarity actually makes things harder, because you have to first overcome those misconceptions. But what would those misconceptions lead to if you played them out?
What would happen if you interpreted those lines more like they were written as "int x = 5; int y = 10; x == y;"? Well, it's basically impossible to imagine every misconception or wrong answer or wrong mental model that students would have. But at least what I'd expect the common result would be if you interpreted the assignment as a comparison would be that you would say that the results are unchanged. Perhaps you would even write a "no it isn't" next to the equality on the test. If you do that consistently, you'd get marked consistent.
Anyway, I vehemently oppose the closing statement of the abstract ("We point out that programming teaching is useless for those who are bound to fail and pointless for those who are certain to succeed"), but the study really isn't bad in comparison to other "we did this on one or two classes" studies.
Admin
Admin
Admin
void main and C++ stl mixture... an uninitialized POD in local scope that could result in either a true or false value at runtime... and the copy line is incorrect and throws a runtime error.. jeez.. if you're going to post code on a site like this, at least try to compile and run it
http://codepad.org/v5O1bExB http://en.cppreference.com/w/cpp/algorithm/copy http://www.boost.org/doc/libs/1_53_0/libs/utility/value_init.htm http://users.aber.ac.uk/auj/voidmain.cgi
UNLESS this is a huge joke and is something you copied and pasted from a stack overflow question... and if so.. you got me
Admin
Um... typed it in, worked first time. Very inefficient: I think I'll have to replace fizzbuzz with something like this...
Stupid, stupid code, glad we are on thedailywtf
Admin
The problem with the interview wasn't that he googled code from the internet to answer a question. I do that all the time myself! The problems were:
As for the URL issue, it wasn't so much that he didn't know what a URL was, it was that he seemed unable to type in a URL that I gave him over the phone. I'd say, "Got to bigboxco.com/ide/H5rt3" and he'd say, "Uh, that didn't work." We tried this 3 or 4 times with different sessions until I just emailed him the URL.
Admin
You need to go DEEPER!
[image]ps. I went to your github, but was attracted to porn.xml... now if you'll excuse me..
Admin
Oops... it's actually named pom.xml. I have lost interest. Must've been the font.
Admin
I think the WTF is that Fred thought he could just paste the code into the collaborative IDE, rather than simply type it out, and think the interviewer wouldn't notice.
CAPTCHA: caecus: Caecus, if he had typed it out, then it wouldn't have all come at once, and the interviewer would be none the wiser.
Admin
Both. They gave it before explaining, as kind of a control. Then they explained the concepts, and gave it again.
Admin
If you thought there was an error, and just refused to keep going, instead of, you know, asking the test administrator what's up, then that's just as bad as not being able to form a consistent mental model.
And AC's point is that it wouldn't matter what symbol the test used. They could have used a lightning bolt symbol, the outcome should have been similar.
Admin
[quote user="jay"][quote user="AC"][quote user="jay"][quote user="tharpa"][quote user="Evan"][quote user="tharpa"]I also don't like Atwood's article at http://www.codinghorror.com/blog/2006/07/separating-programming-sheep-from-non-programming-goats.html. I can imagine a person with programming potential (but who's never seen a line of code before) who's never been taught about assignment, and certainly has never been taught about the perverse way that C-family programmers use the equals sign, who would just see the third line in the code there, would think it was an error and/or that the test givers were morons, and wouldn't be able to get beyond that unless they were given those critical pieces of information.[/quote]To play devil's advocate for a second:
If you're a hiring manager, do you want to hire someone who might have programming potential if you put in a lot of training, or do you want to decline and wait a bit longer until you get an applicant who can actually demonstrate some amount of programming proficiency already?
The first could lead to some high rewards, yes. But it's also really high risk. Do you want to take that chance?[/quote]
If I understand your point correctly, it is that a test to separate potential programmers from non-potential programmers could have some legitimacy. I do not dispute this. My complaint was about using such a test that used the C-language perversion of the equals sign without an explanation. I would have been consistent in my view that it was an error, and none of the answers clearly addressed that possibility. Upon reading some of the comments to that article, there were quite a few other people who made the same point. Had the writers used a different assignment operator, like :=, or used "Let" syntax, it would have been a completely different question.[/quote]
Hmm, I just read the cited Atwood article. Maybe I'm missing something here, but if I'm reading this correctly, they gave the students this pre-test without first explaining how assignment in C-like languages works, and then graded students on their ability to guess correctly. This seems really, really pointless to me.
Now if what he means is that they explained it, and then gave the quiz, and some students couldn't grasp the idea, okay, that's a different story.[/quote]
Yes, you are missing something. The article claims there are 3 groups of students. The first one are the students that could make up a consistent model of what those symbols meant. It doesn't matter if they get it right or wrong, just if they can imagine any way in which the questions/answers made sense, and used that to answer.
This means it doesn't matter if they used "Let a = b" or "a := b" or "a <- b" or whatever. The model students could form may very well change, but the fact that they used one would not.[/quote]
Hmm, again, just going on what I read in the Atwood article, I don't think that they said that they asked students to invent a notation, but rather that they gave them questions using an existing notation and asked them to guess what this notation meant.[quote]
Right. And those that scored well were not those who were simply able to guess the notation correctly, but able to come up with a meaning for the notation (whether that be the actual meaning, or something different), and consistently apply it. That's what they were looking for.
[quote]We're mostly programmers here, so we're already way ahead of these students. Suppose you took a class in some new programming language you had never seen before. And on the first day, you're given a pretest with questions like:
What is the result after this code sample?
17 ; x 4 ; y x () y
(a) x is 4 and y is 17 (b) x is 21 and y is 4 (c) x is 0 and y is pi-squared
I think such a question is just as fair as what it sounds like these students were given.[/quote]
No, it's not. Your code sample is bunk because you're introducing two different operators. The sample in the article has only one. If you were to change your 3rd line to have a semicolon rather than a set of parenthesis, then one could make some kind of inference.
Admin
Looking up solutions to coding problems on a site actively maintained and reviewed by other programmers is such garbage, all programmers should spend hours inventing their own wheels, amirite?
Admin
Admin
There's always room for a better wheel. Determining whether you have the time and money to do such is a thing is an entirely different story.
Admin
Yeah, copying non-compiling broken code out of a question posted to a site maintained and reviewed by other programmers is way better than actually knowing how to program.
Admin
Beat me to it.
Admin
I have an older friend who is very good with buzzwords. If interviewed by managers, he does extremely well (because he sounds like a manager and uses managerspeak) and gets hired. If interviewed by developers, he does very poorly (because he sounds like the idiots in charge of the developers) and rarely gets hired. He's been a contractor for most of the last 3 decades and is now in his upper 50s. His resume is written so that if you search for keywords, his will come very close to the top. So bascially he's hacked the resume screen and the first interview process.
What he also does very well is listen to the keywords, buzzwords and new technologies that recruiters are asking for, and only picks up enough on that tech to get through the interview. So if recruiters start asking for SQL Server Object Smoker, he'll read up on it between the time of the request and the interview.
Admin
the problem with his code: in his code, = stood for assignment, while he used = instead of == in the question of possible answers, too. So it is really ambiguous, it could even be a trick quesion, that all answers are correct, because they assign the value from the answer to the variables in the answer.
Admin
Iteration and recursion are fundamental and you can't write a damned thing without them.
Structured programming is also fundamental and there is no language that does not offer some kind of structure. Yet I constantly see people who just shit out hundred line functions that have no particular purpose.
Types are also fundamental, and yet I see people who make everything into a damned string, and just pass strings around everywhere.
And if you're going to claim expertise in Java (or some other OO language) you are implicitly claiming to be familiar with OOP. So when I see you jamming everything into a utility class and not using objects to bundle type and action, it's clear you lied to me about knowing Java.
It's not that they can't get beyond it, it's that their natural intuition is making it harder for them to code, and it will likely always put them at a disadvantage against people who just naturally accept that the symbols in an artificial language simply mean what they do, without their intuition butting in. If I can think less and achieve the same result, I'm going to get to that result faster, or get a better result in the same time.
I remember I was going door to door canvassing, and I was with one other dude, and we had a map of the houses to visit. This guy could not read a map to save his life: when he was trying to orient himself, he'd start turning around and would turn the map in his hands at the same time. That's an extreme example, but his natural intuition was clearly working against him.
So if that guy wanted to work as a door to door salesman, he would waste more time getting lost than someone who had a good sense of direction, and that would mean he'd get less sales, and thus less commission. So being able to identify that deficiency would help him make a good decision about what line of work to go into.
Admin
Best programmer I know personally: degree in Electrical Engineering.
Best systems analyst I've ever worked with: Ph.D. in Chemistry.
Takes all kinds!
Admin
Admin
Admin
Ever heard of TheDailyWTF.com?
Admin
Admin
SideBet: $10 syas he's one of those people who when told to have a look at someting on youtube (:%s/youtube/<insert other site>/g) goes to google, and enters youtube.com in the search box, then clicks the first search result. It really, really pains me when I (frequently) see (admittedly non-technical) people using the internet this way....I'm afraid tehy're gonna overlaod google.
Admin
You're all idiots.
Admin
Meanwhile, the WTF programmer in this story was the 1%. 99% of cheaters do prosper. The meta-WTF is that the WTFs prosper more than we do. thedailymetawtf == thedailywtf.
Admin
I would think that if a programmer has the technical knowledge to write StackSort, they probably have the technical knowledge to write the required sort in the first place :)
Admin
Admin
Admin
Admin
It's like pointers in C. When you first get to see them, they make no sense at all. The syntax seems contradictory almost because you first declare it a pointer using the asterisk saying: char *fred; and later assign that location a value, using the same asterisk: *fred = 'a'; Then we throw an ampersand in for good measure, and the poor student is so hideaously confused.
However, as you use them, you get used to how they work, and evenutally you realise that their syntaxt is quite lokical, and actually makes a lots of sense....
Or maybe it's nopthinkg the same, I forget what I was talking about.