wit-bindgen icon indicating copy to clipboard operation
wit-bindgen copied to clipboard

Rename crate folders

Open esoterra opened this issue 3 years ago • 4 comments

One thing I've noticed that is a "gotcha" for people exploring and using wit-bindgen is that it doesn't consistently use the guest/host terminology throughout its crate folders and names. This means that people are often confused when they try to figure out whether the code they're looking for is in gen-rust or gen-wasmtime because both generate Rust code and the user intends to use Wasmtime.

Proposal

Rename the crate folders to follow a consistent naming scheme that makes guest/host more clear.

Guest and Host Bindings Generators

Normalize all folder names for guest and host binding generators to

  • Guest: gen-<lang>-guest
  • Host: gen-<lang>-host-<embedding>

For example:

  • gen-c-guest formerly gen-c
  • gen-rust-guest formerly gen-rust-wasm
  • gen-rust-host-wasmtime formerly gen-wasmtime
  • gen-py-host-wasmtime formerly gen-wasmtime-py
  • gen-js-host-?? formerly gen-js (definitely open to suggestions for what to call this embedding)

Other notes:

  • Give gen-rust a suffix e.g. -utils or -lib that indicates that it's a library for generators but not really a generator itself
  • gen-markdown doesn't have guest / host semantics, so it can stay as it is without a guest or host suffix.
  • I'm honestly not familiar enough with the SpiderMonkey generator to classify how it should fit in this taxonomy, maybe someone has an idea of where it fits or it needs to be an exception.

Rust Public Crate Folders

Rename the crates for use in Rust by our end users to follow a similar naming scheme to the generators

  • rust-guest formerly rust-wasm
  • rust-guest-macro formerly rust-wasm-impl
  • rust-host-wasmtime formerly wasmtime
  • rust-host-wasmtime-macro formerly wasmtime-impl

Other Folders

  • Potentially rename gen-core to bindgen-core so that it doesn't fit in the above convention as a "thing that generates core" (which will also conveniently sort it at the top of folder views)
  • Potentially rename parser to wit-parser for clarity

Wrap up

I've worked in some areas of wit-bindgen but not as much or at all in others, so if I categorize something incorrectly here definitely let me know and I'll update the proposal. I'll put together a PR tomorrow based on feedback so that we can get a sense of what it would look like. Thanks!

esoterra avatar Jun 15 '22 15:06 esoterra

Alternatively, it might be worth asking whether the mode (guest/host) is more important than the language (rust/c/py/etc.). If it is than it may make sense to name them gen-guest-c, gen-guest-rust, gen-host-wasmtime-rust, etc.

Additionally, I think whatever choice we make here should eventually be applied to the CLI commands/args, but I think that should be a separate issue and PR that comes in after this one is resolved. e.g. wit-bindgen host wasmtime rust, wit-bindgen guest c

esoterra avatar Jun 16 '22 17:06 esoterra

Renaming sounds like a great idea to me and at least personally I don't have much of a preference which precise naming scheme is chosen. I'm happy to defer to others for this!

alexcrichton avatar Jun 17 '22 18:06 alexcrichton

It would be great to also consider renaming wit-bindgen CLI arguments.

wit-bindgen rust guest -i exports.wit
wit-bindgen rust host wasmtime -e exports.wit
wit-bindgen c host wasmtime -e exports.wit
wit-bindgen python host wasmtime -e exports.wit

Maybe this is too verbose to type out but it is more explict and clear. I don't have a preference of naming scheme either. Totally fine with the proposal!

Mossaka avatar Jun 24 '22 17:06 Mossaka

I'm in favor of listing guest/host before the language, e.g. wit-bindgen guest c

I am also pro parser to wit-parser now that we're discussing parsing profile syntax.

ricochet avatar Jun 30 '22 19:06 ricochet

I believe this is now done, so closing.

alexcrichton avatar Sep 01 '22 19:09 alexcrichton