| > Rust does everything that C does while making programmer more productive. Look at what Linux Kernel hackers say about it. They are the ones who know things about C. Anybody can submit a patch to the Linux kernel (which is great of course). Any big names (long term kernel development) backing it? That said, kernel development has different constraints to userspace application development. For kernel drivers for example, sometimes you really are pulling absolutely every trick out of the book just to squeeze enough performance out. > Nobody said it will. But segfaults hardly come from poor design. They come from accidental mistakes, lack of static analysis, and gotchas that your language offers. Sure, but there are a few simple patterns when used throughout that are quite reliable. There are quite a few books out there on writing safe and reliable C. > > now it is harder to develop > Only if you're a C programmer who doesn't know Rust. Maybe, but I'm not yet sold that the added 'dance' you have to perform with Rust is worth excluding one type of bug. > > and runs slower > This is plan false. Please back it up. Every C program can theoretically [+] be compiled to be the same as a Rust binary, but not every Rust program could be compiled to be the same as a C binary [1]. > Try using it for a week, and count for me how many times it segfaults on your face. (That is not to diminish Grigory's work, which I have nothing against.) I use it quite regularly. Even more regularly I use C++, I simply program with it in the same way one would do using Java as pure OO and no raw pointer magic (except in rare, well tested cases). The less magic used, the more reusable your code will be in the future. [+] Not exactly, but close enough. [1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/... |
Linus Torvalds is one of them. And he is a hardcore C programmer, he was strongly against C++ in the Kernel when people were suggesting that.
> Sure, but there are a few simple patterns when used throughout that are quite reliable.
And yet, C/C++ programs segfault all the time. Memory corruption vulnerabilities are some of the most severe and common ones. There was a submission here, on HN, about it. There was something about Google adopting Rust on Android precisely because of this — in case you want to find it.
I've been a C (Kernel) programmer in the past. And I've quit precisely because it took too much of my time to debug things that a good language should normally detect for you. Now, my main languages are Rust and Haskell, and the compiler helps me eliminate a huge class of bugs. If it compiles, most of the time it works correctly.
> Every C program can theoretically [+] be compiled to be the same as a Rust binary, but not every Rust program could be compiled to be the same as a C binary [1].
What should I be looking for in [1]? And what do you mean here? "Theoretically", you could implement every possible C program in Assembly, but that's hardly an argument against C. We should be thinking here in terms of things that a programmer normally would implement in reasonable amount of time. A knowledgeable Rust programmer is by orders of magnitude more productive than a C programmer with the same experience.
The discussion we're having was already had many times here. I'm just repeating the standard arguments.
Rust also has more freedom to perform optimizations on your code than C, because Rust has so much more information about it. For example, in C, a carefully placed "restrict" keyword can speed up your program a lot. But if you're not careful enough and you fail to satisfy the "restrict" invariant, you get undefined behavior. In Rust, things are "restrict" by default due to borrow checker and the invariant is ensured in compile time.
The argument for C against Rust just doesn't stand a chance if you remember C's undefined behavior. C is full of it. Can you list all the conditions when it can occur in C?
> I use it quite regularly.
I meant using the OP program, not C language.