← Back to context

Comment by IshKebab

11 hours ago

> I prefer debugging C

I prefer not having to debug... I think most people would agree with that.

I prefer a billion dallars tax free, but here we are:(

  • In Rust dev, I haven't needed Valgrind or gdb in years, except some projects integrating C libraries.

    Probably kernel dev isn't as easy, but for application development Rust really shifts majority of problems from debugging to compile time.

    • My current project is C++ backend. I do a lot of debugging but all of it concerns business logic, some scientific calculations and the likes. In this situations having Rust will give me exactly zero benefits. As for "safety". I am a practical man and I pay my own money for development. Being able to use modern C++ I have forgotten when was the last time I had any memory related issue. My backends run for years serving many customers with no complaints in this department. Does not mean of course they're really really safe but I sleep well ;)

  • If it wasn't clear, I have to debug Rust code waaaay less than C, for two reasons:

    1. Memory safety - these can be some of the worst bugs to debug in C because they often break sane invariants that you use for debugging. Often they break the debugger entirely! A classic example is forgetting to return a value from a non-void function. That can trash your stack and end up causing all sorts of impossible behaviours in totally different parts of the code. Not fun to debug!

    2. Stronger type system - you get an "if it compiles it works" kind of experience (as in Haskell). Obviously that isn't always the case, but I can sometimes write several hundred lines of Rust and once it's compiling it works first time. I've had to suppress my natural "oh I must have forgotten to save everything or maybe incremental builds are broken or something" instinct when this happens.

    Net result is that I spend at least 10x less time in a debugger with Rust than I do with C.