Prefer Rust over C / C ++ for new code

2019-02-07



  • When to use Rust
  • When not to use Rust
  • When to use C / C ++
  • False reasons for using C / C ++
  • Appendix: my story with C / C ++
  • Application: chorus


This is a position paper that I originally circulated within the firmware community at X. I received requests for a public link, so I cleaned up the article and posted it on the blog. This is obviously my personal opinion. Please read everything before sending me angry letters.



TL; DR: C / C ++ has enough design flaws and alternative development tools are already in pretty good shape, so I don't recommend using C / C ++ for new development except in special circumstances. For situations where you really need the power of C / C ++, use Rust instead . In other situations, you shouldn't use C / C ++ anyway - use something else.



When to use Rust



, , , , ( 30 ) C C++. , , (buffer overflows), (dangling pointers), (race conditions), (integer overflows) .



: , , C. , , .



C/C++, , :



  • .
  • .
  • , .
  • , .


Rust , . , , C.



( โ€ฆ , .)



Rust 2013 . 2018 ^1^ , , , . C++11 2011 , Rust , C++11 GCC . - .



2018? " " (, ), Rust (nightly Rust toolchain). 2018 .



. , , C++ Rust. , , . Rust , .



Rust



Rust , C/C++, Rust , , C/C++. , . 2019 ; . Rust , .



: (symbolic algebra evaluator), (concurrent persistent data structure) - , , , , - โ€” , - , Rust. C++, , Rust, . Swift^2^, Go, Typescript, Python Kotlin/Java โ€” .



, , Swift , , , .



C/C++



, C/C++:



  • , , - . , Arduino. .



  • . , , Ada, , C.



  • Rust. Rust , LLVM, , GCC. , , 68HC11 68000. (Rust MSP430, Cortex-M .., AVR ). , , . IBM System 390.



  • , / (toolchain) . , - Rust. , - GCC, CodeSourcery.



  • , , rustc , , rustc . Rustc , GCC. , . C++; Rust , GCC.



  • C++, C++ , API (, extern "C", (pipes) RPC). C++ , . (Swift, , .) - "".





C/C++



, , .



C/C++ 30+ , /.



, . .



C C++ , C, , , , .



Rust , , Swift C++ (Clang). , C/C++.



C/C++, .



โ€ฆ . C/C++ , , , . , C++, , . , (UB). , Rust.



, C/C++ , , . , , .



Rust , .



C , , , Rust ( ). , , , Learning Rust With Allly Too Many Linked Lists.



C/C++ , , / SMP . Rust.



; , C++ , , Rust . โ€” , .



: C/C++



, C++ , . , .



C 1993 , C++ 2002 , . , Google, Qt, Chrome, , . Loon, C++ ( 99); C++11 ( 2011 ), , . , X C++, C .



Loon " " C++ crt0.o Cortex-M, ; . C++, Rust- . C++ โ€ฆ , , . "" ().



: , , C++ , . C++ , .



:



. :-)



(Chris Palmer): State of Software Security 2019: ( )



C++ โ€ฆ , โ€ฆ , C++.

(Alex Gaynor) The Internet Has a Huge C/C++ Problem and Developers Don't Want to Deal With It ( Vice, ):



. , Windows Firefox . , , , . , , .

( .)



Manish Goregaokar Mozilla, ycombinator fuzzing Rust Firefox , C++ , :



, . Rust .

fuzzing Rust firefox, โ€ฆ ( / ยซยป ). , Gecko .

Copyright 2011-2019 Cliff L. Biffle โ€” Contact




All Articles