ostap

ostap

How could BEAM VM benefit a desktop app?

Curious: Can you think of any desktop apps where having Beam VM would be beneficial?

Most Liked

sbuttgereit

sbuttgereit

Speaking as someone that does a substantial amount of desktop development, I have to disagree with this point of view. Concurrency, not resiliency, is probably the bigger story of what the BEAM has to offer desktop development. This isn’t to say that resiliency is a minor concern in user facing desktop applications, but concurrency can color all the user interactions and not just the badly behaving ones.

If we look at common desktop development paradigms, meaning GUI event driven programming, we typically have some assemblage of “widgets” which sit there waiting for an interaction. The nature of the interaction can vary… so, for example, a user may check/uncheck a checkbox widget setting it, or I may set it programmatically, or either case could set it to a tertiary state. Such an action will change some internal state in the widget object itself, but also typically result in signaling other interested parts of the application that the interaction took place, perhaps along with the resulting state. The other parts of the application which received that signal may themselves change the state of the other widgets in the UI, internal state, or even programmatically change the original checkbox state, all of which can cascade into another whole set of signals and signal responses… etc. until some bottoming out condition is reached.

These widgets sitting around with independent state and independently waiting for a user interaction, and the internal state related logic of the form, again waiting for interesting signals to decide what to do, sounds an awful lot like agents sending and receiving messages. Sure an event loop looks and feels more like Pub/Sub to a GUI developer, but in the end the notion that you have some program sending messages to none or more interested other programs feels like BEAM processes sending messages to each other.

And good, well considered concurrency can very much influence the user’s experience of an application. The snappiness and responsiveness of a user interface can depend heavily on if widgets and display elements can send their signals and move on while other parts of the program process as instructed by responding to those signals: stop-the-world interactions are often times negatively felt by users. This isn’t to say you can be careless and the concurrency is a cure all: it’s a necessarily element, though not sufficient on its own.

Resiliency can be also important in a GUI, too. I work with ERP systems and the one in which I deal with that uses Qt/C++/JavaScript is a good example. I often times find end users with their desktop client open and a dozen or more independent forms open: may a couple items are up, the customer, a sales order, current stock levels, etc. They do this because they need to research, they were in the middle of task 1 and urgent task 2 came up, etc. It is conceivable, particularly when dealing with data tables in the UI for example, to take a reference to a row in the table, refresh the table (meaning all the row objects are destroyed and new ones are created), and then try to operate on the just deleted row object. In the C++ this usually crashes the application meaning that all the forms the user had open crash, including ones which might have incomplete work product or that they simply spend the time to open for whatever they were trying to accomplish: in the end it’s a pretty crappy user experience. Now, with BEAM like resilience the bigger likelihood is that the task referencing the now deleted row just finishes (no shared mutable state), but in the worst case the widget crashes, or even the form crashes, but the whole application doesn’t need to crash. Sure there are ways to fix this in Qt/C++ and ways to screw it up with the BEAM… the real question between the two is how easy and in which direction does the development environment push you?

Finally, I should caveat this saying while I think at a shallow level of analysis the BEAM seems like it would be compelling to build a desktop framework around, it’s not clear that the details support that conclusion. Maybe the way the BEAM implements scheduling or the serial nature of a single processes message passing make it inappropriate to drive the event loop, etc of such a framework. I haven’t done that analysis, but it seems like something that technically would be reasonable to investigate.

In the end I don’t think we’ll see any progress along these lines. GUI frameworks are a big lift and I just don’t see enough momentum in the community to push that direction. I don’t think the obstacles are technical or that the BEAM has nothing to offer desktop development. I think the biggest barriers are sociological and demand driven.

d-led

d-led

this seems to not have been mentioned but Wings3D is a desktop app written mostly in Erlang. See a post from 2009.

https://github.com/dgud/wings

aseigo

aseigo

Interestingly (maybe?) there was a PoC project that allowed one to run a QtQuick / QML gui with logic in a BEAM language. The idea was to have messages from the “business logic” in the BEAM bridged over into the QtQuick runtime, and vice versa so that bound events from the QtQuick runtime (keep in mind that changing values of bound variables are, from a mental model perspective, events themselves) could appear as messages in the BEAM code.

This bridging actually worked fairly well, with it feeling relatively “native” on both ends. It never went beyond PoC as a curiosity, but it did demonstrate the plausibility of this approach. It would mean not requiring a U/X library written in e.g. Elixir while keeping all the business logic there … with all the benefits and interesting possibilities of both worlds being available.

I do think this would provide a lot of interesting possibilities, including:

  • a sharp separation of business logic from UI
  • painless multi-threaded business logic for desktop apps
  • painless recovery from errors in business logic (which is such a pain in desktop apps)
  • a very easy pathway to network services, allowing easier integration of online services with desktop applications
  • inter-application communication between apps via message passing, which could be done via local sockets or by simply tying all the desktop apps together into a local BEAM cluster. Both would require some thought as to safety (stability, security, ..), but would be within reach.

Besides having the resilience of the BEAM as wlel as the pleasure of writing functional code with an OO UI, I believe it would allow for patterns that are currently hard to achieve, such as transparent movement of application state between machines (including application code itself), interaction across the network without requiring intermediate web services (at most a reflector service, which itself could be a simple BEAM application) …

There are a lot of possibilities here. Should desktop innovation become a useful area of interest again at some point, this is one of the ideas I have sitting around waiting to be dusted off :slight_smile:

Where Next?

Popular in Discussions Top

matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New
jswny
I would like to better understand what the advantages/disadvantages of umbrella applications are compared to structuring your app as as s...
New
vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
MarioFlach
Hello, I want to share a project I’ve been working on for a while: https://github.com/almightycouch/gitgud Background Some time ago I ...
New
sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
PragTob
Hey everyone, this has been brewing in my head some time and it came up again while reading Adopting Elixir. GenServers, supervisors et...
New
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement