4 ms·
> True, but LLVM IR and other IRs have undefined behavior > as well. LLVM IR has less undefined behavior than C, and even despite the reduced surface area f
by kibwen 11y ago
> True, but LLVM IR and other IRs have undefined behavior
> as well.
LLVM IR has less undefined behavior than C, and even despite the reduced surface area frontends have still historically wrestled with taming its UB (both PNaCL and Rust have documented their struggles).
> It limits you to one compiler, while C has many.
To quote Walter Bright on this topic (which I've linked elsewhere in this thread, but here it is again: http://forum.dlang.org/post/n1vbos$11ov$1@digitalmars.com http://forum.dlang.org/post/n1vbos$11ov$1@digitalmars.com):
> 1. You're at the mercy of bugs in the C compiler you
> cannot fix.
> 2. C leaves quite a lot as "implementation defined",
> causing endless compatibility issues with various C
> compilers.
> [...]
> 6. You'll suffer from endless bug reports caused by a
> mismatch between your compiler and the user's C
> compiler, whatever that might be.
> [...]
> 10. The order of evaluation of C code expressions is
> implementation defined.
> 11. Installation problems, again, because you don't
> control the user's C compiler.
- azakai 11y agoSure, multiple implementations always brings with it those downsides you quoted. Same thing with web browsers, etc. But the benefits of multiple implementations are pretty significant as well, so it ends up worth it in some cases, and not in others.
- kibwen 11y agoI agree with the comparison to web browsers, but even then how much deliberately implementation-defined behavior do modern web standards contain compared to C? I can think of Javascript object property enumeration order being unspecified, but nothing else springs to mind.
- azakai 11y agoThere's quite a lot, I'm afraid. For example, the precision of sin/cos (this led to bugs on real websites), the precision of random numbers (this led to a bunch of recent blogposts). And there are also non-semantic differences that end up being important, like one browser running certain things too slowly or taking too much memory. Multiple implementations is always more complicated ;) But in many cases it's better than a monoculture, in my opinion.
- kibwen 11y agoOh I'm not arguing in favor of a monoculture. But the OP's statement that "This would make it possible to leverage the C compilers that already exist for every platform out there" is naive because C's deliberate flexibility makes cross-platform and cross-compiler codegen fiendishly persnickety. Meanwhile, the only thing that you gain from all this extra effort is the ability to target platforms that GCC and LLVM don't already support, but these platforms are all likely to be obscure resource-constrained devices, and I just can't see developers on these platforms flocking to such a thoroughly-dynamic language as the OP is envisioning.
- azakai 11y agoYes, the corner cases are quite bad. But still, C code can be remarkably portable. Back in the older days, using autoconf you could run - well written&portable - C code on a very wide variety of OSes and architectures. Since then both OSes and architectures have consolidated, so it's less noticeable I suppose. But yes, I agree that in the context of a really dynamic language, it might not be what the author wants anyhow.