XSUI updates, and also grug

Created 8/19/2025, 3:32:04 PM; Last modified 3/24/2026, 12:38:29 AM

1. XSUI Updates

As I said in my last blog post[a] I've been working on a UI framework called XSUI. I've worked on a bit over the last week. Mostly, I've been transitioning it to an immediate-mode approach. Previously, when I started writing it, I had mostly used retained-mode UI frameworks, and so that's what I based my library off of. Then I looked more into different ways to design UI, and I found immediate mode style UI frameworks, which to me seem a lot more flexible and easy to use.

1.1. Simple Setup

I haven't added too much in terms of actual /features/ yet (completely changing the public API of a library is a lot of work, actually) but I have added a nice QoL improvement: simple setup.

[a] my last blog post

Before, you had to manually initialize your backend and a lot of XSTD stuff before even being able to use XSUI (example below with SDL2):

But for simple GUI apps, you probably don't actually need this much control over the initialization process, so it's kind of just boilerplate setup code. I decided to add a simple initialization mode that offers an interface somewhat like Processing[b]:

This is much simpler and reduces the amount of boilerplate you need to place, at the cost of some control. This is most useful for GUI apps; games will most likely still want to initialize manually.

[b] Processing

You can, of course, still get your backend's underlying renderer by calling `xsui_state_get_ctx(ui)` and then using a backend-specific function to cast that to a renderer to be used with your backend.

1.2. Immediate Mode

Now looks like this:

At first this doesn't look too different; the difference is that if we want to change the second UI, we can just call different functions on the next `draw()` call, then we just let XSUI modify the tree for us. If we wanted to change the first, we'd have to carefully manipulate the UI tree and keep references to all the frames we want to manipulate.

Using immediate mode does have some drawbacks, however. I am going to have to sacrifice some of the design goals of having XSUI be "user-modifiable". I think I'm still going to try to keep some of that philosophy but it's going to be a lot harder when even the structure of the UI is defined in code. I think I have a solution to this, but it's going to take some tweaking to get right, and it's probably a far-off goal.

2. grug: An interesting little modding language/framework

Recently, I discovered grug[c], an interesting little modding language. I recommend you watch Trez's youtube video about it, but in short it's a modding language that tries to be as simple and as easy to integrate as possible. To this end, the language supports a very small amount of types, and directly integrates with C function calls with very little binding necessary.

[c] grug

One of the notable things about grug is its complete lack of builtin collection types; games are expected to provide their own collections to grug instead. This generally simplifies the language and implementation a lot and makes memory ownership much simpler. It also makes binding simpler as you don't need to convert between types from the host language and types from the mod language.

Another interesting design decision is that all public API functions and types (grug is statically typed) are specified in a single `mod_api.json`, which is easily parseable and can be used to generate documentation.

I've been contributing a bit to the language and proposing ideas. In addition, I've been writing some documentation for the language too (but it's currently heavily WIP). I also have a game I'm working on (that I'll announce once it's in a playable state) that I might try to add grug modding support to.

Groups

Blog

Writings

Proxied content from gemini://zipsegv.net/blog/2.gmi (external content)

Gemini request details:

Original URL
gemini://zipsegv.net/blog/2.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.