My Authors
Read all threads
Here's a rant (opinion?) that I'll turn in to a blog post soon.

I think Rust should have a third ABI, not repr(C) or repr(Rust), and it should be used to slowly phase out the C ABI for a better one. Want to hear more of my unreasonable thoughts about ABIs? Read on.
First off: we should look at languages like Swift, Zig, Python, maybe even Go or C++, and find a better set of primitives to work with. I think there is a common set of features that wouldn't have everything, but would prevent falling back to the nuts and bolts of C.
Second: we shouldn't try to make the whole language follow this ABI. It should be relegated to API boundaries that are meant for FFI. This way we can keep language-specific optimizations in the normal case, and only pay a static ABI cost at the API surface area.
Third: the ABI should have the concept of semver baked in, or at least a monotonically increasing version number. It should be expected that this ABI increases regularly (1/months-years).
Third again: Compilers should be able to support emitting multiple different versions of this new ABI, based on a sliding window of version support. Linkers/Dynamic linkers should learn how to polyfill mismatched version numbers
Fourth: The ABI should encode some basic concept of ownership/lifetimes, even if the language only supports cloning/copying out of the borrow.
Fifth: The ABI should include the ability to encode information about types and layouts, not just function names. This should be used at compile/runtime to provide type information. Compilers should be able to import ABI libraries directly, or provide codegen tools to get headers
Sixth: The ABI should include a standard for enough introspection to at least get type and signature information for functions and data structures, both for the compiler and for humans. Ideally, you could include doc comments as a first class citizen as well.
Those are the things that come to mind first, and I'm sure all of these items exist in one form or another in a lot of different environments/runtimes! But these are all things that have bit me while trying to use Rust with other languages, and I think we can do better.
Missing some Tweet in this thread? You can try to force a refresh.

Keep Current with James Munns

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!