bytecodealliance / cargo-component

A Cargo subcommand for creating WebAssembly components based on the component model proposal.
Apache License 2.0
488 stars 56 forks source link

Consider reverting `--reactor` to `--lib` #198

Closed vwkd closed 10 months ago

vwkd commented 1 year ago

It seems as part of the large refactor in #101 the --lib flag was also renamed to --reactor. What's the reason for this change?

The term "reactor" suggests a component can somehow "react"? The term is commonly associated with reactive programming but it seems that's not what it should mean here.

The README admits the need to explain it means a library.

A reactor component [..] is meant to be used as a library.

It somewhat makes sense if calling the component's exported functions makes it "react". But in that sense, a command component similarly "reacts" to its run function being called.

Is there a strong reason to replace the existing term "library" that's widely used across languages and ecosystems with a new term "reactor" which might be confused with an unrelated meaning? Why not call a library a library?

esoterra commented 1 year ago

This distinction goes back to the idea of reactors vs commands going back to here or potentially earlier.

peterhuene commented 1 year ago

In addition to aligning with component model terms, the intention behind the change was to make a distinction between a "normal" Rust lib package (one that compiles to an .rlib) that can be linked into any other package and a component "reactor" package (one that compiles to a .wasm) that cannot be statically linked by the Rust tooling.

However, cargo component new doesn't create lib packages and certainly reactor is perhaps needlessly introducing jargon that might be confusing to folks.

If there's general consensus that --lib makes sense, I'm happy to add it back as an alias to --reactor.

tomasol commented 10 months ago

I am also in favor of the --lib switch, as it a more common term. When I see reactor I think of the reactive design pattern.

pchickey commented 10 months ago

I forgot about this but seeing it bumped into my notifs now, and having sat with this for a little while I'm also in favor of changing it to --lib, because it is more familiar Rust terminology. Familiarity lowers the barrier for Rust developers to discover and use components, exposing them to less of the particularities and special terms as part of their initial journey is a good thing.

Understanding that a cargo component lib means component model reactor is something easy enough to learn later on if they become more sophisticated users, and using --lib doesnt shut us out of expressing anything else we currently anticipate this tool should do.