6 ms·
My concern is this seems like it's own fallacy now. You are assuming the same experts could have written these systems in another language. Could they? Maybe
by taeric 10y ago
My concern is this seems like it's own fallacy now. You are assuming the same experts could have written these systems in another language.
Could they? Maybe. But there is no solid evidence that they could.
Is the argument appealing? Yes. But it is lacking the evidence of these systems that could be better in other languages.
My 2 cents for why, is that c is basically the only game in town that can easily use new and special assembly. Of which there is a lot. Consider, what is the fastest way to calculate a square root? And how old is that instruction? (I'm assuming it is actually used by higher level languages by now.)
- kstrauser 10y agoI don't think that's true. Let's pick the Node.js ecosystem for an example (chosen because I use it very little, so I'm not hyping up my own pet language). Lots of non-expert programmers are writing Node packages, both for their own in-house use and to share with others. I'm going to assert that the average Node user has fewer years programming than the average C user. And yet, they seem to have fewer critical vulnerabilities per amount of code written. They still make mistakes all the time, sure! But they're a higher class of mistakes, more "this sets the wrong HTTP status code" and less "this exposes kernel memory to remote users". JavaScript handles the low-level abstractions so that its users can concentrate on breaking the higher-level stuff, hopefully in ways that are easier to test and notice. Also, almost every language has a way to use C code directly (For example, see Go: https://golang.org/cmd/cgo/ https://golang.org/cmd/cgo/). C may be the best way to write low-level driver code. If it is, use it for that! I'm not convinced that there's a single best language for Ethernet card drivers and HTTP stacks, though.
- taeric 10y agoWhat systems are we talking about, then? Few people are writing stuff in C/C++ nowdays. And the fields that do this on a regular basis are pretty much unchallenged by any of the higher level languages. And, agreed, on truly expert systems, things do go polyglot. This has been true since pretty much the beginning of computers. I'm not sure what sort of evidence this provides, though. So, to bring it directly to point. Where is the evidence that the systems people typically write in C could be written well in another language? About the best I have seen is some system utilities written in rust. Which is awesome, no doubt. And the beginnings of the evidence I'm asking for. (To be fair, we often speak of mysterious wizards that wrote the symbolic lisp systems as though they succeeded at this. I want that to count as evidence, but it feels more like hearsay.)
- hodgesrm 10y ago(Now arguing the other side...) There is a case for looking at safety issues in C. Reducing the possibilities for mayhem from null pointers would be helpful. What I don't fully understand is critiques of C that lump safety issues in with use of braces or semi-colons.
- taeric 10y agoA lot of the safety issues in C have been decently solved, though. You just have to use a larger tool chain than just the compiler. (Valgrind, coverity, etc.)
- hodgesrm 10y agoFair point, I think what's missing from some of the discussion here is that very few languages are productive without an effective toolchain.
- taeric 10y agoYeah. I have tried times in the past to make sure folks don't just think in terms of language, but full toolchains. I confess I am not good at that thinking, either. :(
- hodgesrm 10y agoBut it seems the OP's implicit point was that C is not the right language for higher-level operations. For low-level access it's not very obvious what else you would use. Personally I rarely use C because I currently write network services with REST APIs. C is close to worthless for that purpose for many reasons, not just errors. It's analogous to writing an accounting app in assembler. Most people stopped doing that in the 1960s.
- pjmlp 10y ago> For low-level access it's not very obvious what else you would use. Extended Algol, created in 1961. Almost 10 years before C. There are tons of other examples. C got widespread thanks to UNIX, just like a few decades later, JavaScript got widespread thanks to Web 2.0 and the browser. > It's analogous to writing an accounting app in assembler. Most people stopped doing that in the 1960s. Lotus 1-2-3 was initially written in Assembler, Ι will let you track down when it was created. My last 100% Assembly program was for MS-DOS in 1996.
- hodgesrm 10y ago> Lotus 1-2-3 was initially written in Assembler, Ι will let you track down when it was created. Interesting! I did not know that. I would still stand by the point that application programming by the end of the 60s was leaving the Assembler era and moving on to languages like COBOL and FORTRAN. (And weird cul-de-sacs like RPG which was my second programming language after BASIC.)
- pjmlp 10y agoThis was true on mainframes and workstations. At 8 bit and 16 bit computers target for consumers it was a different story. Forth, Basic, Pascal, C, Amos, Modula-2, Clipper were the "managed languages". Anything that required performance was written in Assembly, or high level in such "managed language" (Turbo Pascal on my case) with lots of inline Assembly.
- ksk 10y agoIMHO, people constantly introduce vulnerabilities when using high level code. Most websites are defaced this way. They're not exploiting flaws in Apache or IIS anymore. Its the Python or PHP or Node.js application or wordpress blog or similar that doesn't sanitize user input or has a buggy web api.
- jerf 10y agoA C program talking to the web will have memory vulnerabilities, encoding vulnerabilities, and business logic vulnerabilities. A modern program talking to the web will have encoding vulnerabilities and business logic vulnerabilities. It's still progress. There are cutting edge stacks which will effectively eliminate the encoding vulnerabilities, too, leaving more-or-less just the bugs you put in. (Obviously I'm simplifying the types of vulnerabilities that exist to make a point.)
- ksk 10y agoWell, you could make another argument too. Given X amount of time in a day, a C programmer can't really pump out _that much_ business logic code because they're also dealing with the other lower level stuff. A high level language OTOH allows you to be more productive in terms of the business logic stuff, and therefore, I'm using a rough metric here, more lines of code, which also means more bugs in the business logic. Like you said, these are all simplifications, but I think the primary problem is that people undertake projects that are way above their competency level. Edit: If we could get some multiplayer-game like matching system where you are matched with the project depending on your skill level that would be awesome.
- dmitrygr 10y ago> fewer critical vulnerabilities per amount of code written Because nobody uses node.js in serious infrastructure. Show me a serious ISP whose DHCP server is written in node. Know any whose DNS server is written in node? Your statement is equivalent to: we should build bridges out of legos and not out of concrete because fewer people have been killed by collapsing lego bridges
- hodgesrm 10y agoAs another example could you write a device driver in a language like Python? I was frankly a little disappointed in both the referenced article and the one it references. C basically is assembler. If you have a problem that needs hardware-level access you'll need things like pointers. The really hard parts of C (like handling null pointers or lack of concurrency primitives) seem to be the flip side of this access. Whether you use things like braces just seems to be a matter of taste.
- a3n 10y ago> As another example could you write a device driver in a language like Python? Sure, with Cython or a Python C extension. :)
- RUG3Y 10y agoMy thought exactly =)
- luhn 10y agoOf course Python isn't up to the task of device drivers, but C isn't the only language that can do that. You could write a driver in Rust, which is a significantly safer language than C.
- hellbanner 10y agoWhy are C & Rust available to write drivers but Python cannot? Is this because Python is too abstracted, where C & Rust have access to the physical hardware without the need for an API?
- xorxornop 10y agoC and Rust compile to native code. Python doesn't. It's either interpreted, or run in an abstract machine (VM). Python was never really intended to interact with the actual hardware directly. I mean, you could, there's no real technical blocker, but it'd be horribly slow. Plus many failure modes of touching hardware are very likely to break the VM process and make debugging very challenging
- jerf 10y agoAs someone who is already fairly hostile to C and actually getting even more hostile over time (the recent shenanigans where the compilers are cracking down on "undefined" behavior with "optimizations", in a language where it's virtually impossible to avoid "undefined" behavior at scale, is insane), part of my hostility is precisely that there there have historically been no other engineering-valid alternatives. (There have been alternatives, just not ones you would have been wise to bet your career on.) It is an example of one of the worst local optimas we can find in computer programming, where something comes out that is pretty good for its time, and then entrenches itself so thoroughly that nothing can ever extract it ever again even though it isn't actually a great foundation to build on for decades at a time. Other examples include SQL, Javascript (though WebAssembly may free us from that before we're stuck with it in 2040), and Unix. When I say this sort of thing, people tend to flip out and start defending those techs against the claim that I don't think they're good at all. That's not the problem. They are good. The problem is that they're not good enough to build on for the future, but they are good enough to entrench themselves. The consequence is that it takes a lot of riling up the community with knowledge of the shortcomings to fertilize the ground for alternatives to arise and be supported enough to make progress. So, please stop defending C. It is what it is. It had a good run. Nothing will ever make it stop being the most important language of the last four decades. But if you don't want it to be the most important language of the next four decades... and you really shouldn't... please stop defending it. Give the alternatives space to breathe. $OBLIGATORY_RUST_CALLOUT.
- taeric 10y agoI'm not defending C. If anything, I'm attacking all of the so called "better" replacements. Specifically your call out that they should have existed by now. I treat that argument as a fallacy nowdays. I'll call it the "wishful thinking fallacy." I do this because if there is anything that calls into question the "science" part of computer science, it is the dogma of folks that refuse the empirical side of the field. It isn't like folks haven't tried to make better languages and toolchains throughout the years. You even acknowledge this. They just haven't delivered on their promises. And, some of that is because you are ignoring all of the advances that have happened in C. If you are not using modern tools like valgrind/coverity/whatever, you are not comparing C fairly to contemporary languages.
- zeveb 10y ago> My 2 cents for why, is that c is basically the only game in town that can easily use new and special assembly. In Steel Bank Common Lisp, one can just write a new VOP to emit a new instruction.
- taeric 10y agoYeah, I was aware of that. Naughty Dog did a similar thing with their toolchain. Lisp seems to have been damaged by the functional programming dogma more than anything else, the more I learn about it. Which is a shame, because the functional parts are good. But so were all of the toolchains around interop with other systems.
- geofft 10y ago> Consider, what is the fastest way to calculate a square root? And how old is that instruction? (I'm assuming it is actually used by higher level languages by now.) Isn't the right way to handle this for your code generator, e.g., LLVM, to know about this instruction, and your language implementation, e.g., clang or rustc, to just say "hey, give me a square root"? I do buy your argument for very processor-specific things like writing a bootloader or a hypervisor.
- taeric 10y agoThat is certainly the high level language way. Because the magic involved in the code generator is quite high. C, however, gives you hold onto the generator to say "use this assembly". So, for new or one off instructions, it is a quick way to get an edge.
- kazinator 10y agoSupport for inline assembly language in C is a compiler extension. It is not exclusive to C compilers.
- taeric 10y agoIndeed it isn't. It does seem to be most common there, though. (See sibling post for comments of early lisps supporting this. Well aware of it, but many higher level languages do not commonly support it.)
- geofft 10y agoMy question is, does it actually get you an edge? When you use inline assembly, the compiler (more or less) has to execute that inline assembly, right where you say it is. It can't speculatively execute it, it can't refactor the call into a different function if you're calling it twice, it can't optimize it out in certain circumstances, etc. It can't move the instruction around or choose a different form depending on register pressure. If you specify the right flags about what registers it clobbers, what memory barriers it requires, etc., the compiler can do some of it, but it's not going to be nearly as good as the compiler actually understanding what's happening, I think. Telling the code generator (and C is a high-level language in this respect, if you want any performance out of C) what you're doing is likely to get you more of an edge, no? I can certainly imagine cases where letting the compiler reorder a slow square root around a memory access will be faster in practice than a fast square root that can't be reordered.