sourcenetwork / defradb

DefraDB is a Peer-to-Peer Edge Database. It's the core data storage system for the Source Network Ecosystem, built with IPFS/IPLD, LibP2P, CRDTs, and Semantic web3 properties.
120 stars 32 forks source link

[Epic] Rust in Defra #868

Open AndrewSisley opened 1 year ago

AndrewSisley commented 1 year ago

A ticket to note down any notable thoughts/findings when thinking about migrating from Golang to Rust, as I've had this thought a few times and am duplicating effort by not writing stuff down and then re-researching/thinking it.

Notes:

orpheuslummis commented 1 year ago

Can you please clarify what you mean by "Rust from Go" and "Go from Rust"?

fredcarle commented 1 year ago

Go from Rust is very difficult and poorly documented

and

Rust has far better language inter-op, should make it much much easier to write defra wrappers in other langs.

seem contradictory. Am I getting this wrong?

AndrewSisley commented 1 year ago

Can you please clarify what you mean by "Rust from Go" and "Go from Rust"?

Calling Go from Rust, and calling Rust from Go

... seem contradictory. Am I getting this wrong?

It is only contradictory if you ignore the many other languages out there, calling Rust from most languages is far easier than calling Go (and calling out from Rust)

EDIT: To expand, I consider Golang's inter-op roughly on par with the JVM (totally crap), whereas Rust is just a bit behind C's (about as good as it gets), with most other compiled langs falling between the two (never tried calling into an interpreted lang, so I can't comment on those)

orpheuslummis commented 1 year ago

Any ideas for a minimal POC, a first step of Rust integration?

AndrewSisley commented 1 year ago

Any ideas for a minimal POC, a first step of Rust integration?

You'd really want to minimize the number of calls between the two langs, so a minimal POC could still be quite large. Would probably introduce Rust at the bottom and only have Go=>Rust calls (as that is easier and makes more sense IMO), but then it takes ages to get the build/inter-op benefits, and you'll likely hit the difficult issues RE using datastores etc.

The gql generate package might be the easiest, but would have the least gains too (dont really care about performance there, or interop atm).

Would be quite a tricky thing to do, but it is very nice that it is getting my head somewhat more focused on the interop side of things