GUI programming in Elixir?

I’m completely new to Elixir and don’t know Ruby, either.

Is anyone writing GUI applications in Elixir? I don’t know the language and the easiest way for me to learn (not to mention the way I’d primarily be using any language right now) is for desktop applications with a GUI front end - ideally something that will work on both Mac and Linux. What are my choices and how well supported/ integrated are they? In case it matters, I’m specifically interested in writing a distributed business application connecting multiple machines over the internet. From that standpoint, Elixir seems like it might be a good fit. But I need to have a GUI interface and not just in a browser.

I tried to research this question first with a web search and then with a search on this site; I haven’t found any good answers so far.

3 Likes

Will the app be connected to a central server?

If so I would look at http://electron.atom.io for the GUI and then use Elixir on the back end/server. (@kofno has some experience with Electron. Hopefully he’ll spot this and add some thoughts.)

5 Likes

For a cross-platform desktop app Java would be my choice. If the Java client isn’t ready then you might investigate the possibility of channel integration by executing Phoenix.js through Nashorn.

JavaFX is really easy to work with and can deliver a great looking GUI.

1 Like

If you have web development experience, I would recommend Electron. It’s fairly easy to build and distribute a desktop application if you already have experience with web technologies. I wrote an app using Elm and distributed it as an Electron app.

elixir and a server and elm as a frontend is pretty popular right now. I’ve actually started working on something built that way (though I’m not sure if I’m going to use electron, or just the browser).

2 Likes

Wow. I recently been using Atom a bit and have been impressed by it. I never bothered to wonder how they were handling their gui. I guess this is it! A lot of stuff to digest but if Atom is basically using electron (I understand it was formerly called “atom shell”) for its gui then it ought to be good enough! At least I will presume so for now.

I’m intrigued that Elm – another language which I’ve read a bit about but not yet learned – and Elixir are being used together… Does this qualify as a real symbiosis? Are the communities cooperating? I previously would have classified Elm and Elixir as “competitors” in somewhat the same space. I had read something about a project to bring Elm to the server.

Any links or comments on any of these things would be appreciated.

2 Likes

Thanks. It will have a centralized store, of sorts, but not really client-server. The nodes are supposed to maintain their own limited data and keep operating in case of any outage and, later, synchronize. The purpose is to tie together a number of loosely coupled businesses.

1 Like

No they are not competitors at all - Elm is front end and Elixir is backend. Elm is a HTML/CSS/JS transpilier, I can’t see why they would want it on the server as well, and even if they did, it would be JS - nobody in their right mind would want JS on the server :043:

7 Likes

At the latest Elixir conference which you can find on Youtube, the author of Elm gave a presentation in which he said he was working on a tight integration with Phoenix channels.

Time frame given was about a month.

1 Like

Yes. I guess I saw that - didn’t read it. Thanks for locating the comment. I figured Elm was at least originally written in Haskell (don’t really know, but figured). So it doesn’t have to stay with HTML/CSS/JS manipulation, right? It’s getting kind of crazy out there. You should see the kind of stuff they’re planning with red-lang. Although not a purely functional language, imo red will upset a few applecarts…to put it mildly.

2 Likes

For GUIs in Elixir you can still use Erlangs wx-module. For this to work, of course, it is necessary that your Erlang release is compiled with wx included.

But for the client side I’d prefer a more lightweight solution that does not pull in a full gigabyte as runtime dependency…

This in mind, I do think, currently the best approach is a JavaScript-application which runs in the Browser and is written in a way that it can work without internet access. This could even update itself silently whenever necessary (and online). Also there are multiple tools available, that can convert HTML5/JS-Applications into native applications for iOS, Android or Win mobile. They might need additional tweaking of the source though.

But if you really want to use the same language in the complete applications stack, I heard about a language called haxe which promisses exactly that, but I never tried more than a hello-world, because I#ve no project which could make use of it.

4 Likes

if this is your goal, Elixir is not at all well suited to learn by creating GUIs. All the answers you got above are about actually creating the GUI itself in another language (Elm, JS/HTML/CSS with Electron, Java) not in Elixir. All the above answers are good, but if your stated goal is to learn Elixir by doing GUI programming (non-web), you won’t find much/anything to support that in Elixir itself.

4 Likes

ElixirConf 2017 included a talk about building a UI “natively” in Elixir that is quite exciting to me! (It uses a port to talk to OpenGL via a small C wrapper). I’m looking forward to the code being released so I can play around with it.

Here’s the link to the forum post discussing the talk that @boydm gave at ElixirConf:

4 Likes

I write mostly GUI business apps, and also need a lot of reporting. The Little Elixir & OTP Guidebook states in the intro that Elixir that Elixir & GUI don’t mix, but several presentations at the Elixir Conf, including the Toyota Way seems to indicate that large companies have embraced Elixir for business apps. Am I barking up the wrong tree here?
A corollary question is whether any of you are using reporting tools, and whether you are writing your ORM in Ecto, if I understand that correctly, or in stored procedures. It seems to me that in order for a reporting tool to interact with the data it would have to be outside of Ecto.

There’s a kind of chicken and egg problem here. IMHO, the BEAM would be a pretty awesome GUI app environment, but it doesn’t have a robust interface to the client windowing API. There is the wx interface, but the problem with putting any GUI library in as a NIF is that it can crash the BEAM.

One way around this is to use the browser and javascript as your GUI interface.

Creating a Port interface to OpenGL is also pretty intriguing. However, I think for Native UI Desktop Apps, Elixir is going to be an uphill battle. There will likely be places where this battle is worthwhile, but I think for most applications the time to delivery penalty will be too great until more of the spadework in library interfaces is available.

What might make more sense is to drive an Elixir app via a GUI wrapper if your underlying problem maps well to what the BEAM does well. (i.e. if your basic problem is “embarrassingly parallel” and I/O limited ) What would scream “Elixir Desktop App” to me is a problem that using the increasing number of cores available on high end desktops would help.

While Elixir will never likely be the fastest on 1 or two cores, once you’ve solved your problem in Elixir it becomes much easier to throw 24 or (128) cores at it and see reasonable speed ups. Right now those kinds of machines are mostly servers, but that level of concurrency will eventually make it’s way into desktop computing.

1 Like

So maybe just presenting the browser as a GUI interface would be the best solution?

Here’s Joe Armstrong’s research on GUI options for Erlang: http://erlang.org/pipermail/erlang-questions/2017-July/092949.html

5 Likes

I agree. People are going crazy over component oriented architecture now. Isolating and orchestrating state is selling like hot cakes.

Elixir is designed for this, no? This kind of reactive design.

2 Likes

I wonder if using ElixirScript and compiling to electron would be a possibility :thinking:

2 Likes

Kind of late to the party here, but for anyone still interested in this, I’m currently building a phoenix app that I plan to distribute on desktops using webview, seems to be the most simple and straightforward approach.

5 Likes

please do keep us posted, sounds awesome - dream scenario would be an app that you could build for desktop and/or for the nerves kiosk GitHub - nerves-web-kiosk/kiosk_system_rpi3: Nerves QtWebEngine Kiosk system for Raspberry Pi 3

1 Like