5 ms·
"The compiler did not have a bug. The compiler never had a bug. The bug was always in the programmer's code and usually in their understanding of the language..
by qwerty456127 9y ago
"The compiler did not have a bug. The compiler never had a bug. The bug was always in the programmer's code and usually in their understanding of the language... It was caused by a misunderstanding of the way arguments to unprototyped functions were automatically promoted..." - I'd say the bug is neither in the compiler nor in their understanding of the language but in the language itself then. Why on Earth do we need a language that we can't use safely without "understanding of the way arguments to unprototyped functions are automatically promoted"? IMHO the number-one principle to be followed in every sane language design is the "principle of least surprise" (POLA). If the language can surprise you easily and lets you write weird code that is going to work a way different from what one will probably assume intuitively - that's a language made wrong.
- aalleavitch 9y agoSome people seem to believe that you shouldn't use a language unless you're capable of writing the language yourself.
- lovich 9y agoThey should have never started using their mother tongue then
- dkarl 9y agoWhy on Earth do we need a language that we can't use safely without "understanding of the way arguments to unprototyped functions are automatically promoted"? Backwards compatibility and uses that are niche but vital. Programmers insist on using parts of languages long after they're discovered to be bad ideas, or when they're included in the language for very specific use cases that aren't relevant to 99% of programmers. Those parts of languages are catnip for "real" programmers. "You'd be foolish to use this technique, and you'd have to be stupid to need it for this application." "That's a matter of opinion, but it's fact that I'd have to be clever to make it work." Can't argue with someone who thinks like that.
- mnw21cam 9y agoRelevant quote: Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? Brian Kernighan
- kccqzy 9y agoWhat’s surprising for you might be hardly surprising for someone else. Intuitively `0.1+0.2==0.3` should be true in every language. Now fire up REPLs and test that and the number of common languages where that is actually true can be counted with just one hand.
- ajross 9y ago> Why on Earth do we need a language that [...] Have someone sit down with you and explain how slow computers were in the 1970's. C won because it could be efficiently implemented on everything, produce better code than pretty much anything else, and still produce effective software quickly. And everything after that is a network effect because of all the inherited C. Your complaint has been repeated ad nauseum by literally generations of programmers who simply can't imagine why everyone did things this way, and who then go on to productive careers writing or integrating or just living with software still written in C. If you want to change the world, you need to stop pontificating and roll up your sleeves. There's a whole lot of code to write in rust, or whatever your particular brand of zealotry demands.
- wbl 9y agoMainframes had bounds checks. It didn't cost much, but C omitted them. Some of the undefined behavior in C particularly around accesses and overflow could be changed to implementation defined to fix some of the more footgunny parts. Until C 99 C could not vectorize nearly as much as Fortran. C won because of Unix network effects and the PDP, not because it was that good a choice.
- ajross 9y agoSurely someone had checked loads. The IBM 360/370 did not (unless it was some optional thing they sold -- certainly it wasn't part of the basic architecture), so "mainframes" seems rather spun. Likewise, yes, C's floating point calling conventions sucked and Fortran continued to see use in numerics work for a long time. But at the same time no one was writing performance-sensitive vector code for their Cray's in high level languages, ever. And frankly no one even thought to until GPUs made low level code impossible. I'll say it again, C won because: 1. Compilers could be (and were!) written for any byte-addressible architecture by one hacker in a basement... 2. ...that produced output code quality comparable to what you could get anywhere else in the industry 3. ...and take advantage of the huge community of C hackers. Different languages running on supercomputers and non-360 mainframes wouldn't have changed any of that.
- acjohnson55 9y agoI'm pretty confident that every language is made wrong, then. Unless you go super minimal, there's just no way to guarantee that features won't interact in surprising ways for some given person's expectations.
- khedoros1 9y ago> "principle of least surprise" (POLA) I'm astonished that "principle of least surprise" would be written "POLA".
- MaxBarraclough 9y agoParagraph breaks, please. > If the language can surprise you easily and lets you write weird code that is going to work a way different from what one will probably assume intuitively - that's a language made wrong. I agree that much of what is unhelpful about C could be changed without compromising its principles. Implicit conversions, for instance, and implicit fall-through. Fortunately there are compile-time warnings and run-time checks (such as Clang's 'ubsan') to take the edge off.