It is currently Thu Dec 14, 2017 9:45 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Nov 23, 2014 7:50 am 
Offline

Joined: Thu Aug 12, 2010 3:43 am
Posts: 1589
Continuing a discussion about graphics for a fizzbuzz game that went off the rails

Your idea would screw over companies if they truly end up with a shitty programmer who can't do anything right for that reason.

Although yeah, I doubt most programmers would fail to do fizzbuzz, at least those who would be confident enough to apply for a programming job. Only explanation I could see for this being true is if most of the people applying actually are not programmers (and so it could be used to weed them out quickly).


Top
 Profile  
 
PostPosted: Sun Nov 23, 2014 8:32 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7314
Location: Chexbres, VD, Switzerland
Quote:
Your idea would screw over companies if they truly end up with a shitty programmer who can't do anything right for that reason.

I never meant to force companies to hire the less competent applicant, but if they have a bunch of applicants they should be forced to hire the one they think is the best instead of bitching about all of them to be a bunch of incompetents and crying about the lack workforce while in the meantime a lot of people are jobless.

Namely, if the quality of applicants follow a gaussian curve, they should also pick someone who is close to the peak of the gaussian if they cannot find anything better, instead of refusing anyone who is not in the top part of the gaussian (which is rare).

Sure in some cases they could be very unlucky and get only applicant from the bottom part of the gaussian and be forced to hire one of them - but in equally frequent cases they will get someone from the top of the gaussian available, compensating for it. (If something terribly wrong still happens with incompetent people, firing is always an option - but at least the unemployees would have been given a chance).

As for the problem, I think no matter how simple it is :
1) Being lost in the syntax of a programming language you didn't use for more than 4 months
2) A very strict time limit
3) The stress of an interview situation

Can lead any very competent person with a lot of skills and experience to fail the test. That person out of 200 that will pass the test simply means that he has used a particular language more recently than another person, that he doesn't panic with time limits and that he can bear the stress of an interview situation. That does not mean he will program better nor that he will wear the stress of a deadline (long term time limit) better than anyone else.

A 2-month deadline for a big project or a 3-minute time limit for a simple test are two completely different form on stresses, and thinking one would scale with the other is silly.


Top
 Profile  
 
PostPosted: Sun Nov 23, 2014 9:18 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19346
Location: NE Indiana, USA (NTSC)
First the not-graphics part of my post, so we have something to split off if needed:

Sik wrote:
Only explanation I could see for this being true is if most of the people applying actually are not programmers (and so it could be used to weed them out quickly).

Bingo.

Bregalad wrote:
but if they have a bunch of applicants they should be forced to hire the one they think is the best

I think they do. It's just that they might get 200 applicants for each position, and they can't afford the time==money to weed out all the non-programmers who apply for a programming job without tests like fizzbuzz. And even if it's not fully correct at the time limit, going in the right direction is at least one good signal for the interviewer.

Bregalad wrote:
Being lost in the syntax of a programming language you didn't use for more than 4 months

A competent company will list the languages used in the job posting, and applicants ought to download a free implementation of the language to use on their own computers to bring themselves up to speed. For example, someone applying for a job that uses PHP, MySQL, and a website maintenance system (sometimes called a CMS) ought to download and install XAMPP and the CMS's free edition, play with it, extend it, etc.


Top
 Profile  
 
PostPosted: Sun Nov 23, 2014 8:14 pm 
Offline

Joined: Wed Apr 06, 2005 5:36 am
Posts: 67
Location: Massachusetts
Bregalad wrote:
I'm sorry but I can't belive a second that any of that is true. I'd like to hear the version of people who "failed" the test to know the truth behind this.

As somebody who occasionally interviews people for programmer jobs, I believe it. And it's not for the reasons you listed. Weirdly, I always tell people "just write some pseudo-code, don't worry about syntax," and most people get hung up on syntax.

Bregalad wrote:
As for complaining that people don't know how to use recursion

I often ask people to write a depth first search using recursion and without using recursion, and applicants have a much harder time with the non-recursive one.

_________________
-Tom


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 10:54 am 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
I had to actually look up the definition of a recursion solution/algorithm. I don't think I've ever used it. I code in C and Assembly currently, and just looking at how recursion is implemented as a function calling itself, makes me cringe. The idea itself is fine (as a higher level concept), but it's the execution that makes me cringe; either using a processor stack or a software stack, it's the possibility of stack overflow is why I wouldn't use it. I mean, considering there are safer (and probably faster) alternatives.

In that thread linking back to the original discussion about fizzbuzz, someone else posted that they had used another question in the interviewing process (asked along side fizzbuzz): How can you swap the value two variables without using a temp variable. I thought the question was ludicrous. Not only is it bad practice, and some solutions would fail on some compilers, but if you can't spare a single temp variable then something is seriously wrong with your design/project/scope. This isn't 1980 anymore, and we've moved beyond using sadistic old PIC style chips (I hope). Of course, the question was asked in relation to a higher language, and not Assembly (which is a no brainer). My answer to the interviewer would immediately be: why would you even do this!?

I'm currently going to school for my CS degree, and I found that article fascinating (or rather the comments). I already expected the ego of programmers to be through the roof (as it is in the IT field), but that thread just convinced me further. As smart as most programmers are, I actually see why we need management. A good leader/manager/supervisor is worth more than any extremely skilled programmer IMO, sadly.

_________________
__________________________
http://pcedev.wordpress.com


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 11:14 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19346
Location: NE Indiana, USA (NTSC)
Recursion is fine with algorithms that use sublinear space, such as merge sort, quicksort on unsorted data, or an introspective quicksort that falls back to Shell sort or heapsort when it detects a bad case. All of these have O(log n) depth, which means sorting a list of length 1000 might produce a stack 10 or so calls deep.

Tail recursion is likewise fine if your compiler automatically optimizes tail calls into jumps (JSR aaaa RTS -> JMP aaaa). In fact, Scheme builds its loop construction out of tail calls.

In Python, you swap two variables using tuple assignment: a, b = b, a. The "XOR trick" someone's thinking of probably leads to all sorts of scary undefined behavior in C or C++ if used on pointers. As for "sadistic old PIC style chips", what do you think the 6502 in the NES is? Sometimes you need to use an XOR trick to select bits from two different variables.


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 12:47 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7314
Location: Chexbres, VD, Switzerland
Actually not only swapping two variables without using temp is a sign of bad coding practice, but actually having to swap two variables in the 1st place is a sign of bad coding practice, in my honnest opinion.

Quote:
Only explanation I could see for this being true is if most of the people applying actually are not programmers (and so it could be used to weed them out quickly).

He said :
Quote:
A surprisingly large fraction of applicants, even those with masters' degrees and PhDs in computer science, fail during interviews when asked to carry out basic programming tasks.

So those people were qualified to take the test, and not some random unemployed people from other sectors trying to apply there because they have time to waste.

In the case of people of the latter category applies, it's very easy to omit them by seeing their resume, there's no need to interview them.

Also, anyone who use modulos to solve the problem are not doing it in a smart way :wink:

Quote:
As somebody who occasionally interviews people for programmer jobs, I believe it. And it's not for the reasons you listed

So please explain me the reason, then ?

Quote:
The idea itself is fine (as a higher level concept), but it's the execution that makes me cringe

Sure, but 95% of programmers won't care. They will just use the solution they find is the more elegant and sexy in the language they use, no matter how it is done after compilation or interpretation.


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 1:00 pm 
Offline

Joined: Thu Aug 12, 2010 3:43 am
Posts: 1589
Bregalad wrote:
Actually not only swapping two variables without using temp is a sign of bad coding practice, but actually having to swap two variables in the 1st place is a sign of bad coding practice, in my honnest opinion.


Not really, there are several algorithms that rely on swapping (sorting comes to mind). Also it can make some things simpler. Let's say you're making a routine that draws a shape, and you want to be able to take any set of coordinates to make things easier for the user (e.g. going either left or right, and/or either up or down). The easiest way to allow this is to check if the coordinates are swapped, and if so swap them again inside the function (ensuring they always go in the same direction), which can allow then using a simpler algorithm later on.

Bregalad wrote:
Sure, but 95% of programmers won't care. They will just use the solution they find is the more elegant and sexy in the language they use, no matter how it is done after compilation or interpretation.

Honestly I barely ever use recursion, since most of the time it doesn't even make sense (nor it's really that intuitive often, really, especially if it's just a replacement for loops). The fact most of the time it's taught in a way that makes it look nifty but with examples that rarely reflect the kind of stuff that is normally programmed in practice should be telling something, too. (seriously, how many people will need to write a function to compute factorials or fibonacci sequences? not to mention that the former is extremely trivial as a loop, and the latter could be done with a loop too without a stack if you try)


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 1:06 pm 
Offline

Joined: Wed Apr 06, 2005 5:36 am
Posts: 67
Location: Massachusetts
Bregalad wrote:
Tom wrote:
As somebody who occasionally interviews people for programmer jobs, I believe it. And it's not for the reasons you listed

So please explain me the reason, then ?

I have no explanation; it really makes no sense. But it has happened to me several times that I'm interviewing someone who seems pretty qualified, and they're answering my questions pretty well. Then I give them a simple programming task, something that should take a couple minutes and we'll use that as the starting part for a more complicated question. And then they completely fail the simple task and I'm utterly confused. And it's not just syntax or making simple errors; I cut people some slack because I know people are nervous during interviews. They just have no idea where to even begin on the problem.

_________________
-Tom


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 1:11 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7314
Location: Chexbres, VD, Switzerland
Quote:
Honestly I barely ever use recursion, since most of the time it doesn't even make sens

I 100% agree with you. However, there is (other) people who like using recursion and think it's sexier than loops. That's where functional programming comes from.

Computing Fibonacci as a recursion instead of a loop will move the complexity from O(n) to O(2^n) because you'll be doing the same computations many times. Therefore it's an *awful* example about how to make a recursion.

Quote:
Not really, there are several algorithms that rely on swapping (sorting comes to mind).

In the real world (I mean, outside the typical programming exercies) swapping pointers, or "keys", instead of elements, is usually what is done.
Actually most of what is done in typical programming exercises, like sorting a list of numbers or printing a Fibonacci list, has no as-it applications in real world but have it's indirect applications, making the knowledge useful.

Quote:
They just have no idea where to even begin on the problem.

Pehaps they just think the question is a trap (because it's so easy it's fishy) and are trying to foresee it, ending up failing miserably at the original question ?


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 1:16 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3968
Bregalad wrote:
Actually not only swapping two variables without using temp is a sign of bad coding practice, but actually having to swap two variables in the 1st place is a sign of bad coding practice, in my honnest opinion.

Swapping local variables might be bad, but not variables stored inside of structs (which won't live in registers).

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 1:22 pm 
Offline

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
tepples wrote:
As for "sadistic old PIC style chips", what do you think the 6502 in the NES is? Sometimes you need to use an XOR trick to select bits from two different variables.

Old PIC design != 6502. Not by a long shot. I'm getting a sense of deja vu in this reply (6502 and PIC being compared). I've coded for the 16x series, and looked at others related in the series, and they are nothing like the 6502. Not only are they severely limited (IIRC a 3 word hardware stack, 40 something bytes of ram per page, etc), but their design is convoluted to hell and back - making even simple techniques of general purpose processors, complex and just a pain on the PIC. Coding the PIC in ASM was challenging and fun, but 6502 is advance space age technology from the future, by comparison. Granted, I'm talking about the old PIC chips; the newer models are less convoluted (IIRC the 18x series looked decent).

Quote:
Sure, but 95% of programmers won't care. They will just use the solution they find is the more elegant and sexy in the language they use, no matter how it is done after compilation or interpretation.

I have no doubt. Seeing how it was implemented by examples (that I saw on the net), if I wrote such a routine that someone else might use or call at some point later in development with a different set of requirements - that's a potential problem if they don't adhere to caution or understand the limit/scope of the function. The risk isn't worth the trade off for some stylized or compact looking source code, or whatever. Then again, I probably write higher level code in some form or fashion that's at similar risk without even knowing it ;>_>

_________________
__________________________
http://pcedev.wordpress.com


Top
 Profile  
 
 Post subject: Premature optimizations
PostPosted: Mon Nov 24, 2014 1:30 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19346
Location: NE Indiana, USA (NTSC)
Modulo to solve fizzbuzz is just fine on anything with a reasonably efficient divide instruction, just not on something like 6502 or 65816. The other solution keeps a separate state variable for each factor (3 or 5) that gets incremented for each number and then zeroed when it reaches the factor. But optimization without profiling first is itself a bad practice.

Anything you do with a loop can be done with tail recursion, including O(n) computation of Fibonacci, by putting the loop's variables as argument to a function that calls itself. By definition:
fib(0) = 0
fib(1) = 1
fib(n) = fib(n - 1) + fib(n - 2)

In tail call style, it looks like this:
fibmore(0, fn, fnm1) = fnm1
fibmore(nleft, fn, fnm1) = fibmore(nleft - 1, fnm1 + fn, fn)
fib(n) = fibmore(n, 1, 0)

This is inefficient in, say, CPython but fine in languages that don't add tail calls to the stack.


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 2:04 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
As someone who does not do programming as part of his career -- I'm a UNIX SA, and thus am what I call a "practical programmer" -- here's my take on it (because I get asked programming questions pretty much any time I interview at a place of work):

When it comes to interviewing candidates, ask them real-world questions, i.e. practical things, not hypothetical.

Give the candidate a scenario that has actually happened in the past, such as a case where someone not understanding operator precedence resulted in ill-effects, or where bad design choices turned out to be catastrophic later on (i.e. a "programming scalability" question). Don't probe them about silly things that really have nothing to do with the job. A lot of the places I've interviewed at (including where I work at now!) tend to pose hypothetical or theoretical problems, not actual problems that are relevant to the group/division or role the individual is applying for.

For example, at my current workplace, here's one of the problems candidates are asked to solve. When I found out we were using this as an interview question (it's not a question my group asks), I took it upon myself to try to solve it. I asked myself "Could I even do this?" because I really didn't think I could. It took me an entire day to write, with all sorts of edge cases not handled (and this is intentional on the part of the challenge, believe it or not -- for example the lack of an ABNF that defines what the term "word" meant posed serious problems for me).

After I submitted my results, I asked the guy who wrote that scenario the following: "is this something that we actually had to solve here at work?" The answer was "No. It's just to determine the candidate's familiarity with programming and problem-solving". So to me, it was a highly-glorified fizzbuzz test, and generally-speaking I don't think that's a worthwhile test. Well, it is and it isn't I guess -- if you aren't sure if the candidate even knows how to program, maybe asking them something like this is worthwhile, but otherwise I don't think it acts as a good indicator of the quality of work you'd get from the interviewee.

Fizzbuzz is one of those questions you ask someone to see 1) if they have ever done programming at all, and 2) if they have basic math skills (specifically have familiarity with the modulus operator). Fizzbuzz otherwise is kinda pointless; for example, in my entire life and career, I've only had to use modulus a few times. But that's based on my background and what I do, and as I said above I'm not a professional programmer.

Funnily enough, the only time I've ever been asked a fairly low-level programming question was when I was interviewing for a UNIX SA position at an ISP -- I had two Russian guys grilling me about assembly language after reviewing my resume. One of them asked "So if you know all this, then tell me fastest way to swap two registers without temp variable", to which I replied immediately "XOR?". The other Russian started laughing at his colleague, since apparently nobody had ever gotten that question right (and they'd worked at previous jobs together), followed by a really big smile. Did I ever do any assembly programming at that job? Not a single line.


Top
 Profile  
 
PostPosted: Mon Nov 24, 2014 6:52 pm 
Offline

Joined: Wed Apr 06, 2005 5:36 am
Posts: 67
Location: Massachusetts
Bregalad wrote:
Quote:
They just have no idea where to even begin on the problem.

Pehaps they just think the question is a trap (because it's so easy it's fishy) and are trying to foresee it, ending up failing miserably at the original question ?

I don't think so. When people are struggling, I start giving them help, sometimes to the point where I just show them a solution. And none of them said "oh that's all? I thought it had to be more complicated than that."

_________________
-Tom


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group