5 ms·
We chose to use Rust instead of TypeScript for the front end of https://github.com/tangramdotdev/tangram https://github.com/tangramdotdev/tangram. This allows
by nitsky 5y ago
We chose to use Rust instead of TypeScript for the front end of https://github.com/tangramdotdev/tangram https://github.com/tangramdotdev/tangram.
This allows us to:
* Share code with our server written in Rust.
* Avoid keeping types in TypeScript in sync with Rust.
* Do server rendering without including a JavaScript runtime.
* Avoid maintaining a JS stack, including TypeScript, Prettier, ESLint, and a bundler.
Because we split our project into many crates, incremental build times are about 1-2 seconds on a linux desktop. This is not as convenient for quick iteration on UI/UX as hot reload with React, but on the other hand, code that type checks is more likely to run correctly.
Overall, I would say that the trade offs are not clear, even for our unique case where we have a server written in Rust.
I am hopeful that in the future, browsers will enable native DOM access from WASM, and the Rust compiler will support code splitting between multiple WASM entrypoints. When this happens, I think there will be a strong case to recommend Rust for more front end projects.
- nitsky 5y agoI should add that we wrote a crate called pinwheel that uses futures-signals for fine-grained reactivity, uses the builder pattern to avoid macros entirely, and supports server rendering: https://github.com/tangramdotdev/pinwheel https://github.com/tangramdotdev/pinwheel
- da39a3ee 5y ago> Avoid keeping types in TypeScript in sync with Rust. Out of curiosity, did you try auto-generating the typescript types from the Rust types?
- nitsky 5y agots-rs did not exist at the time. Perhaps if it did, we would have chosen differently. Generating types with “cargo test” feels very hacky though.
- skohan 5y agoYeah the build times were a killer for me. I did a small project with rust->wasm in the front-end, and this was a bit painful compared to a standard react workflow. It would be really nice if this could be improved in the future.