[HN Gopher] ImHUI: Imgui-style library for the web using actual ...
___________________________________________________________________
ImHUI: Imgui-style library for the web using actual HTML output
Author : ingve
Score : 73 points
Date : 2021-03-03 14:40 UTC (8 hours ago)
(HTM) web link (games.greggman.com)
(TXT) w3m dump (games.greggman.com)
| hencq wrote:
| If I understand immediate mode GUIs correctly, you basically
| redraw the UI every iteration of your (game) loop. How does that
| work in this case? Do you call these functions in a loop? Does it
| automatically remove the dom nodes at the end of every loop
| iteration? That seems quite wasteful, so I doubt that's what
| happens, but I'm curious to how it actually works.
| mschuetz wrote:
| Not sure how they actually work but I can imagine that it's not
| that bad in OpenGL, DirectX, Vulkan, etc. You can just fill a
| preallocated buffer with a certain capacity with the right data
| on the fly and send it to the GPU in one swoop. Should be fine
| for a couple of thousand of elements, as long as you don't
| invoke OpenGL commands for each individual elements, but only
| for the buffer containing all elements.
|
| For html, it's probably much tougher since the DOM is statefull
| and fares badly with frame-wise changes to it. That might
| require caching elements to avoid layout invalidation and
| rebuilding the dom.
| [deleted]
| shrimpx wrote:
| It can work much like React does, using dom diffing. You can
| run to collect virtual dom, diff, and update only what changed.
| boguscoder wrote:
| Russian speaking segment of HN will be delighted
| c-smile wrote:
| Just for those who don't know Russian: the name can be read as
| "I'm the dick".
| FpUser wrote:
| Dick is somewhat softer word then the one implied.
| c-smile wrote:
| Used that word as I am writing from Canada - country of
| liberals and democrats.
|
| More strong connotations of that word are from vocabulary
| of our southern republican neighbor. Pronunciation is
| usually accompanied by trumpets and other pompous
| instruments :)
| tomjakubowski wrote:
| And to painfully spell it out, you have to code switch to
| read it that way: I[']m in English, then HUI as a
| transliteration of khui.
| malkia wrote:
| Bulgarian too :)
| d33 wrote:
| https://en.wiktionary.org/wiki/Reconstruction:Proto-
| Slavic/x...
| malkia wrote:
| OMG! - Ok so "chuvat" (watch attentively in other slavic
| languages) seems related to "chuvam" (e.g. "listening
| attentively" in bulgarian). thank you!
| blondin wrote:
| imgui tends to get much love around here. i have to say, the most
| interesting aspect of the swift language ecosystem for me is
| swiftui. they really nailed declarative ui. the web should really
| steal that model.
| The_rationalist wrote:
| Stencil, angular, vue with the class api are all delightfully
| declarative through decorators
| yakubin wrote:
| I've heard opinions that SwiftUI is inspired by React.
| mumphster wrote:
| Have you used react at all? Check out react + rxjs for a
| similar experience, add some typescript on top and it becomes
| even better!
| beaconstudios wrote:
| I love rxjs but I wouldn't call it user friendly. It's
| essentially a text encoding of data flow programming and
| requires a totally different mental model to react. The
| explicit coding of time is great, but for most reactive js
| code react's own logic is simpler and more idiomatic.
| mumphster wrote:
| For sure, dont mean to argue that point at all. I'm just
| saying the interface of swiftui is very much observables +
| a react like component setup, its pretty neat to see
| something like that coming from Apple
| kall wrote:
| I am enjoying browsing though the code of this. The way the
| author abstracts HTML elements has some appeal.
|
| I'm not convinced this has a benefit over React et al. You could
| even render react 60 times per second and use only plain values
| not state if you think that will be beneficial. Virtual DOM and
| the incredible computing power in our devices will make it work.
|
| I have never worked with real immediate mode gui toolkits though,
| so I may be missing something nice, e.g. about that sequential
| declaration style? Or that it feels even less taxing to reason
| about than react?
| sosuke wrote:
| It reminds me of Visual Basic. I had fun creating front-end GUIs
| for batch files and Quake. I even had my program on PlanetQuake!
| Under the inspired name of "Quake Loader" I think. They gave me a
| little HTML I could put in the site. I even used VBScript to
| install the Quake font on Windows computers. Oh the things kids
| do.
| schwartzworld wrote:
| The library looks interesting, but the author's React code shows
| he doesn't have much experience using it. React provides a
| `useEffect` hook that lets you watch a value outside the react
| tree and update your components when it changes (or vice versa).
|
| Once a value is passed down as props, you get all that reactivity
| for free.
| ianhanschen wrote:
| Never expected the retained vs immediate mode debate to pop up in
| this way, but neat.
___________________________________________________________________
(page generated 2021-03-03 23:01 UTC)