1. 52

  2. 21

    C things I miss in Rust: fast compile times. 😉

    Edit: I really love Rust and what the Rust folks are doing and have accomplished. I haven’t even tried the new incremental compilation yet!

    1. 5

      For me, all the tooling for analysis. I still recommend high-security systems with skilled developers and a budget default on C subsets just cuz of all the tooling available.

    2. 6

      I do appreciate what C has done, but after playing with rust enough my first reaction to a lot of C stuff nowadays is “man this would be funner in Rust…”

      Postgres and CPython are both “very clean codebases” but so many things end up becoming preprocessor directives because C isn’t really up to the task of proper abstraction. I guess that C dev’ers consider the preprocessor to be part of the language though

      The major counterpoint being that I still have a hard time in Rust with “matrices of values” programming. Stuff like software blitting is so easy in C but ends up requiring proofs in Rust (or opting out of checks).

      EDIT: a good example of this that isn’t just “eww macros” is Postgres’ pg_list.h header (you can see it here). It is an implementation of “lists” almost entirely through macros. But really basic stuff.

      It leads to clean code but that implementation…

      1. 3

        so many things end up becoming preprocessor directives because C isn’t really up to the task of proper abstraction

        I agree, my C code (see here for an example) has macros as convenience for string handling and error handling.

        But I haven’t written enough C++ (or any Rust/Go) to know if that would change or not.

      2. 6

        As a (primarily) C programmer who has been eyeing Rust from a distance with some interest, the author makes a number of compelling points – but from what I’ve read elsewhere…

        No integer overflow

        Enough said.

        No, very much not enough said – if this is an issue you care about, this is a gross oversimplification. Such a description might be accurate for a language with automatic bignum-promotion, where integer overflow can be really said to (within the bounds of memory) actually not happen – Python, say. But the situation in Rust, while yes, probably preferable to the one in C in most ways, isn’t that simple.

        1. 2

          Yeah, it wasn’t obvious to me why that was ”enough said.” I use (unsigned) overflow on purpose quite a lot in audio programming.

          I think it’s nice how Swift made overflow trap, using regular arithmetic operators, but added versions prefixed with & to opt-out, e.g. &+.

          1. 4

            In case you didn’t check the article 1amzave linked:

            Rust has .wrapping_<op> methods for 2’s compliment arithmetic (and a few other variants, saturating, checked - which gives a handable error on overflow, overflowing - which wraps and tells you if it wrapped), as well as a Wrapping<T> type that makes the normal operators wrapping.

            It doesn’t have a fancy &+ syntax though, which is probably a good thing IMO given how rarely wrapping arithmetic is used in general.

            1. 1

              Yes, I didn’t know about those before coming here for the comments!

              &+ is not really special syntax in Swift though, since it allows user-defined operators, for better or worse.

          2. 2

            Rust panics on overflow by default, but provides functions that explicitly allow integer overflow wrapping, as well as functions for checked arithmetic and saturating arithmetic:


            This seems like the best of all approaches to me.

            1. 4

              Rust panics on overflow by default

              But not in release mode. (This has bitten me, painfully!) Worth being vigilant while coding in case your code might run into edge cases in production it doesn’t in test.

              1. 1

                Thanks for pointing that out! I somehow missed that important detail. I’ll have to keep that in mind!

          3. -2

            C does have generics. Or -fwrapv/-ftrapv.