Hacker News new | past | comments | ask | show | jobs | submit login

Rust helps a lot with memory or concurrency issues. But not the rest. And in my experience, although the concurrency/memory issue are surely the most time consuming bugs, the "rest" is what takes 90% of the time...



There's more that it helps with. For one example Rust's Enums and richer types allow fewer mistakes -vs- confusion where pointers and integers degrade to a common type. A random line: https://github.com/torvalds/linux/blob/122fa8c588316aacafe7e...

> void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags)

These are valid due to poor type usage, but make no sense:

    crypto_aead_clear_flags(..., PAGE_SIZE)
    crypto_aead_clear_flags(..., EBUSY)
    crypto_aead_clear_flags(..., SOME_RANDOM_THING)
We can hope they would be caught in review if the code happens to do the right thing by accident, or use static analysis and hope it triggers in that case, or use a language with clearer types where it's much easier to use types preventing this issue.


You could the same with C++ or Ada, but naturally it will never be a thing in Linux.


Ada can do that, but C++ arguably makes things even worse than in C: apart from supporting a subset of C's misbehavior, it introduces implicit-by-default converting constructors. Those make API misuse very easy.


Experience in Apple and Microsoft platforms, among others, shows otherwise.

And for info, Android Treble drivers are mostly C++, although Java is also an option.

Ah and Fuchsia is a mix of C++ and Rust at it lower layers.


To each their own. I find Rust a huge step up from C and even C++...especially C++. I've been writing Rust for months and C++ for years. I still feel more comfortable and confident my Rust code has fewer bugs and does what I intend vs C++.


It should be noted that memory in cases where automatic memory management cannot be afforded, and concurrency only in what concerns in memory data structures.


Compared to plain C, you have ADTs which help from day to day programming. You can bring them to C (https://github.com/Hirrolot/datatype99) but I don't know if the Linux guys would allow it.


I would say that 90% of the bugs are just logic issues, but there is a heavy tail of devious bugs that will take 90% of the time, even if they don't surface right away.

Although I still haven't really played around with Rust yet myself (still trying to grok the new C++20 features in recent weeks), the fact it puts your code into a (sometimes admittedly annoying) sandbox to prevent these bugs could be a godsend.


In general I find I'm productive in Rust; however, I do agree that there are some features that produce more confusion and debugging than others. For me it seems to be async and dynamic dispatch that are tricky.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: