7 ms·
One well known obstacle to optimizing C is the difficulty of alias analysis. It's easier to do that for languages that don't have C's unrestricted pointers.
by throwaway81523 5y ago
One well known obstacle to optimizing C is the difficulty of alias analysis. It's easier to do that for languages that don't have C's unrestricted pointers.
- pantulis 5y agoSo Rust comes to mind, right? Anything else?
- rwmj 5y agoFORTRAN or any language with lots of arrays and matrices.
- Semaphor 5y agoSo, APL?
- rwmj 5y agoAbsolutely yes that would make sense (or more likely the modern "derivatives" like J & K)
- jabl 5y agoI suspect if you want a HW architecture for running array operations you'll end up with something like a vector machine (e.g. ARM SVE(2) ) or a GPU rather than a VLIW CPU?
- marcosdumay 5y agoVLIW is basically a more flexible kind of vector machine.
- jabl 5y agoAnd a traditional scalar architecture is more flexible still. The trick is to pick the correct set of tradeoffs for the targeted applications. I claim that for most array style workloads vector/GPU architectures are flexible enough, and offer better perf/watt and perf/chip area.
- jonathrg 5y agoDoesn't the restrict keyword solve this?
- user-the-name 5y agoI don't think anyone has ever used the restrict keyword, or understood what it does.
- moonbug 5y agoderp.
- jonathrg 5y agoWhat? I use it whenever I have a function that takes two or more pointers if I know they can't refer to overlapping memory. And it's part of the signature for memcpy since C99
- IshKebab 5y agoWhen he said "anyone" he meant "almost anyone". You're an outlier if you use `restrict` regularly. I checked on grep.app, there are 10k results for `restrict` for C code, compared to 700k for `struct` (I know they're not directly comparable but that gives an idea.
- jonathrg 5y agoThat seems like about the right proportion to me - struct solves a much more common problem than restrict does. And to be fair, it is a lesser known feature. But user-the-name is implying that restrict is somehow difficult to use or understand, which I don't agree with at all.
- icedchai 5y agoThat probably explains it. In many shops, C may as well have stopped at C89. I've been working with C since the early 90's. I've never seen any code use restrict.