Hacker News new | ask | show | jobs
by pcwalton 3886 days ago
> Most of the cases where I run into this problem and end up feeling like I didn't gain much, if anything, from doing a straight C implementation are situations with deeply nested data structures.

Your feeling doesn't line up with what has been observed in practice. Empirically, people do not get the memory management right in C. They mess up, again and again and again. In Rust, however, the compiler enforces that you get it right.

> Though immediately following that I start to have dream-like fantasies where this entire static analysis stage is simply bolted onto C instead of being a whole new language.

I don't think it's really possible to bolt Rust's semantics onto C. Too much will break: in particular C code is not written with inherited mutability, which is critical to Rust. You could maybe do something like the proposed lifetime stuff in C++, which still requires lots of annotation, enough to effectively be a whole new language.

Rust has a lot better ergonomics anyway.

> Afterall you can do some pretty impressive stuff with nothing but a pile of preprocessor macros (see Objective C).

Objective-C isn't "a pile of preprocessor macros", and it would be completely impossible to implement the lifetime system using the preprocessor.

1 comments

The first versions of Objective-C were most definitely implemented as pre-processors to C compilation.
That's not the same as using the C preprocessor to implement the language.