docs: multi-language component guide — TinyGo, AssemblyScript, Rust
README: add language comparison table in contributing section, explain AI writing quality differences and why TinyGo is recommended for official components. CONTRIBUTING: full rewrite with separate TinyGo + AssemblyScript sections, each with AI prompt templates, code templates, build commands, and test commands. Rust documented as supported with basic setup reference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -240,9 +240,20 @@ acr parts scaffold gmail
|
||||
|
||||
### 貢獻零件
|
||||
|
||||
零件是 TinyGo 編譯的 `.wasm` 檔案,stdin 進 JSON、stdout 出 JSON,就這樣。
|
||||
零件是 `.wasm` 檔案,stdin 進 JSON、stdout 出 JSON。用什麼語言編譯不重要,只要輸出符合 WASI preview1 的 `.wasm` 即可。
|
||||
|
||||
**AI 可以直接幫你寫零件。** 把 API 文件和 [CONTRIBUTING.md](CONTRIBUTING.md) 一起貼給它,它生成 `main.go` 和 `component.contract.yaml`,你編譯、測試、提交:
|
||||
**arcrun 的零件主要由 AI 撰寫。** 這個設計決定影響了語言選擇:
|
||||
|
||||
| 語言 | 輸出大小 | AI 撰寫品質 | 學習曲線 | 備註 |
|
||||
|------|---------|------------|---------|------|
|
||||
| **TinyGo** | 極小(10–80KB) | 優秀 | 低(Go 語法簡單) | 官方零件首選;語法與 TS 差異夠大,AI 不易混淆 |
|
||||
| **AssemblyScript** | 小(20–150KB) | 良好 | 低(TypeScript 語法) | 社群貢獻首選;TS 開發者上手最快 |
|
||||
| **Rust** | 小–中(30–300KB) | 良好 | 高(Rust 所有權) | 效能最強;適合複雜演算法零件 |
|
||||
| C / C++ | 小 | 尚可 | 高 | 不建議,現代語言更好 |
|
||||
|
||||
**注意:** AssemblyScript 與 TypeScript 語法高度相似,AI 有時會把純 TS 邏輯直接搬過來造成編譯錯誤。TinyGo 語法差異夠大,AI 出錯率較低。初期如果不確定選哪個,TinyGo 是最穩的選擇。
|
||||
|
||||
**AI 可以直接幫你寫零件。** 把 API 文件和 [CONTRIBUTING.md](CONTRIBUTING.md) 一起貼給它,指定語言(TinyGo 或 AssemblyScript),它生成源碼和 `component.contract.yaml`,你編譯、測試、提交:
|
||||
|
||||
```bash
|
||||
acr parts publish ./my-component/
|
||||
|
||||
Reference in New Issue
Block a user