How (not) to use unsafe code

We can probably get fairly close because, AFAIK, all the actix projects are essentially one author, and he frequents this forum as well :slight_smile:. I'm hesitating in cc'ing him because I'd rather this be an educational conversation, and not a unsafety witchhunt.

This instance is particularly interesting because actix is a non trivial project, and has had success in gaining users (with overwhelmingly raving reviews from their standpoint, from what I've seen). It's done well in performance benchmarks. The person(s) behind it clearly know what they're doing (leaving the unsafe stuff aside). And yet there's rampant unsafety.

Why was it difficult (or impossible? or what?) to write the same functionality in safe Rust? Is it a performance issue? Is it too difficult to design a complex app with constantly keeping borrowing in mind? Were these just initial shortcuts that were never removed later? Something else?

I think (a) figuring out why that is and (b) possibly addressing it is just as important for moving Rust forward as catering to Rust newcomers and other initiatives that, to one degree or another, have been questioned recently.

I don't know either, although I think we can all agree with some elements of what it would look like (implementation difficulties aside).

8 Likes