@Lundin in the real world we don't usually write sorting algorhithms either, but we still study them because the value is in learning to reason about stuff, not necessarily in the real world applications. Also, in the real world where real comptuers exist but without optimizations enabled that code does run approximately
2*n
times.