3 ms·
> Such as? Extremely high performance, compact binaries, and its ability to be used both for cross-platform functionality, and for low-level and platform-speci
by MaxBarraclough 8y ago
> Such as?
Extremely high performance, compact binaries, and its ability to be used both for cross-platform functionality, and for low-level and platform-specific functionality. All the reasons C took over the world (every major operating-system and game-engine, for starters), rather than its competitors.
Kernel developers and game-engine developers care about performance. Embedded developers care about binary size. It doesn't do to pretend that C's advantages there don't really matter.
C isn't a 'big government' language like Java. It isn't meant to be. It's meant to be more of a very-high-level assembly language.
Programming languages are a matter of tradeoffs, not of the 'one true path'. If you want a language with good safety assurances, look elsewhere.
> C does not have the needed expressiveness to use most modern performance enhancements (like SIMD, auto vectorizing requires a lot of work and checking of conditions, and is not very efficient)
Auto-vectorisation is a tough nut to crack, sure. That's not specific to C though. Even frameworks like OpenCL are based on C.
> what were important optimizations 40 yrs ago today are reckless (like no boundary checks)
C has a pretty terrible track-record on security, yes. Precisely because it's not a safe language.
I believe Clang now has a flag to add runtime boundary-checks. For many applications, I agree with you that it would be worth the performance penalty to enable that runtime check in all builds.
- pjmlp 8y ago> Extremely high performance, compact binaries, and its ability to be used both for cross-platform functionality, and for low-level and platform-specific functionality. All the reasons C took over the world (every major operating-system and game-engine, for starters), rather than its competitors. After 30 years of throwing money at it.
- swebs 8y agoNah, it's had those advantages since year 1. Like the the other guy said, it's pretty much high level, portable assembly. It wasn't until later that modern languages introduced bounds checking, virtual machines, garbage collectors, and other things that improve safety but have performance and bloat tradeoffs.
- pjmlp 8y agoMe and others that had our 16 bit codebases full with inline Assembly beg to differ. C benefited from the domino effect of UNIX's adoption, that is all. Had AT&T been allowed to sell UNIX at the same price points as VMS, OS/360, Star among many others, and C would have been a footnote on the history of system programming languages, like many others.
- MaxBarraclough 8y agoBut C code is faster than any other major language, and its low-level facilities are better. > C would have been a footnote on the history of system programming languages, like many others Which programming language would Vulkan be using if we didn't have C? Presumably a language much like C, no?
- pjmlp 8y agoC became faster thanks to 30 years of compiler research improving optimization algorithms while taking advantage of UB. Something else naturally, with stronger memory guarantees and memory unsafe constructs clearly expressed on the type system, like Ada/SPARK, PL/8, PL/S, BLISS or whatever else might have wiped UNIX if it had been closed source sold at the same price level as OS/360, VMS among others.
- MaxBarraclough 8y agoI agree it's a shame there's so little Ada/SPARK. Does Ada hold its own at low-level work though? C interfaces well with assembly code, has pointers, etc. Can Ada compete there?
- pjmlp 8y agoOf course, pointers and FFI to Assembly aren't something magical about C.
- 8y ago
- MaxBarraclough 8y ago> After 30 years of throwing money at it. Which high-level language used to roundly outperform C, then? C used to be far slower than assembly, sure. That's not the point.
- pjmlp 8y agoC was nothing special get that in your head, it wasn't even used outside AT&T, before they started giving away UNIX source code to universities with the symbolic price of around 100 dollars instead of the closed source systems costing several thousand dollars that those universities were paying for. C was just yet another systems programming language looking for developer eyes, among PL/I, PL/S, PL/8, NEWP, Mesa, Modula-2, Concurrent Pascal, Object Pascal, UCSD Pascal, PL/M, Ada, CLU, ... C is the JavaScript of systems programming languages, designed without care for what being done outside AT&T walls since the mid 60's in language research and compiler technology, helped by UNIX and POSIX adoption across the industry thanks to source code availability and symbolic prices until AT&T got split and tried to close down BSD, and naturally the years of investment in optimization research.
- MaxBarraclough 8y ago> get that in your head Manners. Otherwise, interesting points, thanks. I wonder if we'll see the rise of another minimal low-level language anything like C. To put that another way: I wonder if Zig will take off .(I know of no other such projects. I don't know much about Rust but I believe it's a more 'feature-rich' language.) Zig seems like a neat idea for a language - there's plenty to improve on in C without introducing a full 'managed' framework, like its insane implicit type conversions. I still don't know what you mean by "years of investment in optimization research". We have high-performance cross-platform code now. Yes, that took decades.
- pjmlp 8y agoSorry if I offend you that wasn't really my intention. For someone that watched C riding the UNIX wave while killing other safer alternatives, that weren't lucky enough to be bundled with an winning OS, it kind of throws me out when I see C being argued as the ultimate systems programming language. It is an historically accident that things turned out this way, and at very least JTC1/SC22/WG14 should provide a safe C subset. Even ISO C++ working group has ongoing proposals to reduce C's unsafety influence on C++. Otherwise POSIX derived OS will continue to be a collection of security patches and band aids trying to make up for those issues.