Hacker News new | ask | show | jobs
by cletus 2759 days ago
You should think of Rust as a better systems language, a better C. This was something that Go was pitched as but as a GC language it just doesn't fit a bunch of systems applications.

What I think is driving Rust and will continue to drive Rust is how it compares to C/C++ in certain key areas:

- Ownership is enforced at compile time. C++ obviously has smart pointers now (ie std::unique_ptr and std::shared_ptr) but these come with not insignificant runtime cost. What's more you end up passing around raw pointers anyway at least some of the time.

- C/C++ do suffer from and will continue to suffer from memory corruption, buffer overruns and undefined behaviour resulting from this. This has been and will continue to be the source of security vulnerabilities.

- Security is becoming so important and software so large and complex that the need for memory safety without sacrificing runtime speed will become increasingly important.

I honestly see a point where there'll be a need for a safe OS that is written in Rust or something like it.

One other thing about Web development: I think this is one area where Rust offers no real benefits (other than memory safety). Honestly I think the best model for serving HTTP requests is the cooperative multitasking model used by Hack (FB's PHP successor) where everything the request uses and does is created and torn down within the scope of a single request. This is a model that's far easier to reason about.

I came from years of doing Java where we had to deal with full GC pauses (something Go isn't immune to either).

1 comments

You should think of Rust as a better systems language, a better C.

I think C++ is a more apt comparison. C is such a barebones language. Yes, it's very unsafe and Rust goes a long way to fix those issues, but Rust brings a lot of other features along with it which dial the language complexity up to 11.

I would like to see a simple language that fixes C's biggest problems. I think that would be really interesting to work with. Nobody seems to want to do it though, or if they have, they haven't been able to get any attention.

One of C's big problems is that it doesn't provide many efficient abstractions, and fixing that problem will lead you to something which is not like C for the same reasons Rust is not like C.
I agree that Rust is more like C++, especially since C++11, than it is like C. Rust has type deduction, closures, iterators, and Traits (which behave a lot like C++ class methods).

> I would like to see a simple language that fixes C's biggest problems. I think that would be really interesting to work with. Nobody seems to want to do it though, or if they have, they haven't been able to get any attention.

Honest question from an embedded C developer who's learning Rust, but still very beginner:

Wouldn't using a subset of Rust provide the same thing you're asking for?

> Nobody seems to want to do it though, or if they have, they haven't been able to get any attention.

Cyclone, Safe C, Checked C, static analyzers deliver with the compiler, ...

The problem is on the receiving end, some devs won't change no matter what.

So far Android and Solaris (SPARC) seem to be the only platforms with memory validation compilation turned on.

Have you seen Zig?
No. I'm checking it out now. Sounds pretty amazing!