It seems to me that there are no programming languages for which you generally compare the source code of similar programs and determine which will be faster because the speed of a program heavily depends on the compiler optimizations used.

If a language's standard specified the assembly instructions to produce, then we could compare programs more objectively.

This would of course produce slower programs. Thus, the language ought to support anything that optimizations would be able to do, and "optimizing compilers" would become "optimization suggesting compilers". All optimizations would then be encoded into the source code itself so that the performance does not depend on the compiler used.

Common/important/complex/annoying optimizations could be required by the language standard so that the programmer isn't required to do *everything*.

Show thread
Follow

@philipwhite This is an interesting idea, but breaks down when you have to consider multiple different CPUs. The nice thing about compilers choosing their optimisations is that you can also specifically optimise for e.g. AVX-512.

I think it would only work for more general optimisations like loop unrolling or general vectorization

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!