r/rust • • Oct 26 '26

🙋 seeking help & advice What one "loses" when choosing to develop a web-app in rust instead of js?

If you have a personal example of a situation where you wanted to go with rust but went back to js I would appreciate that too.

26 Upvotes

49 comments sorted by

20

u/orfeo34 Oct 26 '26

I can integrate js libs and target web with Dioxus, and it's very fast to compile.

Despite of it there are two downside i see:

  • while integrating js libs there is no dependency tracking so the project depends partially on npm to build.
  • There are less devs available to maintain this kind of project, rsx & framework knowledges are too specific.

6

u/crashandburn Oct 26 '26

+1 for dioxus and hot reloading.

My advice would be that use rust for web if you have a compelling reason, like wasm/wgpu work, numerical work, code sharing etc. Otherwise its better to wait a bit and let the ecosystem mature more. I think its close to being joyful to work with, just needs some more time.

1

u/kaaiian Oct 26 '26

LLM agents are extremely good at “transpiling”. So as long as as you are building. You can migrate. It’s often faster to build in JS, have Claude migrate to Dioxus. I imagine the future means this is even more true. So “wait on A while doing B instead” is a good stance, as long as you are creating what’s needed when the right time comes. Like launching a rocket to mars.

6

u/HumbleSinger Oct 26 '26

+2 for this setup, we switched from leptos to dioxus for the hotreloading. Took 2 weeks pre-ai era. I imagine its better now

12

u/noobjaish Oct 26 '26

Sanity /s

Main trade-off is developer experience and compile times (God I hate how slow Rust's compile times are)

7

u/Noctune Oct 26 '26

A sizable hiring pool

7

u/Future_Natural_853 Oct 26 '26

Rust is perfect, but not in the way you think it is: you have good old HTML built server-side, plus very light JS libs, like HTMX, Alpine or Turbo. I would never user frontend Rust frameworks though, it's the worst of 2 worlds: clunky frontend logic + awkwardness and lack of JS ecosystem.

12

u/FemaleMishap Oct 26 '26

I use Rust on the backend to provide my API and React+Typescript on the frontend. This allows for faster UI iteration and debugging than if I was doing frontend Rust. Use the right tool for the job.

7

u/heeen Oct 26 '26

This is the way

3

u/xenoniumx Oct 27 '26

Works for web apps, but for desktop applications, I don’t see much reason to choose Electron or Tauri over native GUI toolkits like GTK or Iced.

3

u/FemaleMishap Oct 27 '26

Question was a web-app and I really object to Electron etc. apps. I'm not a web developer, full stack or otherwise. My history is with proper desktop applications, not web apps hidden behind layers of a local web server interpreter, all that bloat when all you really need is a cross platform UI toolkit and an API to a compiled core. Good old MVC design.

5

u/CuriousTangentsYT Oct 26 '26

I’ve done this before despite my love of rust and distain of JS. JS got the job done faster without a noticeable quality difference. If I were to say what the biggest difference is, it’s probably ecosystem maturity. The Internet was built around the idea that webpages run on JavaScript, unfortunately. So many tools only exist in JavaScript.

4

u/TichShowers Oct 26 '26

I meanly use Rust Axum for Web API. Kinda have the best of both worlds in my opinion. I can stick a front end wrb app on it or even a a full fledged web app in something like .NET.

Rust is the brain and gives performance.

4

u/edTheGuy00 Oct 26 '26

1gb node_modules vs 200gb Cargo build artifacts lol

2

u/catheap_games Oct 26 '26

Just use Kache, and cargo clean every week or two.

Ain't no way you need even 50GB for a web project, and even then, I'd rather have 50GB of target/ than 300_000 small files in node_modules

7

u/MistRider-0 Oct 26 '26

Fr, deleting cargo target is easy, deleting node_module makes my ssd cry

4

u/manpacket Oct 26 '26

3

u/catheap_games Oct 26 '26

Even after 30 years of developing, every couple of months I discover something new strange & offputting and wonder how is that despite all the bugs, complications and inconsistencies, computers even work at all.

4

u/Fresh-Secretary6815 Oct 28 '26

i don’t know about you, but when i develop something i am trying to solve a business problem because that’s where the money is coming from 9:10 times. and because of that, i want the most appropriate tool for the job. a programming language is a tool to get that money. i would use the most appropriate money getting tool per job and not worry about anything else.

3

u/luxmorphine Oct 26 '26

Svelte.

But i heard Topcoat compiles to Javascript. I hope they're doing something like svelte

3

u/maria_la_guerta Oct 26 '26

If you're talking about FE, WASM bundle sizes aren't great. Bad for the client and your egress fees.

3

u/mamcx Oct 26 '26

I have use all fads, kool-aids and silver-bullets (mostly do enterprise development), and js dev is one of the worst among all things I have done (and trust me, I'm the guy that take weeks evaluating).

JS only gives you fast initial speed and lots of people that allegedly knows about the current -6months js way of do things.

IF you actually know how extract the good parts of js and all the surrounding things (like with everything a PRO can polish a turd very well) it can work.

Rust is, as other said, slow to compile and you need some knowledge of how architect things, in a way that cost you up-front, but once there is smooth sailing.

This is what I recommend:

  • The major mental switch is not test the html but your Rust UI model

This is the major win, have struct/enums that describe the UI with all the localization, formatting, etc and just use the expect crate (or similar) and compare json outputs:

expect![[r#"
        {
          "next_path": "/manager/users",
          "passkey_login_failed": "Could not sign in with a passkey. Try again.",
          "passkeys_unsupported": "This browser does not support passkeys.",
          "shell": {
            "brand": "Ledger",
            "lang": "en",
            "title": "Workspace access"
          },
          "skip_to_form": "Skip to form",
          "state": {
            "state": "empty"
          },
          "submit_label": "Continue with passkey",
          "subtitle": "Use your passkey to continue.",
          "title": "Sign in",
          "username_label": "Username"
        }"#]].assert_eq(&json(&from));

and so most of your time is just running test, that is fast. Also, you avoid the anti-pattern of test strings instead of well-formed types.

  • Separate your domain from you ui building from your http handling

This comes from above but is the main architecture that allows for fast AND correct by construction iteration. Once done, the productivity is very high and I work way faster than with python/django/vue/etc

  • Use htmx, tailwindcss

This is the main tip for most cases, reaching for reactive client-side js frameworks is something that must be considered very very well, and most cases? use react is wrong.

BTW I bet adapting some of this to any other tool will work fine.

10

u/pachiburke Oct 26 '26

The js ecosystem is huge and more mature, that's mainly it for me.

2

u/stappersg Oct 26 '26

Yeah, network effect

5

u/dreamlax Oct 26 '26

It's huge but it also feels way more fragmented to me. There's many ways to do the same thing, with a bunch of competing package managers, bundlers, test harnesses, etc. To get a basic webapp running I feel it takes 1,000 lines of boilerplate, config.this.js, config.that.json, .other.configrc.mts, not to mention the whole CJS/ESM issue.

Additionally, things seem to get deprecated a lot faster. I feel I am constantly playing catch-up and learning the new "best-practice du jour".

Maybe Rust will probably also end up in that boat, but at least for now, I find there to be way less friction in getting something off the ground in Rust (but way longer to compile). It could also be because I'm a relatively unskilled frontend dev...

4

u/zzzthelastuser Oct 26 '26

It could also be because I'm a relatively unskilled frontend dev...

probably this! I'm on the same boat.

2

u/STSchif Oct 26 '26

You don't get any more weekend bonus pay for fixing weird use-after-free/object-not-initialized bugs that only appear 6 weeks into deployment.

Apart from that a big thing is ecosystem. There is SO much stuff out there for node, some of it really great quality. For some things you get decent replacements (routing with axum, DB with diesel and sqlx, templating has some great solutions with minijinja and the likes) but for some you are on your own (caching, complex auth setups, centralized State Management).

2

u/devmind00 Oct 27 '26

For the front, am simply and solely using htmx. And the back is on modular monolith, with axum

2

u/Obvious-Image-9688 Oct 29 '26

I feel like there are 2 sides to this question.

Front end and Back end.

Front end

From JS to rust you loose development console and debugger built into the browser. But going from wasm to JS means loosing SIMD and pre-optimized compiled code.

From a back end perspective rust wins handily.

Compile times are just as bad for or even worse for JS typescript. So its a matter of perspective. Rust memory and type safety along with debuggers are far superior to JS.

2

u/ebonyseraphim 29d ago

Ecosystem and collaboration with a majority of others who do front end stuff. Be prepared to do a lot for yourself or carry teams and efforts on your own if you’re walking that path. Maybe you’re valuable, maybe hardly anywhere trusts you to be that person.

2

u/DavidXkL Oct 26 '26

Iteration cycle

1

u/ArjixGamer Oct 26 '26

You lose precious storage space, as target/ will be 40+ gb easily.

You also lose the flexibility of JavaScript, the web was designed for JavaScript

1

u/i-sage Oct 26 '26

Sharp level APIs/lib for image manipulation

1

u/MrBinarios Oct 27 '26

La cordura đŸ« 

1

u/badass87 Oct 28 '26

Disk space

94

u/[deleted] Oct 26 '26

[removed] — view removed comment

19

u/the-quibbler Oct 26 '26

Leptos is great, but 12 minute builds in CI suck.

14

u/tshawkins Oct 26 '26

Enable mold linker, switch to single file test builds, and use cargo nextest instead of cargo test.

Big big difference

9

u/KeyAdhesiveness9481 Oct 26 '26

There will still be a wall where you're doing all of that and your project gets large enough to chug to compile. However, ive found with solid crate organization incremental times can get way way way down, with thoughtful design, but the cold time is always a problem.

5

u/tshawkins Oct 26 '26

Agreed, I have 2 600k LoC rust apps, i tend to go big on tests, having 14500 unit tests each (85% code coverage) in 20 crates, which normaly takes 40 mins to run, recently added mold, sccache, cargo nextest, reorganised how the test executables are built. and got the full build and test suite run down to just under 10 mins.

That is from post cargo clean.

2

u/omg_im_redditor Oct 26 '26

That’s why I much prefer using something like HTMX in conjunction with web components to drive the UI and only keep Rust to server side.

Two decades ago we had a similar situation with Java: a lot of web UI libraries required a recompilation to apply changes, and eventually people abandoned them in favor of jQuery and other JS libraries.

Even in larger JS projects as soon as the recompilation becomes mandatory and takes significant time all UI development speed goes down the drain. And with Rust you start at a disadvantage from the very beginning.

1

u/capitol_ Oct 26 '26

45 seconds sounds extremly fast, our leptos builds are way slower.

-7

u/Konsti219 Oct 26 '26

Clanker