Re:In defense of coding interviews
by pkolaczk on Sunday May 29, 2022 @02:01AM
(#31546810)
This is untrue in languages with proper optimizing compilers, designed for performance, e.g. C++, Rust, Zig. A functional iterator transformation chain is often just the same performance as a "traditional" for loop.
But try that in Java and you'll often see a 3x-10x difference, especially if you run into problems with boxing. Streams are known to be notoriously slower than for loops with index. I once have even doubled the speed of a for loop by unrolling it manually (Java 8). Not all compilers are equally strong at optimization.
Anyway, asking such questions in an interview for a junior/regular developer is just a distraction.
Re:In defense of coding interviews
by Dayshine on Sunday May 29, 2022 @06:45AM
(#31548089)
Even in java/c#: what kind of application has its performance dominated by a control structure? If you're doing so little work inside the loop then you should probably look at using fancy cpu instructions like SIMD
But try that in Java and you'll often see a 3x-10x difference, especially if you run into problems with boxing. Streams are known to be notoriously slower than for loops with index. I once have even doubled the speed of a for loop by unrolling it manually (Java 8). Not all compilers are equally strong at optimization.
Anyway, asking such questions in an interview for a junior/regular developer is just a distraction.