Is there anything stopping Rust from taking bindgen in-tree and importing C modules during compilation automatically? I really like the Clang Importer in Swift...
-
Show this thread
-
Ah, I suppose the fact that this would encourage people to import unsafe code instead of intentionally creating safe abstractions on top. Though the Swift community has organically moved to "safe wrappers" in the interest of idiomaticity.
1 reply 0 retweets 0 likesShow this thread -
Replying to @harlanhaskins
From what I recall of the early rust-dev discussions about this, they didn't want to take Clang as a hard dependency. cc
@graydon_pub2 replies 0 retweets 1 like -
Replying to @jckarter @harlanhaskins
Certainly the dependency was a concern. Also bindgen .. generates text. Afaik it’s not integrated into constructing rust types, as the type checker sees them. At least I thought it wasn’t, long ago, maybe it’s grown in that direction or uses rust compiler libs more than I think.
2 replies 0 retweets 0 likes -
Replying to @graydon_pub @harlanhaskins
That's certainly a problem with the bindgen approach, that in order to generate text you need to have a textual representation of nearly every C feature in the destination language. Swift can use Clang's parser and codegen while selectively reflecting edgy features like bitfields
1 reply 0 retweets 0 likes -
Replying to @jckarter @harlanhaskins
Yeah, the Swift clang importer is amazing. I'd suggest copying it for Rust, except .. eh, only worry is that clang is very much not a pure function from C sources => ASTs. Interfacing with clang is a delicate dance, I think it brings a lot of impl. fragility.
2 replies 0 retweets 2 likes -
Some of that might just be the extensive amount of magic the Swift clang importer has decided to do along the way? idk. I suspect a Rust clang importer would probably err on the side of making the user do more work, and get uglier but simpler results.
1 reply 0 retweets 0 likes -
Replying to @graydon_pub @harlanhaskins
Yeah all the renaming and attribute-driven-swift-interface generation only really make sense with a cooperative first party SDK too
1 reply 0 retweets 1 like -
Replying to @jckarter @harlanhaskins
Yes, I think there is no way anyone but a platform owner able to coordinate across SDKs and toolchains could get to the level of transparent interop Swift has managed with Cocoa. It's sufficiently magic that people often don't *notice* it, which is the highest praise.
2 replies 0 retweets 0 likes
*whisper* XPCOM ;)
-
-
Replying to @pcwalton @graydon_pub and1 reply 0 retweets 0 likes
-
Firmly not swift/cocoa level integration though. That is crazyland (cc @Gankro)
1 reply 0 retweets 1 like - 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.