2 ms·
> If "faster than C" means "I can make a Zig program such that no equivalent C program is faster", then that's obviously false. It could be true though, becaus
by littlestymaar 4y ago
> If "faster than C" means "I can make a Zig program such that no equivalent C program is faster", then that's obviously false.
It could be true though, because compilers aren't perfect, and for instance it actually happens with scientific code written in Fortran: C has restrict but because it's not widely used, C compilers don't make use of it as much as they could for optimization, which means that a language like Fortran that values the non-aliasing guarantee can have a compiler which optimizes it more than what C compilers do.
That being said, there's nothing preventing C compilers to add the same level of aliasing-based optimizations in theory, it's just that they don't do it yet in practice (Rust is pushing the boundaries on that for LLVM though, because noalias optimizations is regarded as a promising performance enhancement for Rust).