Live data from Hacker News

Interviewing programmers: Analysis taster (work in progress)

solipsys.co.uk

31–34 of 34 posts

Re: Interviewing programmers: Analysis taster (work in progress)

#32

I'm quite familiar with C, but I don't see the difference between the while and for loops in the trivia box on article 2 of the series. I would expect the while loop to compile something like this: while(condition) { // stuff i++; } becomes loop: if(!condition) goto end; // stuff i++; goto loop; end: I would expect the for loop to do this: for(;condition;i++) { // stuff } becomes loop: if(!condition) goto end; // stu…

Consider the effect of a "continue" statement in the "stuff" section.

Ah, thanks. It makes perfect sense now.

Re: Interviewing programmers: Analysis taster (work in progress)

#33
post #27

I'd be interested in an analysis of the compiled assembly for those 5 versions in 2b. A quick test on my end shows them all to be extremely similar. I know little assembly, and am not going to attempt to pick it apart, so I can't attest to any speed difference. But as an example the first and the last compile to the same, though the last has 2 fewer instructions and some -16s changed to -24s. The first is identical t…

Indeed - these are issues that I will be discussing, and would discuss with a candidate once I had their code in hand. I say in 2b: Each of these changes is unnecessary and in some cases damage readability. Further, a good compiler will get most, if not all, of the efficiency for you without making these changes. If changes damage readability and don't change the compiled code, don't make them! Readability has to be…

I'll definitely follow along, it's been interesting. And I'd probably come up with something like the last one after a little thought, because it's pretty idiomatic of string copying.

I just tend to seriously dislike code refactoring instead of algorithm refactoring, and anything that advocates it. Typically, the compiler is far better than the coder, especially when you turn on optimizations, but the compiler (nearly) can't swap out your code for a better algorithmic approach. Thus, you'd be much better off with expansive, seemingly inefficient code from a smart programmer who knows the be(st|tter) algorithm(s).

Re: Interviewing programmers: Analysis taster (work in progress)

#34

Earlier quoted context omitted.

It wasn't intended for that purpose, but stand by ... EDIT: OK, I've uploaded a larger version where the labels are readable, but I've had to change the layout so the nodes don't overlap. The lengths of the edges are now not always realted to the distance, although it's approximate. http://www.solipsys.co.uk/Writings/x.dot.png Note: Yours might still not be on it, as yours might be one of the outliers. You can email…

What proportion of the entries are on the graph?

Sorry, missed your question. About 75%.
Post reply on HN