Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are there any popular implementations of immediate mode GUI for the web? It might be interesting to have one that could then "eject" into a stateful UI for when things start to get more complicated.


I think that React is like 90% of the way there and you would just need to mess around with the VDOM a bit for this.

To be honest, given that web render output is a tree instead of flat "render to screen" stuff, writing a nice immediate mode GUI is not obvious.

If you're... very clever you could take React and the State stuff, at least conceptually, and get what you want here.


wouldn't you need some sort of gpu access to have a smooth UI rendering with immediate gui(in production)?


This is if you expect to build an immediate mode with the same flat rendering model.

imgui's model is "you draw onto pixels". You could create another mental model which is "you draw onto a tree." so instead of saying "drawText(x, y, text)" you would do something like "drawText(domLocation, text)"

Granted, this model gets a bit messier, and _some_ might say defeats the purpose of immediate mode. But I think you could still get conciseness benefits on this.


I wrote a UI framework called Concur which is very similar to immediate mode UIs and hence very easy to use, but also scales fantastically well to complex UIs. The original code was written in Haskell (https://github.com/ajnsit/concur), and then ported to Purescript (https://github.com/ajnsit/purescript-concur), and even Javascript (https://github.com/ajnsit/concur-js).

There's an introduction/tutorial here - https://github.com/ajnsit/concur-documentation/blob/master/R...


It looks like we've discovered the same approach in parallel. I even wrote a haskell version first, https://github.com/jhp/sneathlane-haste and then a js version using generators https://github.com/jhp/imperative

Sneathlane is a little different because it outputs to canvas and has a rather complex Widget type to handle focus and to allow different outputs to work together, but the Monad instance has the same behavior of waiting for widget completion. Imperative leans more on the DOM, it has its own VDOM implementation where yours looks to use React's but otherwise the libraries look very similar.

I'm a web developer, I've worked with everything from FRP to React, I think this approach is the best. I hope Concur will help to popularize it! I'm writing this on my commute but will be looking into this further today, to see if there's anything in Imperative that might enrich Concur or vice versa.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: