13 ms·
What I get in these article is that the original intent on C language stands true. Use C as a common platform denominator without crazy optimizations (like tcc
by fithisux 9mo ago
What I get in these article is that the original intent on C language stands true.
Use C as a common platform denominator without crazy optimizations (like tcc). If you need performance, specialize, C gives you the tools to call assembly (or use compiler some intrinsic or even inline assembly).
Complex compiler doing crazy optimizations, in my opinion, is not worth it.
- eru 9mo agoWell, C is a lie anyway: it's not how computers work any more (and I'm not sure it's how they ever worked).
- woooooo 9mo agoAssembly isnt how they work under the hood, but its the highest fidelity interface we have. C as "portable assembler" is targeting the surface that chip designers give us and the one that they try to make fast via all their microcode tricks.
- kergonath 9mo ago> Complex compiler doing crazy optimizations, in my opinion, is not worth it. For these optimisations that are in the back-end, they are used for other languages that can be higher-level or that cannot drop to assembler as easily. C is just one of the front-ends of modern compiler suites.
- ziml77 9mo agoSome of them even give you access to this stuff. C# has Vector<T> which picks implementations of various operations based on the current CPU's capabilities. But they also let you have complete control if you want by providing functions in the System.Runtime.Instrinsics namespace.
- vjerancrnjak 9mo agoI remember being quite surprised that my implementation which uses manual stack updates is much slower than what compiler had with recursion. Turns out, I was pushing and popping from stack on every conceptual "recursive call", but compiler figured out it can keep 2-3 recursive levels in registers and pop/push 30% of the time, had more stuff in memory than my version as well. Even when I reduced memory read/writes to ~50% of the recursive program, kept most of the state in registers, the recursive program was faster anyway due to just using more registers than me. I realized then that I cannot reason about the microoptimizations at all if I'm coding in a high-level language like C or C++. Hard to predict the CPU pipeline, sometimes profile guided optimization gets me there faster than my own silliness of assuming I can reason about it.