r/ProgrammingLanguages • u/mttd • Jul 01 '26
The Expensive Fictions of Low-Level Programming Languages
https://stng.substack.com/p/the-expensive-fictions-of-low-level
19
Upvotes
r/ProgrammingLanguages • u/mttd • Jul 01 '26
View all comments
Show parent comment
1
u/lookmeat Jul 02 '26
I agree, I don't know if we need a language that gives us more power than C, but we could benefit from an assembly that gives us more power. For example one of the most common issues with making code efficient is ensuring memory access patterns are friendly to the CPU's opaque pre-fetchers. Imagine an architecture where you instead load pages from memory into the cache explicitly and then can access individual words/bytes within that page in the cache (and furthermore we can simplify a lot of the complex memory-access-order behavior by instead enforcing a transactional system to push and pull pages from RAM). This would allow C compilers that understand what the ordering of access is going to be, or what the costs are, simply by having access to the bigger context that a programmer has (that is the compiler may understand you are inside a weird for loop, but still a predictable for-loop, unlike the CPU that just sees what the next access is going to be) to do more interesting optimizations (or at least expose pragmas that programmers can use to direct their program).
Updating C would really be, IMHO, more about understanding nuances we do about programming to reinvent certain areas of the programming language. For example we could have pointer types that do not allow for arithmetic, and address types that do allow for arithmetic, with UB being relegated (and managed by careful programmers) only in the point we convert an address into a pointer. Or we could make arrays actual types that work as variables (of very large size) and handle that, rather than the weird place that C did which made sense in the time where there were only word sized ints, word sized pointers and byte size chars (in B, since there was no byte-size, but only word-size values, everything was an int, there was no difference between an int and a pointer, because pointers always word-size values that pointed to word-size values).