logoalt Hacker News

viktorcodetoday at 11:47 AM7 repliesview on HN

> We previously explored Swift, but the C++ interop never quite got there

But Rust doesn't have C++ interop at all?


Replies

nicoburnstoday at 11:55 AM

You can do it via the C ABI, and use opaque pointers to represent higher-level Rust/C++ concepts if you want to.

Firefox is a mixed C++ / Rust codebase with a relatively close coupling between Rust and C++ components in places (layout/dom/script are in C++ while style is in Rust, and a mix of WebRender (Rust) and Skia (C++) are used for rendering with C++ glue code)

show 1 reply
tonyedgecombetoday at 11:52 AM

>But Rust doesn't have C++ interop at all?

It also doesn't have the disadvantages of Swift. Once the promise of Swift/C++ interop is gone there isn't enough left to recommend it.

show 1 reply
woadwarrior01today at 12:42 PM

Yeah, that part doesn't make much sense to me. IMO, Swift has reasonably good C++ interop[1] and Swift's C interop has also significantly improved[2] since Swift 6.2.

[1]: https://www.swift.org/documentation/cxx-interop/

[2]: https://www.swift.org/blog/improving-usability-of-c-librarie...

azornathogrontoday at 12:29 PM

It may have in the future. Crubit is one effort in this direction: https://crubit.rs/

matthewkosarektoday at 12:56 PM

There is also cxx.rs, which is quite nice, albeit you have to struggle sending `std` types back and forth a bit

show 1 reply
the_mitsuhikotoday at 2:06 PM

Rust has cxx which I would argue is "good enough" for most use cases. At least all C++ use cases I have. Not perfect, but pretty damn reasonable.

k33ntoday at 11:48 AM

It's technically Rust -> C -> C++ as it stands right now