News for hackers. Stuff that matters.
Re:Three hundred programming interviews in thirty days by tomtang0514 on Tuesday June 23, 2015 @07:49PM (#9768598)
Regardless of the compiler, let's say (x << 3) is slightly more efficient than (x * 8), I don't see it make such difference since my job will probably be writing code for webapp sort of things. For the things I do I actually believe readability advantage of (x * 8) overcomes the efficiency disadvantage (which doesn't even exist with modern compiler).

Some interviewers (not just the "homework") raise their bar by not allowing you to make any tiny mistake. And I just don't get it. If someone is good enough to write something like a lite version of Hacker New website in hours, I'm not going to turn him/her down because of such mistake.

Re:Three hundred programming interviews in thirty days by hobs on Tuesday June 23, 2015 @09:38PM (#9769060)
And the person who could potentially write the "most perfect" code with all of the conditions applied is often not within that company's price range.

I did interviews at a company for about 2 years and there was constant pressure from management to do trivial crap like that, it finally came to a head and I invited management and one of the "rockstars" to do a mock interview.

When it was evident that the person they thought of as a "rockstar" could not solve these tests(without prior knowledge of the problems), they immediately discounted them as a worthless and stopped bugging me (about that, of course not about everything else).

Re:Three hundred programming interviews in thirty days by developer1 on Wednesday June 24, 2015 @01:49AM (#9769877)
What the hell. A developer who writes x << 3 instead of x * 8 when writing code that is logically doing multiplication is not a good developer. Written code is designed for human readability; the human should not be having to convert that mentally to its math equivalent to understand what operations are taking place. In nearly every possible case, this is at best a micro-optimization. At worst, a symptom of someone who writes unnecessarily obfuscated code to show off their knowledge in a manner that only hurts the maintainability of code by a team.

If I found bit shifting in an interview code sample as a replacement for basic multiplication, I would ask the developer why they chose to do it that way. They'll either a) calmly explain that their computer science classes taught it that way or it's a habit they've adopted after writing code for embedded systems or similar where the optimization actually made a difference, or b) their ego will make an appearance with a "because I'm so senior" attitude. The latter is not a good sign.

Re:Three hundred programming interviews in thirty days by achiang on Wednesday June 24, 2015 @12:08PM (#9772544)
Or it's idiomatic for that language.
Re:Three hundred programming interviews in thirty days by jsprogrammer on Tuesday June 23, 2015 @10:26PM (#9769203)
Sometimes x << 3 is more readable than x * 8. It depends on why you are doing the shift/multiply.