this post was submitted on 29 Jun 2024
87 points (93.1% liked)

Programming

17416 readers
73 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

Fullstack GUI library for web, desktop, mobile, and more. In Rust using a HTML + CSS renderer built on top of Servo.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 12 points 4 months ago

We've been using Leptos at work, which is a similar framework (and probably shares half the stack with Dioxus).

And yeah, it's really good. My favorite thing about using Rust for the UI is algebraic data types.
So, in Rust when you call a function which can fail, there isn't an exception being thrown, but rather you get a Result-type as return value.
This Result can either contain an Ok with the actual return value inside. Or it can contain an Err with an error message inside.
So, in your UI code, you just hand this Result all the way to your display code and there you either display the value or you display the error.

No more uninitialized variables, no more separate booleans to indicate that the variable is uninitialized, no more unreadable multi-line ternaries.
It just becomes so much simpler to load something from the backend and display it, which is kind of important in frontend code.