News for hackers. Stuff that matters.
Re:Immediate Mode GUI Programming by jbverschoor on Monday January 15, 2024 @05:49PM (#39007112)
Immediate mode is very common in game development. Super easy to reason about and debug.
Re:Immediate Mode GUI Programming by bartwr on Monday January 15, 2024 @08:39PM (#39008353)
I'm a former game dev and I used ImGui a lot and don't think it's used because those reasons.

It's used for quickly hacked debug tools to interleave UI and regular logic and not do a logic/view separation (as it would result in code bloat and a necessity for a refactor). You want UI code do some logic (like modifying properties of some game entity or renderer) and prefer to inline it. Lots of game code is effectively YOLO without even a single test. It's also typically guarded by IfDefs and compiled out of release versions.

But as soon as it stops being just hacky debuggers and people try to write proper tools in it, it becomes much more of a pain - people try to (poorly) emulate a retained mode in it, hold state, cache - and it becomes unreadable mess.

Re:Immediate Mode GUI Programming by 1ark on Tuesday January 16, 2024 @01:15AM (#39010039)
This is such a good and clear take.
Re:Immediate Mode GUI Programming by ocornut on Wednesday January 17, 2024 @06:48AM (#39026496)
> But as soon as it stops being just hacky debuggers and people try to write proper tools in it, it becomes much more of a pain - people try to (poorly) emulate a retained mode in it, hold state, cache - and it becomes unreadable mess.

Effectively people are hasty and don't spend the time to try doing things nicely, in particular because the first steps and debug use allow you to do quick things.

But I don't think it's a fundamental property of IMGUI or Dear ImGui that "proper tools" become particularly more of a pain. Of course it is more work to make a proper tools than hasty-debug-tools, and I can easily see how underengineering can back-fire (over-engineering it likewise).

Re:Immediate Mode GUI Programming by jheriko on Monday January 15, 2024 @07:24PM (#39007867)
i am a gamedev. i never encountered this until unity became popular, and even then it was always looked down on as a shitty and hacky approach to a well solved class of problem.

10 years after this, its still about the same... which is probably why an article like this has any controversy about it instead of being run-of-the-mill.

Re:Immediate Mode GUI Programming by TillE on Monday January 15, 2024 @07:28PM (#39007897)
Absolutely everyone (including the AAA studios) uses Dear ImGui for tools these days.

Retained mode is probably more common for user-facing GUIs, though.

Re:Immediate Mode GUI Programming by badsectoracula on Tuesday January 16, 2024 @01:30AM (#39010115)
> Absolutely everyone (including the AAA studios) uses Dear ImGui for tools these days.

I've been working in (mostly AAA) game engines and tools since the mid-2000s, largely in custom engines and i never encountered Dear Imgui, so i disagree with the "absolutely everyone". Pretty much every engine i've worked with (and didn't make myself) uses something like wxWidgets, Qt, MFC or some custom toolkit for the tools and custom stuff for in-game debugging (usually a console for keyboard use and some "page/screen" based reporting/lists/menus that are easy to navigate with a gamepad).

I do know that some game engines use it, but it isn't as universal as you think.

Re:Immediate Mode GUI Programming by flohofwoe on Tuesday January 16, 2024 @04:44AM (#39011399)
If you look at 'development screenshots' of games in the last 5 years where some sort of inhouse debugging UI is visible, it's almost guaranteed to be Dear ImGui.

Qt, WPF, wxWidgets etc... was a good option up until 2015 or so, but since then the least painful way for writing integrated debugging UIs and standalone inhouse UI tools is Dear ImGui.

Re:Immediate Mode GUI Programming by whstl on Tuesday January 16, 2024 @05:25AM (#39011670)
Same experience. IMO the keyword here is "integrated".

I'm showing my age here, but when game companies used to hire people to do tools, or leverage internal knowledge, it was often things like MFC in Windows... or the ones you mention. They would often run outside the game, often displaying lo-fi graphics.

The only "integrated" tool back in the day was a Quake-like console.

But eventually people started demanding tools that were more integrated, and immediate GUI was in the right place at the right time.

Re:Immediate Mode GUI Programming by low_tech_punk on Monday January 15, 2024 @10:15PM (#39009003)
I'm web dev recently introduced to game dev. I'm curious why the two worlds have such different approaches. Another example is ECS being more prevalent in games than in web apps.
Re:Immediate Mode GUI Programming by nox101 on Tuesday January 16, 2024 @01:42AM (#39010173)
because they're doing different things.

Web page: Wait for data from server, update page to match, this usually happens at most every few seconds. (or if it's server based) Fetch data, format into html, set to browser

Game: For 10s to 1000s of objects, run some code for each one at 60 frames a second. That code is usually one or more finite state machines and/or co-routines per object (or some hacked together code that effective does the same). This code updates a bunch of state for each object, and then other code displays the current state.

They're doing different things so they take different approaches.

PS: I get the above is over simplified.

Re:Immediate Mode GUI Programming by kragen on Tuesday January 16, 2024 @02:09AM (#39010330)
react is pretty common in web dev and it's immediate-mode

ecs is just watered-down in-ram relational databases, and relational databases are also pretty popular for web apps

Re:Immediate Mode GUI Programming by whstl on Tuesday January 16, 2024 @05:29AM (#39011690)
That's an interesting take I agree with. It's kinda interesting how lots of technologies are converging from totally different directions.

IMO there is also a few parallels between centralised event stores like Flux/Redux and ECS. Sure the data is organised completely differently (perhaps Flux can learn from ECS here) and updated differently (perhaps ECS can learn from Flux here) but the concept of centralising state is similar IMO.

Re:Immediate Mode GUI Programming by kragen on Tuesday January 16, 2024 @06:50AM (#39012248)
hmm, that's interesting!
Re:Immediate Mode GUI Programming by rtpg on Tuesday January 16, 2024 @08:02AM (#39012811)
I think react is not as immediate-mode as what you see in many immediate UI libs. In particular the canonical "let buttonPressed = drawButton("OK")", where your button state/press is actually reported back. In React events on your components have to flow back through some strategy.

This is either a nit or a completely fundamental difference that entirely changes the ask.

Immediate mode isn't _just_ about repeating the UI every frame

Re:Immediate Mode GUI Programming by kragen on Tuesday January 16, 2024 @08:13AM (#39012890)
this is a good point