4 ms·
C is trivially upstream of everything. Rust is slightly less upstream of everything, in that you have to essentially go through C to do it. C is also very smal
by jvanderbot 2y ago
C is trivially upstream of everything. Rust is slightly less upstream of everything, in that you have to essentially go through C to do it.
C is also very small and easy to hold in your head, with minimal required dependencies, aside from standard system libraries. Rust typically pulls dozens of dependencies for even small libraries.
These are just tradeoffs. If I were going to build a small library to do something with libcurl, I might do C first then Rust for expanding if required. Same for specialized processing like rasters or computational geometry or even linear programming - all those are C already, and rarely do you find a perfect Rust crate that exposes everything you want.
And unsafe rust is definitely harder than just writing C. It often is easier to write it mostly in C then expose app/higher API level functions to Rust, rather than do the business logic in Rust.
- hollerith 2y agoYou can write Rust code with no dependencies (not even Rust's standard library) and coders do so regularly when writing code for microcontrollers. That is one of the primary advantages that distinguishes C and Rust from most languages (which tend to depend completely on a library to do automatic memory management for example). It is advantageous not only on constrained systems like microcontrollers, but also when interfacing with code written in one of the languages that has a hard dependency on a runtime library to manage memory.
- jvanderbot 2y agoOf course this is true with minor effort. I'm not doubting rusts benefits, I write rust full time for a reason. Just answering why sometimes C is first.
- flohofwoe 2y agoBut now you're (almost) back to basically carving out your personal language subset, which is also one of the biggest problems in the C++ ecosystem (it is possible to write 'sane C++', but everybody's sane subset looks slightly different, which massively fragments the library ecosystem and leads to endless frustrating and pointless discussions whether a library should make use of this or that language or stdlib feature).
- pjmlp 2y agoWell does one write ISO C, GCC C, clang C, AIX C, xyz C? It is the same issue as well.
- atiedebee 2y agoNot really, most C programs (especially libraries) are written in C89 or C99. GNU-C and all other dialects are generally reserved for when you write an application that won't be interfaced with through code.
- pjmlp 2y agoI guess we don't look at the same kind of examples, specially in the enterprise world.
- pjmlp 2y ago> C is also very small and easy to hold in your head Mostly true during K&R C days, without taking into consideration C compiler dialects outside UNIX V6. Already during 16 bit home computer days it was already flexible enough with compiler extensions all over the place, that most folks would fail a pub quiz on C. Even more so with C23 as current.