Create cross-platform GUI apps with Golang + Elm!

Overview

README

About

Create GUI apps with Wails + Elm!

Dev env requirements

Create a project

Run the following command:

wails init -n wails-hello-world -t https://github.com/benjamin-thomas/wails-elm-template

Live Development

Inside the project folder, run: wails dev. This setup provides auto-reloading of backend+frontend code.

It's also possible to keep the frontend reloading process separated by:

  • deleting the frontend:dev:watcher entry in ./wails.json
  • then run cd ./frontend && npm run dev:watch in a separate terminal (this triggers the elm-live toolchain)

Debugging

It's possible to debug and inspect javascript code at: http://localhost:34115.

This URL also allows the inspection of state change provided by elm's '--debug' compile flag.

Building

To build a production binary, use wails build.

Note on performance/alternatives

I feel this stack could be a great combo for GUI programming. Elm's promise to eliminate runtime errors could turn out to be invaluable.

I evaluated other technologies, here's my list pros and cons while trying to build a hello world app on an old computer:

| Technology               | Pros                                                                                            | Cons                                                                                                         |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| JavaFX (with modules)    | Easy cross platform development                                                                 | Hard cross platform distribution (tooling is still a little rough)                                           |
|                          |                                                                                                 | Packaged app remains rather large (~30-90MB)                                                                 |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| JavaFX (without modules) | Easier distribution if using Bellsoft/Liberica JDK                                              | What are the security implications for the end user?                                                         |
|                          |                                                                                                 | The distributed package is even larger (~150MB)                                                              |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| JavaFX                   | Interesting ecosystem for building business apps (see: ControlsFX,etc.)                         | Slow app startup (2s)                                                                                        |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| JavaFX                   | Potentially tiny binaries if distributes as .jar                                                | The end user needs an SDK, that's a pretty heavy requirement (+ becomes a security concern to manage)        |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| JavaFX                   | Can achieve a rather native look.                                                               | Task manager reports a javaw.exe binary, not my-app.exe.                                                     |
|                          |                                                                                                 | I could not find how to circumvent this although I'm pretty sure it's doable                                 |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Electron                 | Easy dev setup, easy distribution with extra packages                                           | Distributed package remains quite large (~70-120MB)                                                          |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Electron                 | I saw a small memory footprint in my simple test (has there been improvements here?)            | Memory usage is said to be a problem, memory leaks could easy to introduce and hard to find/debug            |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Electron                 | Very slow app startup (4s)                                                                      | Microsoft documented the high memory usage of Microsoft Teams for their users (ouch!).                       |
|                          |                                                                                                 | Then announced moving off Electron for this reason.                                                          |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Flutter (Dart)           | Cross-device development (mobile+desktop) by Google. Fast startup and dev hot-reload (< 1s).    | Apps look pretty tied up to Google's material design. Some community projects like `fluent_ui` try           |
|                          | Binary bundle could downsized if zipped from ~20MB                                              | to address this but are still at an early stage.                                                             |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| .Net MAUI (C#, F#, VB)           | Multi-platform App UI by Microsoft: almost cross-platform (cross-device) dev.                   | No Linux support :(                                                                                          |
|                          |                                                                                                 | Seems to require a Windows dev machine (no dotnet core support)                                              |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Avalonia (C#, F#, VB)            | Community driven cross-device development                                                       | Binary size remains fairly large. Incorporates DLLs that got wrongly tagged as viruses by AV companies, etc. |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Tauri (Rust based)       | Very similar to Wails.                                                                          | Rust compile times make hot-reload so slow (30-40s!)                                                         |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Wails + Elm              | Fast startup (1s), very fast auto-reload (instant), small binary (4MB), small memory footprint. | v2 of the project is a little early, but the project has been around for many years.                         |
|                          | The architecture and final output feel much simpler than the other solutions.                   |                                                                                                              |
| ------------------------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |

If you feel I got things wrong, or want to add to this list, don't hesitate to open a PR!

Improve this template

Go one level above this project. Then run these two commands and ensure hot-reload works.

rm -r ./wails-elm-test;wails init -n wails-elm-test -t ./wails-elm-template/
cd ./wails-elm-test/ && code . && wails dev
You might also like...
Clean Architecture template for Golang services

Go Clean template Clean Architecture template for Golang services Overview The purpose of the template is to show: how to organize a project and preve

Callable Ajax / http requests inside Golang templates

jaco Callable Ajax / http requests inside Golang templates Examples Examples #1 {{ define "content" }} div id="myTodos"/div script

A Go Template Library. A bunch of utils and collections that are not part of the Golang standard library.

gotl A Go Template Library. A bunch of utils and collections that are not part of the Golang standard library. Prerequisites This library is using ext

Competitive Programming Template for Golang

Go Competitive Programming Template How to use this repo? Check the commit histo

Template user CRUD operations with golang, JWT, postgres

user-api-golang A CRUD API template for perform operations on users. Written in golang. Components Server: Golang with go-chi as mux and zap for loggi

An example of implementation of Clean Architecture in Golang

Golang Template Description This is an example of implementation of Clean Archit

Go-project-template - Template for a golang project

This is a template repository for golang project Usage Go to github: https://git

Template for depency injection in golang (no libraries)

Go Dependency Injection (No libraries) Project template based on the most common layered architecture style, made to explain how to do dependency inje

Golang Service Template

Golang Service Template Golang back-end service template. Using this template, you can get started with back-end projects quickly. Web Framework ORM D

Owner
Benjamin Thomas
Benjamin Thomas
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.

Maroto A Maroto way to create PDFs. Maroto is inspired in Bootstrap and uses Gofpdf. Fast and simple. Maroto definition: Brazilian expression, means a

Johnathan Fercher 844 Nov 24, 2022
A scaffold to quickly create a go project

OpenMix 出品:https://openmix.org Mix CLI 一个快速创建 go 项目的脚手架 A scaffold to quickly create a go project Installation 安装 go get -u github.com/mix-go/mixcli

Mix Go 22 Nov 16, 2022
"to be defined" - a really simple way to create text templates with placeholders

tbd "to be defined" A really simple way to create text templates with placeholders. This tool is deliberately simple and trivial, no advanced features

Luca Sepe 22 Sep 27, 2022
Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application.

goview Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application. Contents Inst

foolin 309 Nov 23, 2022
Handlebars for golang

raymond Handlebars for golang with the same features as handlebars.js 3.0. The full API documentation is available here: http://godoc.org/github.com/a

Aymerick 501 Nov 23, 2022
A general purpose golang CLI template for Github and Gitlab

golang-cli-template A general purpose project template for golang CLI applications This template serves as a starting point for golang commandline app

null 20 Nov 19, 2022
Clean Architecture using Golang.

Golang Template Description This is an example of implementation of Clean Architecture in Go (Golang) projects. Rule of Clean Architecture by Uncle Bo

Golang Common Packages 78 Nov 1, 2022
Clean arch Golang template project

Template No previous versions, still working on this one to reach v1. API Service for pssword app mobilde based on : https://github.com/bxcodec/go-cle

Diego Alberto León López 2 Sep 15, 2021
Template for Golang rest API using Fiber

Rest API Setup DB sudo -S docker-compose -f db.yml up -d Build container sudo -S docker build -t rest-api-image . Run container from image sudo -S doc

Daniel Svitan 2 Dec 5, 2021
Clean Architecture template for Golang services

Go Clean template Clean Architecture template for Golang services Overview The purpose of the template is to show: how to organize a project and preve

null 7 Jul 11, 2022