tags:

views:

141

answers:

1

Hello all,

Since a few months I've been learning Erlang, and now it was time to do some basic GUI.

After some quick research I saw there was an interesting library called 'wxi' (based on Fudgets of Haskell) which uses a different approach on GUI's. No central loop, every widget processes it's own events and handles it's own data.

What do you guys think about this? It looks like it kind of can be efficient in languages such as Erlang, and it's an interesting approach.

William van Doorn

+2  A: 

In conventional apps, a process (or thread, if you want to be picky) owns the state of the UI and handles events via a message loop. Since Erlang processes are extremely lightweight, wxi's approach is a very logical and natural extension of the conventional model.

This approach has signification ramifications for UI and app design. For instance, a complex download-manager control that has animation, I/O, etc., can be bundled as a completely independent process (with sub-processes handling its component UI pieces) that interacts with the parent UI through message-passing. Such a control could even crash due to a connection problem or internal bug, and the parent control, acting as a supervisor, would indicate that an error occurred and simply start a new copy of the control.

Marcelo Cantos
Yes, but this concept is harder to follow when you have 'heavier' threads? Such as in Java/C?
wvd
It's a disaster with conventional threads, for at least two reasons: 1) too many threads will drown the CPU in context-switching; 2) threads share memory, which makes them extremely difficult to program correctly, whereas Erlang processes are strongly isolated and can only share information via message-passing, which dramatically reduces the non-determinism in the system. Most UI frameworks use a central message loop that handles all UI elements because threaded programming is a prohibitively expensive and fragile model of concurrency.
Marcelo Cantos