5 ms·
This entire article seems to amount to "I am used to C, thus I don't see the problem with C." which is a fine position to have, but it's a perspective unique to
by mlindner 4y ago
This entire article seems to amount to "I am used to C, thus I don't see the problem with C." which is a fine position to have, but it's a perspective unique to the writer and others like him. It doesn't apply to people learning new languages that aren't C.
Also several statements about how C must be used because somehow it's closer to the real world/hardware than other languages. Which is easily shown to be false given that hardware designers have had bend backwards and into contorted shapes to emulate the hardware environment that C was originally created to work against. This great article is a nice rebuttal of that: C Is Not a Low-level Language: Your computer is not a fast PDP-11. https://queue.acm.org/detail.cfm?id=3212479 https://queue.acm.org/detail.cfm?id=3212479
These types of arguments feel like they come from people who don't realize how much the compiler reworks your code to make it act like it does what you told it to do.
- keithalewis 4y ago[flagged]
- pprotas 4y agoIt was not worth reading but it was worth clicking the reply button? Not sure what you mean by “rant”, he makes some good points.
- snickerbockers 4y agoNo, the problem is not that modern CPUs want to be a PDP-11, it's that they want to be an 8086 for compatibility reasons. From the software's perspective, the ISA *is* the hardware. It doesn't matter if the CPU is internally recompiling everything to a RISC-like architecture with an arbitrary number of registers because there's nothing i can do to access that. If there's ever a radical new ISA which supplants x86 where C's constructs prove to be a bottleneck, and that ottleneck only applies to C, you will finally see it fall to the wayside. >These types of arguments feel like they come from people who don't realize how much the compiler reworks your code to make it act like it does what you told it to do. I guess it's hard to argue against a vague undefined term like "rework" but i can assure you that the output of gcc largely resembles what i expect it to. If the compiler does something bizarre i will know about it because i actually do check the assembly.
- bhawks 4y agoOP links to: https://queue.acm.org/detail.cfm?id=3212479 https://queue.acm.org/detail.cfm?id=3212479 Which in the very initial paragraphs points out it is not about having a hidden set of registers to work with - it's about exploiting parallelism and the tension between a sequential programing language and massively parallel hardware architecture. The ISA is not the hardware it's a 40 decade old abstraction that the hardware bends itself into to make your code run.
- mpweiher 4y ago> From the software's perspective, the ISA is the hardware Precisely! And because the weirdness happens below the ISA, all the mismatches Dave Chisnall describes apply to any other language just as much including actual machine language. So raw machine language is not a low-level language? <head scratch>.
- bhawks 4y agoIt is rare to build general purpose computing hardware in lockstep with software. The two worlds are only bridged by the ISA interface. It'd be interesting to see what interface we'd choose today with multiple decades of hardware and software development.
- mpweiher 4y agoConsidering we're still trapped by the Gentle Tyranny of Call/Return, we'd probably choose the same interfaces...never mind the huge path-dependence on optimising all the parts around those interfaces. I have a sneaking suspicion that a more dataflow-oriented interface might be useful. The CPUs do dataflow analysis, the compiler does dataflow analysis, and higher levels are also often dataflow, but all communicate using a non-dataflow instruction stream. On the other hand, the only commercial dataflow CPU I am aware of, the NEC 7281 (http://www.merlintec.com/download/nec7281.pdf http://www.merlintec.com/download/nec7281.pdf) was less than successful.
- AshamedCaptain 4y ago> It'd be interesting to see what interface we'd choose today with multiple decades of hardware and software development A worse one? Not a couple days ago there were a couple stories about Itanium here on HN (a designed-from-scratch ISA that turned out to be practically worse than the much more ad-hoc x86_64). Even e.g. RISC-V (which is not entirely free of legacy) is practically 1:1 with ancient ISAs like ARM.
- Gordonjcp 4y ago> C Is Not a Low-level Language: Your computer is not a fast PDP-11. We'd be in a damn sight better place if it was, though.
- mlindner 4y agoOur computers would be a lot slower if they were just a fast PDP-11. The way computers worked changed because the physical reality of transistors don't like to work in that manner.
- Gordonjcp 4y agoNot sure why you think the transistors we make have any influence of the design of an instruction set architecture or register set.
- AshamedCaptain 4y ago> Which is easily shown to be false given that hardware designers have had bend backwards and into contorted shapes to emulate the hardware environment that C was originally created to work against. It may be a valid point, but value-less, since this basically implies that most hardware you are going to be able to buy today (ARM, x86, whatever) is going to be a fast PDP-11 (or at least it's going to present itself as one).
- tialaramex 4y agoNot quite. The modern hardware isn't actually a fast PDP-11 it's just capable of emulating one more efficiently than you would if people didn't insist on writing C. So it may be that your "clever" C algorithm which in your head translates into just six CPU operations, unfortunately on a real modern CPU is six hefty macro-ops that will take dozens of cycles to execute and repeatedly go to sleep waiting for main memory, whereas the algorithm in a modern language that looked ludicrous to your C programmer eyes compiles to sixteen tiny ops the CPU can consume two at a time with no waits and it's done in eight cycles while the C code was still waiting for a main memory read.
- AshamedCaptain 4y ago> The modern hardware isn't actually a fast PDP-11 it's just capable of emulating one more efficiently than you would if people didn't insist on writing C. I'm not disagreeing with that. It's a valid remark. What I'm arguing is that it's a useless remark in practice. > So it may be that your "clever" C algorithm which in your head translates into just six CPU operations, unfortunately on a real modern CPU is six hefty macro-ops that will take dozens of cycles to execute Note that this was already true even for the original PDP-11, and more so for the original 8086, both being ridiculously CISC and microprogrammed. C was born in this context. > whereas the algorithm in a modern language that looked ludicrous to your C programmer eyes compiles to sixteen tiny ops the CPU Even if true, it's irrelevant, since even a "modern language" will be forced to target that machine with its PDP-11 -emulating ISA, and is therefore subject to the same limitations than "modern C" is. The very point the article is making leads to the conclusion that most machines today are actually presenting themselves as a PDP-11-like, and therefore any language which does not target a PDP-11-like is doomed to a niche.
- MYEUHD 4y ago>C Is Not a Low-level Language: Your computer is not a fast PDP-11. https://queue.acm.org/detail.cfm?id=3212479 https://queue.acm.org/detail.cfm?id=3212479 C is indeed a low level language. If you wanted a language that's close to the actual hardware you have, you'd have a different language for different hardware. (That's what assembly is) Meanwhile, C is simple and easy to write compilers for. Therefore, it gained popularity because of its portability
- astrange 4y agoIf you know how a CPU works, especially the bits outside decode and ALUs like cache coherency, I don't think you could call assembly "close to the hardware" either.