Where Rust earns its place in a TypeScript application
Where Rust earns its place in a TypeScript application
I enjoy Rust, but “rewrite it in Rust” is rarely a useful architecture plan.
TypeScript is hard to beat for moving quickly through product code. The ecosystem is broad, the feedback loop is short and sharing types across a web application is convenient. Rust becomes interesting at the edges where the constraints change.
The boundary is the feature
Good candidates tend to have a narrow interface and one demanding responsibility: parsing untrusted input, talking to hardware, running a long-lived local process or doing work where memory use needs to stay predictable.
The Rust component should make the rest of the application simpler. If every product change requires editing a protocol and rebuilding three layers, the boundary is in the wrong place.
Errors need to cross cleanly
A Rust enum is not useful to a TypeScript caller unless its meaning survives serialization. I prefer a small error shape with a stable code, a human-readable message and optional details meant for diagnostics.
The important part is deciding which errors the caller can act on. “Model missing” can lead to an installation prompt. “Permission denied” can explain what setting needs attention. A generic internal error cannot.
Optimize after the seam is right
The first win is often not raw speed. It is having one process own a difficult responsibility with explicit inputs, outputs and limits. Performance work becomes much easier once that seam exists because it can be measured in isolation.
Sometimes the result is faster. More importantly, it is usually easier to reason about.
Use both languages for what they are good at
Rust does not replace TypeScript in my projects, and TypeScript does not need to imitate a systems language. A small, deliberate boundary lets both remain pleasant.
That is the point where Rust earns its maintenance cost for me.