| I'm fairly sure I've said this before here and elsewhere, but bears repeating, especially for this post. Statecharts is currently probably the most undervalued tool when it comes to programming GUIs with state. Statecharts are a continuation of state machines, but with less footguns and better abstractions to be able to build larger systems. In the end, you either build a GUI that are using state machines implicitly, or explicitly. Tends to be less prone to bugs if you do so explicitly. If you're interested, here is some starting points (copied from an older comment of mine): Here is the initial paper from David Harel: STATECHARTS: A VISUAL FORMALISM FOR COMPLEX SYSTEMS (1987) - https://www.inf.ed.ac.uk/teaching/courses/seoc/2005_2006/res... Website with lots of info and resources: https://statecharts.github.io/ And finally a very well made JS library by David Khourshid that gives you lots of power leveraging statecharts: https://github.com/davidkpiano While we're at it, here are some links to previous submissions on HN regarding statecharts with lots of useful and interesting information/experiences: - https://news.ycombinator.com/item?id=18483704 - https://news.ycombinator.com/item?id=15835005 - https://news.ycombinator.com/item?id=21867990 - https://news.ycombinator.com/item?id=16606379 - https://news.ycombinator.com/item?id=22093176 |
Yuck. Use continuations with anonymous fns that tell the GUI what to do next. The state is in the closure implicitly!
I wish I had an articulate counterargument, but just look at this: https://xstate.js.org/docs/#promise-example
Statecharts are a formalism for modeling stateful, reactive systems.
Beautiful is in the eye of the beholder, and never moreso when the programmer is blind to the cost of repetition and state.
Arc got it right. http://www.paulgraham.com/arcchallenge.html
Write a program that causes the url said (e.g. http://localhost:port/said) to produce a page with an input field and a submit button. When the submit button is pressed, that should produce a second page with a single link saying "click here." When that is clicked it should lead to a third page that says "you said: ..." where ... is whatever the user typed in the original input field. The third page must only show what the user actually typed. I.e. the value entered in the input field must not be passed in the url, or it would be possible to change the behavior of the final page by editing the url.