Thank you for the review.
other than the odd puffery about it being the most amazing thing ever
Noted. I understand that can be off putting.
it positions this as FFI, that is, to interoperate with other languages, without actually showing any other languages
I think of C ABI as the serialization format of FFI. When we write a JSON serializer in Rust, we don't talk about how another language will deserialize it. CO3 helps Rust communicate with the language boundary through C stable ABI regardless of who's listening on the other side.
However, your complaint is not missed and I think a solution can be implemented on top of CO3 that would connect a language of your choice with Rust. This is something to explore in the future.
If you're going to have a bunch of magic rules to make it easier to talk to C safely,
I'd say that you're being a bit too dismissive here. Any sufficiently advanced technology is seen as magic. There are really good reasons why syntax looks the way it does inside ffi!. One of the design goals was to make it look just like regular Rust but describing FFI required some extensions. I was really careful to make every extension follow the aesthetic of the Rust language.
I'm actually in the process writing another article to specifically address the "magic" syntax. I think this introductory article is too overwhelming.
it better be really clear and obvious what the C side looks like (especially when in many FFI situations you won't actually have control of the C interface)
If Rust talking to itself over the ABI boundary through CO3 there should be no issues. The declarations will match because you write them only once inside one ffi! block that is used on both export or import. This was another one of the design goals that API of your library should look the same whether you link to it as rlib or cdylib. The idea is that you write your crate in Rust and the FFI glue is generated directly out of that, no additional work required. CO3 gets you quite far, but some differences just cannot be abstracted away. This use-case is like really safe.
If Rust is talking to an existing C library then yes, you are responsible to correctly describe the FFI declarations. The other major design goal was that you should be able to explicitly describe any existing FFI boundary, but obviously this is much more dangerous because safety is predicated on programmer's responsibility; it is not entirely compiler asserted. Having said this, my intention is to provide a checker tool that compares output of CO3 extern declarations with an existing C header to catch such dangerous declaration mistakes.
FFI is inherently exceedingly unsafe due to lifetimes, thread safety and many other very important details are only documented
FFI is indeed inherently unsafe and many things just can't be encoded in the type system. CO3 should generally reject lifetime flowing from one fn arg into another unless you explicitly opt-into. The rule is that, by default, any pointer is considered valid only for the duration of the fn call.
Although I mention the conditions under which CO3 provides safety I should emphasize it more. I do think CO3 helps with safety and readability a lot
I'll need to see something more convincing that it is actually desirable in a real FFI situation
I really appreciate you taking the time for writing the critique and I'd love to get an opportunity to convince you further. In the article I mention the work on rs-odbc which might be an interesting dive in. Also, I actually went around some no-name crates I could find and opened PRs to transition them to CO3. This helped me catch some new FFI idioms that CO3 didn't support but now does.