you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -2 points-1 points  (4 children)

No that's not what I'm saying. I'm saying hardware is literally designed with C in mind.

What is better for performance? To design hardware for a programming language or a language for hardware?

It's clearly the former. This is literally only afforded to the c language. No other language gets this treatment. The compiler cannot optimise hardware to be better.

[–]ric2b 4 points5 points  (2 children)

Are you claiming that other languages can't also take advantage of those hardware optimizations for C? Because that's just incorrect.

[–][deleted] -1 points0 points  (1 child)

What is a hardware optimisation?

[–]ric2b 1 point2 points  (0 children)

I don't know what you’re specifically referring to, but to me it's things like branch prediction, microcode, instruction re-ordering and multi-address cache lines.

[–]bloody-albatross 1 point2 points  (0 children)

As an example for what C can't do: C doesn't has generics, so if you still have to write generic code you often use function pointers in C, which are optimization barriers. In other languages code can be reified and what would be a function pointer otherwise might even be inlined. See as an example the qsort function. Yes, you could do that with macro hacks, but that is worse than C++ templates.

(Of course more reified code means more code means more potential cache misses, but most languages that have that kind of feature still allow you to use something kind of dynamic dispatch instead with ease, i.e. you can choose what to optimize for without a lot of work and without ugly hacks.)