News for hackers. Stuff that matters.
Re:This shouldn't have happened: A vulnerability postmortem by zionic on Wednesday December 01, 2021 @02:49PM (#29408290)
C/C++ don’t really have “benefits”, they have inertia. In a hypothetical world where both came into being at the same time as modern languages no one would use them.

Sadly, I’m to the point that I think a lot of people are going to have to die off before C/C++ are fully replaced if ever. It’s just too ingrained in the current status quo, and we all have to suffer for it.

Re:This shouldn't have happened: A vulnerability postmortem by nickelpro on Wednesday December 01, 2021 @03:50PM (#29408958)
On any given platform, C tends to have the only lingua franka ABI. For that reason it will be around until the sun burns out.
Re:This shouldn't have happened: A vulnerability postmortem by pornel on Wednesday December 01, 2021 @05:38PM (#29410079)
The C ABI will outlive C, like the term "lingua franca" outlived the Franks. Pretty much every other language has support for the C ABI.
Re:This shouldn't have happened: A vulnerability postmortem by jstimpfle on Wednesday December 01, 2021 @06:37PM (#29410562)
One complication is that it's not just about ABIs but at least as much about APIs. And C headers often make some use of the preprocessor. Usage of the preprocessor often even is part of the API, i.e. APIs expose preprocessor macros for the API consumer.

Zig has a built-in C compiler and supposedly you can just "include <header.h>" from within a Zig source file. Rust has a tool called bindgen. There are other tools, I haven't tried either of them, but the fact alone that I'm somewhat familiar with the Windows (and some other platforms') headers makes me not look forward to the friction of interfacing with some tried and true software platforms and libraries from within a different language.

I know there has been some work going on at Windows on porting their APIs to a meta-language. Does anyone know how much progress was made on that front?

Re:This shouldn't have happened: A vulnerability postmortem by pornel on Thursday December 02, 2021 @07:05AM (#29415096)
The Windows meta-API thing is done: https://lib.rs/windows

We'll probably continue using C headers as a poor ABI definition format, even without writing programs in C. Sort-of like JSON used outside of JavaScript, or M4 known as autoconf syntax, rather than a standalone language.

But C headers as an ABI definition format are overcomplicated and fragile (e.g. dependent on system headers, compiler-specific built-in defs, and arbitrary contraptions that make config.h), and not expressive enough at the same time (e.g. lacking thread-safety information, machine-readable memory management, explicit feature flags, versioning, etc.).

So I think there's a motivation to come up with a better ABI and a better ABI definition format. For example, Swift has a stable ABI that C can't use, so there's already a chunk of macOS and iOS that has moved past C.

Re:This shouldn't have happened: A vulnerability postmortem by jstimpfle on Thursday December 02, 2021 @10:59AM (#29417788)
Not disagreeing about the issues of header files and the difficulty of consuming them from other languages (which was my point).

But regarding ABI definitions, I suspect that introducing "thread-safety information, machine-readable memory management, explicit feature flags" will make interopability at the binary level difficult or impossible, which is even worse.

Re:This shouldn't have happened: A vulnerability postmortem by pornel on Friday December 03, 2021 @06:01AM (#29428673)
Why do you think so? These things don't define binary layout, so they shouldn't interfere with it. In the worst case the extra information can be ignored entirely, and you'll have the status quo of poor thread safety, fragility of manual memory management, and crashes when the header version is different than binary .so version (the last point is super annoying. Even when the OS can version .so libs, C gives you absolutely no guarantee that the header include path and defines given to the compiler are compatible with lib include paths given to the linker).
Re:This shouldn't have happened: A vulnerability postmortem by pjmlp on Thursday December 02, 2021 @08:48AM (#29416027)
On Android, ChromeOS, IBM i, z/OS, ClearPath it isn't.
Re:This shouldn't have happened: A vulnerability postmortem by kwertyoowiyop on Wednesday December 01, 2021 @02:52PM (#29408328)
C/C++ will be around for at least a hundred years. Our descendants will be writing C/C++ code on Mars.
Re:This shouldn't have happened: A vulnerability postmortem by zionic on Wednesday December 01, 2021 @03:06PM (#29408496)
I don’t know about that, I can see Rust having a certain aesthetic appeal to martians.
Re:This shouldn't have happened: A vulnerability postmortem by axelf4 on Wednesday December 01, 2021 @03:49PM (#29408954)
Nah, they definitely use Zig.