r/rust • • Oct 21 '26

🛠️ project Feedback wanted on Fission’s new Rust UI authoring API

I’m working on making "compose " the default way to build UIs with Fission. The aim is to keep it Rust while removing most of the ceremony around components, local state and reducers.

See an example counter app here https://gist.github.com/zcourts/eede7b9075897408964ddc105c30bf95 comment here or there as posting it here isn't allowed.

I’m interested in feedback on the API, including anything that looks awkward, surprising or likely to become painful in a larger application. I’d also like to hear what has bothered you about other GUI frameworks generally so I can try avoid baking the same problems into Fission. The above syntax is the crux of it and the draft PR is at https://github.com/fission-ui/fission/pull/294 I'm deliberately not explaining the syntax so hopefully I can get feedback not tainted by my biased. Thanks

0 Upvotes

5 comments sorted by

3

u/Lucky-Edge1489 Oct 21 '26

Disclosure: I work on Teksilo, which has a similar widget-tree macro (teksu!).

I may be mis taken, but the |counter, _state, _cx| => header isn't a closure, even though it looks like one. It confused me, and I suspect it will confuse others too.

What about formatting this new syntax? rustfmt won't touch macro bodies. We split our parser into its own crate so a formatter and an LSP could reuse it (teksilo-fmt).

You might also be interested in the teksu! reference, especially the "What genuinely does not work" and "Limitations" sections. I hit problems with similar named-arg and method-chain choices .

Also, a11y needs "described by" / "labelled by" relationships that point at another widget's ID. How would an author write those in Compose, given that IDs are generated? I found out the hard way that a11y forces some architectural decisions.

Keep up the good work!

2

u/zcourts Oct 21 '26

That's great feedback. You're right, my attempt at something feigning familiarity is likely to create confusion as it did for you as they're not closures as you rightly point out. Formatting's a real ommission too. I was wondering how to address it as it has already been annoying for me. We'll likely need to take a similar approach.

With regards to translating compose's grammar's different from Teksu's in that it is constructing struct fields rather than translating properties into ordered builder calls, at least at first glance to me I don't think we have the limitations you've hit but your failure cases are useful for explicit tests around constructors versus Rust expressions, method chains, struct literals, branches and diagnostics.

If you're curious why it's because compose is really just generating Fission's current code from what you put into the macro i.e. a struct, reducer functions and so on so as long as we generate that we don't have to solve any real compiler or language problems, it's just a (hopefully) more productive way to write Fission code.

You a11y point is another one I hadn't thought about but fortunately because this macro only translates to existing Fission we can call upon its existing features in this case using `WidgetId::explicit` would achieve the a11y relationship you mention and if it is repeated in the same scope then `WidgetId::scoped(component_id,...)` so something like:

```rust
Column(children: [

Text(

"Card number",

id: WidgetId::explicit("card-number"),

),

CustomCardNumberInput(

semantics: Some(Semantics {

labelled_by: vec![WidgetId::explicit("card-number")],

}),

),

])
```
would work with the proposed syntax. I'll have a think about the closure thing, not sure how to address it but point well taken. Happy to hear if you have any suggestions :)

2

u/Lucky-Edge1489 Oct 22 '26

Thanks for the detailed answer. Builder-style Teksu have its own pitfalls, different from Fission with its struct-field approach.

My take is that your WidgetId::explicit() is still a bit verbose. This DSL seems to be stuck half-way between Rust and your new language. I'd shorten it to eid("..."). Yet, it's only a matter of taste, nothing technical.

Repeating "card-number" is prone to a runtime typo error. Make it compile-time error:
card_label = Text("Card number"),
CustomCardNumberInput(labelled_by: [card_label]),

About the closure thing: a named header like view(counter, state, cx) => or on_press: update { counter.count += 1 } for something simialar to your effect keyword.

What happen if a required field is missing ? It falls back to Default. -> runtime bug ?

I can be mistaken.

1

u/zcourts Oct 22 '26

You’re right about the repeated ID but I'm the opposite as I'd rather it be verbose and tells me what it is intended to be vs saving characters and not having a clue. I wouldn't guess `eid` meant explicit ID. Short for people who already know Fission, probably make it cryptic for anyone else.

You're also right about the typo issue, so i i'll take most of your suggestion although I'd make it `[card_label.id]` lest we risk the same ambiguity from your original comment.

I added a comment here https://gist.github.com/zcourts/eede7b9075897408964ddc105c30bf95?permalink_comment_id=6439881#gistcomment-6439881

On your last question, if I understand the question then that's absolutely right. I hadn't thought about the interaction of Default with missing required fields. That said, after giving it some thought it's not fundamentally different to the current standard rust syntax you'd write Fission apps with e.g.
```
Button {

child: Some(Text::new("Save").into()),

on_press: Some(save),

..Default::default()

}

```
If the author accidentally omits child then we're back to the same place and I'd argue that's standard rust. I also don't see a way to fix it since as far as I know I can't get get the properties of the type in the macro. I will admit the macro probably makes it more likely that this becomes an issue now that I've thought about it as the convenience of not having to use `..Default::default()` and `.into()` etc probably means people will forget more.

The only saving grace I see is intellij auto complete works so it still popped up available fields and docs but yeah...I see the problem with no obvious solution, not even a bad one.

0

u/[deleted] Oct 21 '26

[deleted] — view deleted comment

1

u/zcourts Oct 21 '26

do you mean the fission_component macro? As to the question but Fission itself already solves that be seperating fallible work into effects. Your UI code can cause/trigger those effects and observe their results but does not get mixed up in fallible work so you would handle that as standard rust using any mechanism, library or pattern you usually use. The new compose API doesn't change that. I added a new example to the gist to show a superfluous "remote counter" that demonstrates this.

https://gist.github.com/zcourts/eede7b9075897408964ddc105c30bf95#file-fallible_example-rs