You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learn/migration-guides/typescript-to-rust/index.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,11 +66,11 @@ Your background with TypeScript's type system is a real advantage. You already t
66
66
The main tradeoff you'll notice immediately is that Rust has stronger compile-time guarantees but [slower compile times](/blog/tips-for-faster-rust-compile-times/).
67
67
Most developers find this worthwhile because the borrow checker catches so many issues that would otherwise surface in production.
68
68
69
-
{% podcast_quote(id="080f1fca", slug="roc-with-richard-feldman", player="s05e04-roc?t=45:10", attribution="Richard Feldman, Creator of Roc") %}
69
+
{% podcast_quote(player="s05e04-roc?t=45:10", attribution="Richard Feldman, Creator of Roc") %}
70
70
"I certainly think that the degree to which compile times bother you would depend, sort of obviously, on what you're used to and what you think of as sort of possible or normal. Like if I'm used to Elm and sub-second recompiles and stuff like that, then yeah, I mean, it's going to bother me when I'm waiting 10 seconds to be able to build my thing or to run my tests."
71
71
{% end %}
72
72
73
-
{% podcast_quote(id="34099980", slug="zoo-with-jessie-frazelle", player="s03e05-zoo?t=40:33", attribution="Jessie Frazelle, CEO of Zoo") %}
73
+
{% podcast_quote(player="s03e05-zoo?t=40:33", attribution="Jessie Frazelle, CEO of Zoo") %}
74
74
"Writing Rust is so much more natural to me that even TypeScript is hard for me to write. I\'m just looking for a match statement, or things where I want to abort a Promise. In Tokio you can abort an async operation; you can\'t do that in TypeScript. That drives me nuts."
75
75
{% end %}
76
76
@@ -344,7 +344,7 @@ As mentioned, for backend web services, Tokio is the standard choice. It's multi
344
344
345
345
Rust enforces stronger guarantees than TypeScript through its ownership system and borrow checker. Most developers need a few months to get comfortable with the ownership model and will go through a phase of ["fighting the borrow checker"](https://www.youtube.com/watch?v=ZNFdkTIzdXM). This is normal and temporary. Once it clicks, it becomes one of the things you'll miss most when you go back to other languages. (This and the amazing compiler error messages.) There are ways to [flatten Rust's learning curve](/blog/flattening-rusts-learning-curve/) that can help you get there faster.
{% podcast_quote(player="s04e06-1password?t=53:08", attribution="Andrew Burkhart, Senior Rust Engineer at 1Password") %}
348
348
"I had never touched memory coming from TypeScript. I could not get through the Rust code at first, but luckily they hired me anyway. Everything I know about Rust I\'ve learned in the last three years. It\'s definitely something you can pick up. The hardest thing to get from zero to productive isn\'t the syntax: good Rust requires a bit of engineering knowledge the book doesn\'t always cover."
349
349
{% end %}
350
350
@@ -411,7 +411,7 @@ You won't deal with `null` or `undefined` errors, but you will end up modeling a
411
411
412
412
NPM gives you more packages, but Rust's ecosystem is of excellent quality and growing rapidly.
{% podcast_quote(player="s05e08-radar?t=08:55", attribution="Jeff Kao, Staff Engineer at Radar") %}
415
415
"Rust really feels modern. There\'s a rich cargo crate ecosystem, a formatter, flame graphs, and the paradigms are very functional, but you\'re not forced to use them. Having a rich data structure ecosystem in the standard library, being able to process vectors with all the functions that many developers are used to these days, really felt refreshing. Especially for a team with largely a background in TypeScript."
416
416
{% end %}
417
417
@@ -560,13 +560,13 @@ This gives you a clean separation and lets you migrate gradually.
560
560
561
561
A common pattern is a Rust backend with a TypeScript frontend connected through a typed API layer. The [`ts-rs`](https://github.com/Aleph-Alpha/ts-rs) crate can automatically generate TypeScript types from your Rust types, giving you closed-loop type safety across both sides with almost no extra work:
{% podcast_quote(player="s02e02-amp?t=48:58", attribution="Carter Schultz, Robotics Architect at AMP") %}
564
564
"We have a Rust backend and TypeScript frontend. There\'s an amazing crate, `ts-rs`, that for any Rust types you define will generate TypeScript types for them, so you have closed-loop type safety between them. We end up using `serde_json` to serialize a Rust type, send it to the frontend, and the frontend uses `ts-rs` to get TypeScript types for it. We have closed-loop type safety across both applications for practically free. It was so easy to set up."
565
565
{% end %}
566
566
567
567
Oxide Computer takes this further with a fully generated API layer: their server framework [Dropshot](https://github.com/oxidecomputer/dropshot) generates an OpenAPI spec directly from Rust endpoint definitions, which then drives a TypeScript client generator. No need to write or maintain API definitions by hand:
568
568
569
-
{% podcast_quote(id="97aa1056", slug="oxide-s-steve-klabnik", player="s03e03-oxide?t=1:23:42", attribution="Steve Klabnik, Author and Software Engineer at Oxide Computer") %}
569
+
{% podcast_quote(player="s03e03-oxide?t=1:23:42", attribution="Steve Klabnik, Author and Software Engineer at Oxide Computer") %}
570
570
"I write my server-side definition, say \'please generate stuff and regenerate the client in TypeScript,\' and when I switch back to my TypeScript file it gives me a type error if I\'m not passing something correctly. I get full type safety the whole way up through the stack. We\'ve been very happy with TypeScript. It\'s a pragmatic decision to engage with that ecosystem deeply, and it\'s been very, very nice."
0 commit comments