3 ms·
You're missing high-level languages such as Modula-2 or Free Pascal that are safe-by-default while being close to the machine. They compile faster. They're easi
by nickpsecurity 9y ago
You're missing high-level languages such as Modula-2 or Free Pascal that are safe-by-default while being close to the machine. They compile faster. They're easier to analyze. Someone who understands C could easily port it to one of these languages or even write a translator that converts them to C for easy integration of incrementally-rewritten pieces of the OS. They don't because they like C for non-technical reasons or want to do one piece of tooling work over another.
Another you might find interesting in alternate history where C programmers adopt better tech is Cyclone that tried to stick to C as much as possible. Rust's safety scheme took a lot of inspiration from Cyclone.
https://en.wikipedia.org/wiki/Cyclone_(programming_language) https://en.wikipedia.org/wiki/Cyclone_(programming_language)
http://trevorjim.com/unfrozen-cyclone/ http://trevorjim.com/unfrozen-cyclone/
" There are excellent model checkers out there for C, and quite a few proof assistants are gaining the ability to check proofs on C code directly"
I agree. Further, just using Design-by-Contract with property-based and fuzz testing on those contracts would improve things by itself. There was also an academic who applied Frama-C to one of their smallest, battle-tested components in I think a string library. Although no coding flaw found, the exercise did show the documentation was incorrect. Gotta wonder what benefit might happen for less obvious stuff than string operations.
- nanolith 9y agoCyclone is an interesting example. Something that is backward-compatible with C and does not incur significant compile-time overhead, like C++ does, is a potential alternative. Unfortunately, Cyclone was abandoned. It only has support for 32-bit architectures, and it is not being actively maintained. One of the biggest reasons why C is so popular is that it works on practically every platform, even those that Cyclone, Modula-2, and Free Pascal do not. Of course, if OpenBSD eliminates support for a bunch of the platforms it currently supports, such alternative languages become viable. However, the OpenBSD team purposefully maintains these platforms because they expose errors that would otherwise be missed by a scaled-down release. Software errors missed in x86_64 or x86 may be picked up in MIPS or SPARC because of endianness. An alternative that I think is more tenable is a language that compiles to C. Such a language can piggy-back off of C's incredible market penetration while adding safety features. Barring some extensions to Cyclone, most of Cyclone's features, for instance, could be implemented as a source-source compiler that targets ANSI C99 or ANSI C11.
- nickpsecurity 9y agoThat's actually what I said here in my more thorough comment below plus some of other replies: https://lobste.rs/s/4cf21p/re_integrating_safe_languages_into#c_4ch7ug https://lobste.rs/s/4cf21p/re_integrating_safe_languages_int... Ill be replying to followups on that later tonight or in the morning. I totally agree it should be default. I'll go further to say it should have C datatypes/sizes, calling convention, FFI with little to no annotations required, and compile to C. Each check should be removable per midule with a compiler option, pragma per module, or equivalent keyword/operator marked unsafe . It also needs inline ASM. For its own advantages, add macros, safe linking, and a REPL with incremental compilation. That by itself would be better and faster to develop than with C with seemless integration with legacy codebases. Side benefit like in my Brute-Force Assurance method would be it benefiting from all tooling C ecosystem has to offer esp static analysis and certifying compiler. What you think on that?