Hacker News new | ask | show | jobs
Ask HN: Easy language/runtime to distribute to desktop users?
16 points by throwaway8903 1435 days ago
I want to distribute an Open Source program to end users that does work via a Rest API. A UI isn't strictly necessary but might be required later.

What's the best language to write something like this in? Python?

16 comments

I strongly recommend Go. It cross compiles very easily and can embed arbitrary files. I’ve used it at work to distribute to Linux, Windows, etc. it comes with a solid REST API toolkit baked into the stdlib for simple things and great libraries for more complex flows.

For what I do at work, one of the simple apps just listens on local host and serves templated html and a rest API. Also easy to bake the server and CLI (if you want one) into a single binary. So “myapp server —foo —bar” runs the server, and “myapp” can be used as a CLI interface to the REST API until you make the UI.

All of this can be done with the stdlib, no need for 3rd party tools.

Flutter needs 1.64GB disk space, that's not a light install. Unless I build the app beforehand as others have suggested.
Of course you'd build the app, why would you make the user install Flutter as a development environment? A built Flutter desktop app can be had in ~100 MB, as well as being able to be on Windows, macOS and Linux with minimal effort. For example, https://www.superlist.com/
> What's the best language to write something like this in? Python?

Python (packed with PyInstaller) is a reasonable choice.

If you know a language that supports cross-platform builds, that (all other things being equal, including library support for what you want to do), that might be more convenient for distribution, OTOH, you probably want to test on your supported platforms anyway, so building on each isn't that much additional work.

Just use a compiled language. I've messed with packing up languages like python and its just a clunky pain in the ass

Compiled all the way, golang works great

JavaScript or Typescript with Deno is another option. I haven't tried it myself yet but Deno has a "compile" command to build an app into a single executable

Kotlin/Java could also be used. Also haven't tried this, but it seems like it's become easy to bundle a JRE with a java app to create a single executable https://www.reddit.com/r/java/comments/86l45p/how_do_people_...

Just ran into a similar problem for creating an installation script for my project, Keagate (https://github.com/dilan-dio4/Keagate).

My solution was to use a bash installation script (https://github.com/dilan-dio4/Keagate/blob/main/packages/scr...) that checks if Node and NPM is installed. If it not, it automatically installs them via NVMs one-liner (can be seen in the bash here: https://github.com/dilan-dio4/Keagate/blob/d7442118a4846daf3...). The script then invokes the rest of the project via node.

This creates a cross-platform, streamlined installation workflow that natively goes from Bash (eww) to Node (nice).

if you write it in python or other interpreted language you would either need to bundle python or rely on users installing it or having it already (comes with macos and most linux distributions, windows not so much), so arguably a compiled language would be better for distribution to end users as its easier to bundle dependencies
Plus python programs are hard to use on windows.
No, they aren't hard to use. They may be different to package than for, say, Linux, but even that is just different and not harder. (And it's not even different significantly if you use pyInstaller.)
As a user of various python apps on windows I can tell that in practice it’s one of most confusing experience among all other languages. I have to purge everything python-related and reinstall it once a year.
If you are using apps that have been packaged with PyInstaller (or a number of other methods) for end-user use, I don't understand this: I use a number, and it's completely painless.

If you are using a systemwide Python installation and installing apps into it with pip, then, yes, that's potentially a world of needless pain.

Why?
1. any ui lib for python needs binaries that have to be present on the computer of the user. Under linux for example you just add an dependency to the package and add your own deps If they aren't shipped. Under windows you better ship everything, including the python runtime. 2. Windows has no standard paths. If you decide to not ship everything for windows, the user has to install everything manually. 3. You alwys have to remember to use pathlib when interacting with files, because only windows uses \ as an path seperator and has an 260 filename limit. Pathlib abstracts it a bit away.
I don't think you've described the problem adequately. A REST api implies a server... is this program supposed to implement the server locally, or connect to the cloud?

There are multiple cross platform environments, including Lazarus/Free Pascal if you want a GUI that can connect to the internet as a back end. (That's my decidedly minority favorite)

If you just need command line functionality, It's really hard to ignore Justine's work on actually portable executables.

Python is cross platform, but don't count on the scripts working without support/updates in 2 years.. they tend to change things and break compatibility.

Personally I would either use a compiled language, or electron
Redbean because it's a single file distributable program that runs on six operating systems. Nothing else comes close to being as simple.
> I want to distribute an Open Source program to end users that does work via a Rest API. A UI isn't strictly necessary but might be required later.

Can you clarify, is the open source program that you distribute to end users serving a REST API (running the server locally), or is it a client (like a CLI) making calls out to a remote REST API?

JVM languages using GraalVM in Native Image mode:

https://www.graalvm.org/22.1/reference-manual/native-image/

If the program requires a Rest API to operate, I would suggest making it a web app using TypeScript with React/Vue/etc. If there's any longevity in usage keeping the client in sync with API changes will be a major factor.
You can compile .NET projects to a single binary - cross compilation is also a thing, so you can compile your tool for platforms other than your own, unlike Python with PyInstaller.
Along with Go, Deno, etc, Rust also cross-compiles easily