Fancy some GUI programming with Elm?

Hello Elm community,

I’d like to promote a very cool golang project that’s been under my radar for a while: wails!

What does this have to do with Elm? Well in short, it allows one to develop cross platform GUI apps with minimal effort using web technologies for the frontend, running on a golang based backend.

Sounds like electron? Yes it does, but the approach taken here is quite different: you get a small binary with minimal memory consumption as a final product. Cross compiling is incredibly easy, and you get a very performant hot-reload environment out of the box. So in short, it’s the first time I feel this kind of architecture could work for me, maybe for you too?

I made an Elm template so that starting a project and coding an Elm based GUI app is as easy as 1, 2, 3!

You can find mention of it in the next version of the docs.

Or straight on my github with setup instructions: GitHub - benjamin-thomas/wails-elm-template: Create cross-platform GUI apps with Golang + Elm!

Have fun!

27 Likes

Thanks for posting – this looks very interesting!

To build windows, linux, mac binaries, do you need access to all three platforms, or can you cross compile binaries for all three platforms on Linux?

@cbrake cross compiling from Linux targeting Windows works flawlessly.

I’ve just tested targeting MacOS and the build script says this is “not currently supported”

One major plus point of the go ecosystem being a very easy cross-compilation experience I’m pretty sure it’s not out of reach though :slight_smile:

That is really neat, and somewhat surprising as I thought there would be some messy integration with native webview code, but they must have figured out how to make that work.

Good to see re-use of native webviews for local app development rather then shipping another browser. I’d like to submit pywebview as another option if you’re a python programmer -

The ability for go to be packaged into a single binary is a nice selling point of go in general. For Python, packaging up python+pywebview with your program turns out to about 30megs for a simple setup without any big frameworks included, which isn’t too bad IMO.

Thanks for your feedback @awesomo4000.

Looks interesting, although I don’t see any help to distribute the app (looks like you would either need to install or distribute python on the target host which is not a great option for me).

The project I pointed to allows one to distribute a single binary, where everything is self contained (even the assets).

A hello world app got me an 8mb exe as an output which is not too shabby I would say :slight_smile:

I have to dig further into this project though to have a final opinion though, but so far so good.

Here are some of the tools used for packaging an application written in python:

These bundle up python with your application as the entry point and are distributed as installable applications in suitable formats to install on the target OS. Installer for a minimal application is about 30 megs. Since they include python you don’t need to install it separately.

Nice, I’ll check it out thanks :slight_smile:

Hey @benjamin-thomas – have you also seen https://tauri.studio/ ?

It’s been mentioned on here by folks a few times before, and was already on my list to check out. Curious if you came across it and found some drawbacks compared to Wails?

I’m particularly interested in being able to target mobile platforms as well. It seems par for the course that each time one of these native platforms pops up it claims that will be the case, and then over time isn’t. :sweat_smile:

3 Likes

Thanks @benjamin-thomas, I had tried out Tauri but got stuck on learning Rust. Wails on the other hand was really easy to pick up. I could write Go in a couple of days. Many thanks :sparkling_heart::sparkling_heart::sparkling_heart:

@supermario, a small(opinionated?) comparison of browser based GUI tools is available at the elm template in the original post readme

2 Likes

Ah, missed that, thanks @Nduati_Kuria !

I’m curious, what would be the differences with a PWA written in Elm with serverless function calls ? For instance Google Cloud Functions can be written in Node.js, Python, Go, Java, .NET, Ruby, and PHP…

Hey @supermario. Yeah I did have a look at tauri. Rust looks interesting to me, however I just can’t get over its super long compile time. Which I was the case with tauri, I quickly discarded it because of that, I couldn’t feel productive with it.

If someone knows a trick or two to get faster compile times in dev I’m all ears :slight_smile: (I don’t care if the final build takes a while, but waiting for the compiler while coding really bothers me)

Glad you found this helpful @Nduati_Kuria :slight_smile:

Indeed Go is very easy to pickup

@Laurent I imagine you can get pretty far with a PWA (probably at the cost of complexity though) but some things will stay out reach.

For example, in my case I want to develop some kind of port scanner to find devices on a LAN. This tech combo makes this project doable and easy for me.

I could see myself creating some CRUD apps backed by a local sqlite database, where the private data stays on the user’s computer, etc.

+1 on the networking capabilities. In my case, I am using Bonjour/device discovery to link a desktop app with a mobile app over WiFi.

On the comparison between Wails/Go and Tauri/Rust, isn’t Go’s lack of union types problematic when interacting with the frontend? I’d hate to model message passing with interfaces instead of ADTs.

Right now I’m developing a PC application with Tauri and I’m abusing JSON encoded values + Serde to (almost) seamlessly pass messages from Elm to Rust and viceversa.

1 Like

@benjamin-thomas Yes, it makes sense for sensitive actions out of the browser “sandbox” like LAN stuff. By the way yes you can do a lot nowadays with the web: https://whatwebcando.today/.

1 Like

There’s a section in the Bevy Engine docs about some tricks to get faster compile times: Bevy - Setup

I’ve found it to be fast on recompile with those optimizations.

I can’t say for sure, I’ll have to play more with this stack to have an opinion :slight_smile:

Thanks for the link @Laurent, always good to consider this approach first. I thought about another use case for you: let’s say you want to have your app loaded in the user’s system tray: this tech will enable that.

Thanks!! I multiplied my compile times by …10!! :sweat_smile:

I also had an issue with some cargo cache causing extreme lag somehow (had to rm it then ok), wasn’t expecting that.

So I had another look at tauri. It looks interesting for sure, but harder to get into IMO. I wish they had better docs and a better hello world app on project init :slight_smile:

1 Like