4 ms·
Half a century since Pascal. Forty years since Ada. 28 years since Java. Fifteen years since Go. Ten years since Rust. And still unsafe code is in the majority
by Animats 2y ago
Half a century since Pascal. Forty years since Ada. 28 years since Java.
Fifteen years since Go. Ten years since Rust. And still unsafe code is in the majority.
- mpweiher 2y agoWell, that tells us something...
- tiffanyh 2y agoDoesn't libc interface requirement of C/C++ use, create massive downstream challenges for other languages to gain super mass adoption (at the OS level).
- sanxiyn 2y agoYes, but Linux (hence Android) doesn't have that problem, because its interface is system call not libc.
- tiffanyh 2y agoBut don't syscalls require C/C++ data structures & type definitions. So while not technically "requiring" C/C++, if your language cannot map exactly to C/C++ data structs & type definitions - it won't work.
- nineteen999 2y agoYes.That's a problem for the contenders, Linux/UNIX kernel are written in C. Unless we want to add language-specific syscall interfaces for every compiled language out there. Alternative is to, y'know, write a kernel in your language of choice and choose your own syscall specification suiting that language, and gain mass adoption. Easy!
- saagarjha 2y agoThe practical interface for Android is Binder, which has an interface that can be made amendable to a richer language.
- deleted 2y ago[deleted]
- MBCook 2y agoIs it? If you add up all the JavaScript, C#, Java, Python, and PHP being written every year, that’s a lot of code. Are we sure that all that combined isn’t more than C/C++? Or at least somewhat close?
- cyberax 2y agoNeither Pascal nor Ada are memory-safe.
- docandrew 2y agoIt’s possible to write unsafe code in either but it’s also much easier to write safe code in both Pascal and Ada than C/C++. And it’s easier to write safe code in C++ than C. Memory safety exists in a spectrum, it’s not all or nothing.
- pjmlp 2y agoMore than C or C++ will ever be. It is like complaining a bullet vest doesn't protect against heavy machine gun bullets.
- cyberax 2y agoNot really. Standard Pascal's dynamic features were barely present, but even they allowed dangling references to exist. And all practical Pascal clones (e.g. Object Pascal) had to grow constructor/destructor systems to cleanup the memory on de-allocation (or they went the garbage collection route). So they were on-par with C++ for safety. Ada is similar. It provided safety only for static allocations with bounds known at the compile-time. Their version of safe dynamic allocations basically borrowed Rust's borrow checker: https://blog.adacore.com/using-pointers-in-spark https://blog.adacore.com/using-pointers-in-spark
- pjmlp 2y agoNo one used Standard Pascal, just like everyone embraces their Compiler C extensions and many of them are blissfully unaware their code fails to compiler under strict ISO C conformance mode. We are beyond Ada 83, Controlled Types and SPARK exist, and Rust also does runtime bounds checking, so what.
- wmf 2y agoYou can't really write a library in Java or Go that a C program can use. The real magic is memory safety without GC and a huge runtime. But if you point that out people will call you a fanboy.
- archargelod 2y agoAm I missing something or can I just write such library in a language with RAII or ARC (Nim, Swift) memory management? I don't understand why Rust people believe Rust is the only option.
- wmf 2y agoRust isn't literally the only option but it seems to be the only mainstream option.
- pjmlp 2y ago60 years since NEWP/ESPOL/JOVIAL. ESPOL is one of the first recorded uses of unsafe code blocks, 1961.