4 ms·
If you do this, your C code will run significantly slower than, say, Java, Go, or C#, because the compiler is unable to apply even the most basic optimizations
by NobodyNada 2y ago
If you do this, your C code will run significantly slower than, say, Java, Go, or C#, because the compiler is unable to apply even the most basic optimizations (which it can do still in all those other languages).
So, at that point why even use C at all? Today, C is used where the overhead of a managed language is unacceptable. If you could just eat the performance cost, you'd probably already be using a managed language. There's not much desire for a variant of C with what would be at least a 10x slowdown in many workloads.
- cv5005 2y agoOr it could be made faster because certain manual optimizations become possible. An example would a table of interned strings that you wanna match against (say you're writing a parser). Since standard C says thou shall not compare pointers with < or > unless they both point into the same 'object' you are forbidden from doing the speed of light code: char *keywords_begin, *keywords_end; if(some_str >= keywords_begin && some_str < keywords_end) ... Official standard sanctioned workarounds would require extra indirection (using indices for example) which is suboptimal.
- gpderetta 2y agoYou can cast them to uintptr_t and compare them to your heart's desire.