Hacker News new | past | comments | ask | show | jobs | submit login
A New Architecture for a GUI Framework (gavinhoward.com)
7 points by gavinhoward 4 months ago | hide | past | favorite | 7 comments




Thank you for engaging with the core idea. You were the only one to do so. No one on Reddit did.


I recall you have written in favour of structured concurrency before. I'd be interested in your thoughts about how we can combine this with a GUI framework for something better than the status-quo. Most of the other frameworks out there run an event loop in the main thread and just fire-and-forget a new thread when they need to prevent the UI thread from blocking. It's a pretty dire state of affairs.

Try r/programminglanguages, usually get some decent discussions there.


The way I designed this is actually that the framework starts a thread in which the client runs, using blocking code from the framework.

Code would look like this:

    for (vwt = wy_vwt_create(); event = wy_event(); vwt = wy_vwt_freeze())
    {
      switch (event->type)
      {
        // Handle event types...
      }
    }
That `wy_event()` call is blocking, yes, because it waits for the next event, but that actually doesn't block the UI thread because the client event loop is not on the UI thread.

Behind the scenes, the framework would create several threads: one for the client, one for the UI, one for accessibility, etc.

The `wy_vwt_freeze()` is the call that would freeze the current VWT, but it would also send notifications to those other threads to do their thing, and they can work separately.

This also allows clients to handle events while the next frame is being rendered.

So the way to prevent the UI thread from being blocked is to just separate it from the event thread, something VWTs allow by construction.

And of course, I would create the threads under structured concurrency, but it's not the key part.

Does that make sense?


It's really amazing how nice it can be to use a system which one never has to wait on --- I was really hopeful of that when Apple bought NeXT and Rhapsody ran with an unbelievable crispness on modern hardware (which was to be expected, it was written for 25 MHz 68030 computers with 8 MB of RAM) --- it was incredibly disappointing when the Mac OS X Public Beta shipped and my 400MHz G4 iMac was about as performant as the NeXT Cube w/ 52MB RAM I had at home.


We can hope DonHopkins shows up with some relevant pie menu experience?


<fingers crossed>




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

Search: