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

> there are generally only a few dozen rectangles

Only in a hello world application. Every professional editor like GIMP has tons of tiny widgets. And redrawing one tiny widget on mouse over is faster than running the render function.

Also, you are assuming that running render function costs nothing while in real-world apps there will be layout calculations (because you don't want to position widgets manually), array iteration (for example, to display a sum and average of values from a 100K element array), text characters layout, calling helper functions, generating SVG for a 10K points graph, some genius might add reading from a file, etc.

Yes, writing good code is harder than bad code, especially for a LLM.

And if you are on the stage where you need widgets and layout calculation, why not add a dirty flag and damage rectangles as well, I cannot understand.

 help



You say I'm talking about a hello-world application, but I'm talking about Firefox, Emacs, and my window manager. Firefox has 10 tabs visible, 21 icons in the toolbar, five bookmarks, and about 20 HTML elements. This still adds up to a few dozen rectangles, not thousands or even hundreds.

You say I'm assuming that the render function costs nothing. I thought it was clear that I was not assuming that; what I said in the comment that you're responding to is, "The amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor." But you may have responded before I added that; I forget if I added it in later. Here by "drawable" I mean talking about things like letters, not widgets that have their own render functions. Widgets that have their own render functions can take more than four orders of magnitude more time than the per-pixel work before the per-widget work becomes the dominant factor.

It's true, as you say, that people are capable of using up that margin by doing things like reading from a file, because writing good code is harder than writing bad code. But that's not really a question of immediate-mode vs. retained-mode. You can write bad code with retained-mode GUI libraries, too. In fact, my experience is that it's much harder to write good code with retained-mode GUI libraries.

As for layout calculations, the layout engine I elicited from Opus 5.5 for http://canonical.org/~kragen/sw/megilloom-sandbox lays out 60,000 lines of text per second, in JavaScript, and it supports table layout. (It caches the layout calculations so that it can remain responsive up to hundreds of thousands of lines.)

Some IMGUI libraries are capable of providing a dirty flag and damage rectangles without requiring every application to duplicate the error-prone cache-invalidation logic to do that. As Raph points out in this post, they're not a panacea. But they're not as bad as you are naïvely assuming them to be.


> the error-prone cache-invalidation logic

Because writing good code is harder than bad code.

Let me give an example. I vide-coded a program that renders white and gray frames and it can do it faster than 60fps on one core in a VM with no GPU. However, VS Code in that VM feels like it is running at 5 fps. The scrolling is slow and laggy. Why is that so? Probably because writing good code is harder. And probably they were thinking like you, that redrawing the whole screen is fast enough except in fact it is not.

Every time someone says that their framework is fast, they should test it in a VM without a GPU.


Generally speaking, what distinguishes good code from bad code is that it minimizes the number of error-prone things that must be done. As Frank Borman said, "A superior pilot uses his superior judgment to avoid situations which require the use of his superior skill."

I think VS Code is slow because it's a piece of shit, not because it uses an IMGUI library. I don't think it does use an IMGUI library; I think it uses src/vs/base/browser/ui which is all retained-mode.

VS Code runs in Node, which is fundamentally mostly a single-event-loop system, and in general it's very difficult for large single-event-loop systems to be reliably responsive, because literally any loop, anywhere in the system, that runs for too many iterations, will cause it to start janking. That's a problem with browser apps, too. Erlang-style actor systems have a much better chance, but they can still run into unexpected head-of-line blocking problems.

I have some experimental designs for software transactional memory systems which I hope will solve this problem...


I agree we need to minimize programming errors - by designing a good reactive retained mode framework.



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

Search: