Re:"Rust does not have a stable ABI"
by dependenttypes on Thursday August 13, 2020 @07:14AM
(#24142084)
> Most of Rust's "nice security features" are wildly incompatible with existing C/C++ code and inherent language features
Such as?
Lifetimes and the borrow checker.
Re:"Rust does not have a stable ABI"
by dependenttypes on Thursday August 13, 2020 @11:10AM
(#24144122)
A linter can do that.
Nope.
Re:"Rust does not have a stable ABI"
by dependenttypes on Thursday August 13, 2020 @12:59PM
(#24145509)
Just because you lack the ability to imagine something like that it does not mean that it is impossible. Sadly this kind of sentiment seems to be way too common in tech.
This wouldn't be possible in a practical sense. One could imagine a static analyzer of some kind which infers all lifetimes, though that would likely quickly be unworkably slow on real codebases, since you need to infer programmer intent. Additionally c static analyzers intended to catch all memory errors/UB etc. have existed for decades, and no one uses them, b/c they don't work or have too many false positives. For example did you know that until C++20 allocating an int with malloc was UB in C++? Would you want to work in a language where the linter marked every other line as UB?
It is impossible given the spec and syntax of those languages, which is why Rust exists, to enable these features...
Re:"Rust does not have a stable ABI"
by SAI_Peregrinus on Thursday August 13, 2020 @01:45PM
(#24146019)
C lacks the information given to the compiler to do this. It can't be added without adding that to the language. So no linter can do this alone, without language changes.
Re:"Rust does not have a stable ABI"
by dependenttypes on Friday August 14, 2020 @08:41AM
(#24157114)
You can use _Pragma/#pragma, regardless though, you can achieve a lot of what lifetimes can without any annotation.
Re:"Rust does not have a stable ABI"
by SAI_Peregrinus on Saturday August 15, 2020 @06:27PM
(#24172972)
Pragmas are extensions to C, not part of the C language standard. You can add things to C, but it then ceases to be standard C and becomes GNU C or MS Visual C or early C++ or something else. But not ISO Standard C.
And yes, just about anything non-lexical lifetimes can do you can do with static analysis. But the set of things you can do with Rust includes things that need explicit lifetime annotations, which C doesn't have.
If you think we could get this right in C (48 years old) and C++ (35 years old), don't you think we would have done it by now? :-)
Re:"Rust does not have a stable ABI"
by dependenttypes on Friday August 14, 2020 @08:39AM
(#24157093)
No, people tend to be quick to create a new language in addition to lacking imagination and thinking that it is impossible to do in C.
Too quick to create a new language?! Rust was started in 2006 and announced in 2010. Its improvements are based on research done before and after C/C++ existed.
If you're the only person smart enough to solve the $64B problem so everyone can start writing safe and backwards compatible code in C/C++, please, go right ahead.
yes writing a mini-rust compiler in C is possible and you can write in the mini language. But the problem is: at what cost?
Re:"Rust does not have a stable ABI"
by dependenttypes on Friday August 14, 2020 @08:37AM
(#24157088)
This has nothing to do with what I am talking about.
2. No. If C/C++ could be made safe* Rust would not exist.
* everyone agrees on this point, including the richest and largest software companies on the planet