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
34
u/runningOverA Jul 01 '26 edited Jul 01 '26
Good article.
But without giving a solution how those limitations can be overcome, as in "C was designed for the hardware of 70s which doesn't exist anymore, and C is not low level".
...And without benchmarking the solution that overcomes those limitations and reaches the mythical "faster than C" level because the new language was designed for modern hardware unlike C.
...And before releasing the said language for programmers to use and set its relative position between easy to hard.
...nothing much really changes. Therefore we shall be waiting.
5
u/zyxzevn UnSeen Jul 01 '26
IMHO.. Small corrections from a CPU perspective.
C aimed at a certain CPU architecture. And the CPUs adapted their architecture to C as well. Both were expensive.
The CPUs started with special memory registers, without virtual memory. No cache, few registers and small memory. Math instructions were slow. Parallelism was popular via SIMD on "super computers", which worked with Fortran. Additionally signal processors were used for radar and such.
C simplified the memory addressing to one single integer. The memory could be addressed in any way, allowing tricks to reduce the memory footprint. Now such tricks used to keep data inside the CPU cache.
Operating systems and embedded programming have exotic memory models and often very limited memory. So this made Assembler or C the only options for systems programming. Other languages like Fortran or Pascal simply had not the correct memory access possibilities.
The virtual memory increased the size of CPU data-access enormously. Without special proxy data structures. This also added essential safety. So pointer validity checks were no longer necessary. This meant that C no longer crashed the operating system and could compete with safer languages.
Other languages like Pascal or ADA could easily have become a systems language. But for some reason language features for exotic memory access were never added.
13
u/jcastroarnaud Jul 01 '26
I think that the point of the article is: hardware moved on from the 1970s and C model, becoming much more complex and varied (parallelism, GPUs), thus with more performance knobs to tweak; C and most languages are unaware of these knobs, and their design makes hard to use them.
My wild guess is: compiler backends will need to evolve to take advantage of current hardware ecosystem, and new/updated languages will abstract over that view on hardware, instead of the 1970s one.
14
u/Seed_oil_simp Jul 01 '26
The articleās premise is based on the assumption that because C was designed in the 1970s and hardware has changed since then, C cannot be well suited for writing high performance programs on current hardware.
The reason this assumption mistaken is that hardware has developed since the 70s *with C programs in mind*. Because Windows and other system is mostly implemented in C/C++, hardware has developed to support C performance.
With the number of programming languages that get made, if it were possible to beat C performance by designing for current hardware, someone would have done it.
2
u/JeffD000 Squint Jul 03 '26 edited Jul 03 '26
I have some bona fides on the topic of the C/C++ language being the bottleneck to optimizations related to parallelism and the memory hierarchy, which many people commenting here seem to be focusing on from the article. See my response buried deep within a thread of the current post (shortcut link here):
https://www.reddit.com/r/ProgrammingLanguages/comments/1ukd472/comment/ov9mpue/?context=3
2
u/Norphesius Jul 01 '26
I feel like we need a better, or more particular, definition for what people are calling "formal verification", applied to common programming. I love the idea of applying these mathematical constructs to verify program correctness, and we've gotten genuine progress in the form of stuff like FP & Rust, but there's an asymptotic limit for the productivity of this kind of thing.
Especially with the growing idea that we can just chuck an LLM at a problem and have it generate results until it fits a spec perfectly, I'm concerned we're going to end up with false confidence in "correctness". The more you're trying to prove about the program, the more the proof (spec) has to grow in complexity. People will create incorrect specifications that appear to have properties they actually don't, or just fail to include some essential properties. An AI will happily waste a million tokens trying to generate according to the wrong spec (if it can do it anyway), and everyone will think things are fine until they're blindsided by a massive error/crash.
Eventually big enough spec is just going to be as complex to evaluate for correctness as a program, and then do we get an AI to verify that? People are approaching this like a silver bullet when it's really not.
12
u/cscottnet Jul 01 '26
This is written by someone who does not program for a living, and focuses on entirely the wrong problems.
As an example, focusing on performance differences between (say) C and Rust is ignorant of the fact that the largest performance factor will be choice of algorithm and big-O run time, and that likely 90% of all software is almost completely performance insensitive: it's only the actual performance-critical path where performance matters at all. An AI won't understand this, and neither does the author of this piece.
1
u/dnabre Jul 01 '26 edited Jul 01 '26
edit: for some reason I forgot branch prediction, and everything about GPUs.
I'm looking forward to the next parts, but this seems not to get the point. Seems to be getting at, regarding C, how much our modern processors have be optimized for it and/or providing facade for it. Beyond it's popularity and history, C isn't special here. Any other AOT language with low-level access that maps pretty directly from itself to assembly fits the bill here.
It's easy to forgot how much shuffling and translation is done inside CPUs, including piles of extra registers, operation units, and the like, to transform the normal C/assembly instruction stream into something that will fully utilize the CPUs abilities (assembly/binary instructions, same idea). For x86/x86_64, this is slightly worse, because generally CISC instructions get broken down into RISC instructions before the rest happens.
Without the follow up articles, I think more credit is being given to higher-level languages which can in theory compile to instruction streams that more fully utilize CPU resources without all the wasteful slide of hand. It could be done, but I don't think it is done, outside of possibly some research systems.
To avoid the overhead of this translation/re-ordering systems, you'd need processors that basically didn't do it, and let you use all the resources directly. Again, nice in theory, but isn't going to happen in the foreseeable future. Setting that aside, it is interesting to try to imagine what a C-level, or just assembly, language lets you use all of that would look like.
1
u/proudHaskeller Jul 05 '26
But the problem he points out aren't problems with C or Rust, they're problems with how our CPUs operate in the first place. The execution model is sequential because that's the execution model that is set by the architecture, regardless of how non-sequential the inner workings of the CPU are. The cost of a memory access is unknowable because the architecture does not give control over memory accesses and the CPU implements implements them in an unpredictable way.
There is no reason why C or Rust couldn't compile to a CPU architecture that solves these problems.
1
u/Soupeeee Jul 01 '26
The gist of the article seems to be that with modern programming languages, it's hard to verify a program's correctness and optimize it at the same time. Considering that AI will be writing most of the code in the future, the author suggests that the most important part of new programming languages is formal verification, and that humans being able to understand the code becomes less important. This opens the door to programs that are structured differently to take advantage of modern CPU pipelenes, speculative execution, and multithreading.
Two of the more intriguing APIs that I know of that try to fit this description are languages like Futhark that are designed to be converted into highly parallel during compilation and language APIs like Java's Vector API. Both provide constraints that help them achieve their goals, but also don't make you worry about lower level details like memory alignment and thread management.
I'm curious to see if the author talks about these developments and if they address some of the challenges that are described.