Best option to do desktop apps in Elixir

Written in Erlang, wings3d.

You could try tauri which targets rust, or sciter-js. Both allows for you to connect to your phoenix server.

I’m not too sure if the self-healing properties of the beam are as beneficial for gui apps, which users can just force kill and restart in seconds. It might even be detrimental to user experience, especially if the app gets stuck in an infinite loop of restarting without the user being able to manually handle the error.

onivim autocompletes every do as defmodule or another word, you have to go back to normal mode each time. Awful. I’d say it is not ready for elixir right now :slight_smile:

But the autocomplete and docs for all the standard library and own modules works well!

1 Like

Is using the users default web browser out of the question?

You could use something like Bakeware and then use System.cmd("open http://localhost:<my-port>") to open the default browser on the users machine. The command would differ between OSs, but should be pretty easy to implement.

You should probably also consider a method to figure out an unused port, and include that in your command to launch the browser.

I don’t mind using the default browser, it’s just I don’t know how to make an Elixir program open a new browser window (using the default browser) and then making it open the url I have in mind.

Bakeware looked promising, but it doesn’t work for Windows, which is a requirement.

I did find this code snippet:

 def open(url) do
    start_browser_command =
      case :os.type do
        {:win32, _} ->
          "start"
        {:unix, :darwin} ->
          "open"
        {:unix, _} ->
          "xdg-open"
      end

    if System.find_executable(start_browser_command) do
      System.cmd(start_browser_command, [url])
    else
      Mix.raise "Command not found: #{start_browser_command}"
    end
  end

From the project:

Could prove useful, as long as I can make it work for both Windows and Linux.

1 Like

I’ve been working on a library to make the desktop apps part possible here: GitHub - dominicletz/desktop: Elixir library to write desktop apps with OTP24 & Phoenix.LiveView it all depends on Erlang OTP24 because that includes my pull request to include :wxWebView and so you can have a native window that shows your Elixir LiveView app. So the desktop library brings you all of that and avoids the need to mess around with any of the :wx* libs in your app.

I’ve got a local version of an app builder that produces a .dmg for macOS and a nsis Windows installer but it’s still a work in progress - planning to get that desktop-builder ready for the Code Beam V in May.

18 Likes

Wow, this is awesome :heart_eyes:

Link to the pull request so that we can upvote it :slight_smile:

Oh, I though it was pending approval(bad interpretation from me), but it was already merged in February :tada:

And for Linux?

1 Like

For linux I’ve got a self-extracting installer based on makeself.io . That one I’m not super happy with though, would prefer a deb package. I’ll push to github as soon as possible.

3 Likes

Better then nothing :slight_smile:

It would be a great addition for sure :slight_smile:

Thanks man. I am really excited with the possibility of writing a modern looking desktop app in Elixir with LiveView. I may make a version of my video notes web app with your desktop library :slight_smile:

1 Like

This project looks rather interesting. Let me know if you give any conferences or do any articles on it, I really would like to learn more about it.

2 Likes

Wow, that’s cool!

Is it limited to browser features or some deeper OS integration is possible?

2 Likes

Yeah I’ll talk at the code beam sto about this project and next steps Virtual Erlang and Elixir Conference for Europe

So far there is a native widow, native desktop notifications and native app icon. Also the sample app is using the sqlite ecto library for local storage. What are you thinking of in terms of deeper OS integration?

1 Like

For example registering itself as a service in macOS and handling NSPasteboard data.

@dominicletz Hello again, do you have a link for the conference? I wasn’t able to get a ticket but I am still interested to see how your presentation went !

Sounds to me it might be this video Elixir Berlin meetup February 2021 - YouTube

4 Likes

This is the GitHub repo in the video GitHub - elixir-desktop/desktop-example-app: Elixir Sample App using the Desktop library with LiveView to create a desktop app

2 Likes

Thanks for linking that @wanton7 . If you guys are curious about that project we’re currently hiring for a position to work on this. So if you want to be paid to work on open source let us know: Elixir Engineer (or Erlang)

Cheers!

5 Likes

Maybe this could be interesting for desktop apps? GitHub - wojtekmach/elixir-run: Erlang/OTP + Elixir + IEx + Mix in a single executable for Linux/macOS/Windows. Just run Elixir!

You could use that to distribute the VM and just bundle in your code with it. Though I don’t know how it handles connections to libraries like OpenSSL, WxWidgets…

1 Like

elixir-run uses bakeware which in turns builds a release with the OTP that you’re currently using. If you have OTP with OpenSSL, wxWidgets, etc, properly set up, then your release will be fine.

elixir-run has limitations for certain kinds of apps so it will stay as a proof of concept. There may or may not be another tool coming in that space though. :slight_smile:

btw, here’s a way to build OTP openssl & wx, all statically linked for Macs: ci: Add macOS builds by wojtekmach · Pull Request #5036 · erlang/otp · GitHub. I hope that PR will be merged in and later on we’ll also have official binary builds for Linux.

1 Like

I was more thinking about distributing to other people’s computers, who may or may not have the same versions and locations of the libraries. So a statically linked build would be very nice for this purpose.