Hi everyone.
This is Linwei from SDK team. In the upcoming group session (8/3), I’d like to discuss about candid generation.
Context
Every canister should have a interface definition in Candid. For how do developers get the Candid, there are two approaches.
- Write the Candid by hand, then implement the canister to confront the interface.
- Implement the canister and let the CDK generate Candid definition automatically.
There are a few projects dealing with similar problem, e.g. Protobuf, Thrift, WIT. All of them provides the support for the first approach. But there is barely no official support for the second approach. Because the build tools of most programming languages are not flexible enough for the task.
Motoko CDK supports the second approach by default.
Rust CDK recently refreshed its support for the second approach. The feature was implemented in a hacky way. It defines an extra WASI entry point function which print out the Candid definition to stdout.
Users execute the WASI binary in wasmtime
to get the Candid.
Problem
Should SDK provides support for both approaches? Or one of them?
My thoughts
I gathered opinions from SDK teammates. We agree that the first approach is more viable for most programming languages. So for community contributed CDKs, the first approach is a must-have support.
Meanwhile, we are aware that supporting candid auto-generation would lower the barrier of onboarding new developers to IC ecosystem since learning a new IDL (Candid) won’t be required before writing canister code.
If it’s possible to support the second approach in some language, it’s great to have it. That’s a bonus CDK feature.
dfx
support?
dfx
can support the first approach naturally.
As mentioned before, Rust CDK export_candid
workflow requires wasmtime
. It’s controversial whether we should bundle a wasmtime
copy with dfx
.
Discuss in group session
We value community opinions. If you want to share your idea, please join the discussion in the upcoming group session (8/3).