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

One positive side of immediate mode is that the code becomes a lot more straight forward. You only see that loop function, so it's very nice if you need a POC, or if it's going to be ran on embedded.


Here's some pseudocode for argument's sake: http://paste.debian.net/1317369

I don't think the immediate-mode code is really more straightforward. Retained mode looks just as simple and only has that one same function with the same 5 basic SLoC, only

- (A) the ui library has to do less work at runtime, resulting in a more responsive app (as per parent comment);

- (B) i was forced to reorder the component instantiation. In immediate mode, the counter's label depends on the button's state, whereas in retained mode, the button update callback depends on the counter instead; and

- (C) immediate mode only needed one sprintf instead of two since the initialization and update logic is unified. You can combine them in retained mode with a helper function or closure (and in real-world apps you would); in this trivial case this increases the SLoC but in real-world cases it reduces it.




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

Search: