Skip to content

Why FuncSug

cl4cnam edited this page Mar 10, 2025 · 5 revisions

Motivation

Many people ask why GUI programming is so difficult. Some of common difficulties come from event-driven programming problems. That's why, with FuncSug, programmers do NOT have to follow the event-driven programming paradigm. For example, you no longer use addEventListener and so no longer have the corresponding problems.

Note

The problems of event-driven programming are described, for example, in "FUCHS, Matthew. Escaping the event loop: An alternative control structure for multi-threaded GUIs. In : IFIP International Conference on Engineering for Human-Computer Interaction. Boston, MA : Springer US, 1995. p. 69-87."

Explanation

When we make a client web program, we code logical parallelism but this is not explicitated. Indeed, when we code addEventListener on several HTML elements, we give them a logically simultaneous ability to react to a DOM event (:warning: This is not an ability to react simultaneously).

In FuncSug, this parallelism is made explicit so that it can be handled more easily.

For example, if I code:

myFirstElement.addEventListener('click', myFunction1)
mySecondElement.addEventListener('click', myFunction2)
restOfProgram()

After execution of the first two lines, I get two simultaneous ability to react. It would be more explicit if we could write (in FuncSug style):

parallel:
	restOfProgram()
	while true:
		await click on myFirstElement
		myFunction1()
	while true:
		await click on mySecondElement
		myFunction2()

This is roughly the tacit global mental structure of a program in the event-driven paradigm. In FuncSug, you aren't restricted to it any more: you can nest parallel blocks, sequence, and all control flow structures without limitations.

This example doesn't look like a big improvement. But, in many cases, this style can bring a big simplification, see this comparison.

In FuncSug, this style is extended with variant of parallel: parallel exitAfter ... finished, parallel(select ...) and parallel(for ... in ...). In addition, you can interrupt, pause, resume or restart a parallel branch.

In addition, in this example (test it), you'll see that FuncSug saves you the hassle of managing all the combinations of component states.

Clone this wiki locally