4 ms·
If a --k&r mode were to be reliable, wouldn't it need to get specified first? Otherwise people would start relying on some edge case. If speed is not a require
by iso8859-1 3y ago
If a --k&r mode were to be reliable, wouldn't it need to get specified first? Otherwise people would start relying on some edge case.
If speed is not a requirement for the --k&r mode, you could just take the tis-interpreter and note that if it runs without UB, it is still much faster than an actual computer was when k&r were active.
Would it even be possible to specify a variant of C that contains no UB (e.g. would define exactly what happens on unaligned access), but can compile practical existing C89 programs? I wonder if it could be written such that it could actually specify the behaviour consistently across the language intersection supported by both of e.g. GCC 2.95 and Chibicc[0].
Or maybe there are so many bugs in GCC 2.95 that it would simply be infeasible? How much time would it take to specify?
[0]: https://github.com/rui314/chibicc https://github.com/rui314/chibicc
- tedunangst 3y agoIt could probably only be used with a neural link. It would read your mind, then emit code that matches your perception of what you imagine old compilers did.
- zokier 3y agoYou jest, but there was some real effort put in to attempt define a dialect of C that would be less UB etc. And indeed the big problem was defining the semantics: > After publishing the Friendly C Proposal, I spent some time discussing its design with people, and eventually I came to the depressing conclusion that there’s no way to get a group of C experts — even if they are knowledgable, intelligent, and otherwise reasonable — to agree on the Friendly C dialect. There are just too many variations, each with its own set of performance tradeoffs, for consensus to be possible. https://blog.regehr.org/archives/1287 https://blog.regehr.org/archives/1287
- tialaramex 3y agoRight, One of the many benefits of Rust is that it provides a convenient litmus test for C and C++ programmers who complain about UB. For some of them, having a language (safe Rust) where programs don't have Undefined Behaviour is excellent - but for a whole lot of them this isn't OK. And the reason IMO is that they didn't actually want Defined Behaviour. What they wanted is for their nonsense programs to just work anyway. They want to skip the hard part of the job of software engineer where you need to correctly express what you meant as a program. They're the current generation of the people Charles Babbage complained of, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?'.