HACKER Q&A
📣 throwaway8903

Easy language/runtime to distribute to desktop users?


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?


  👤 dfinninger Accepted Answer ✓
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.


👤 dillonnys

👤 dragonwriter
> 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.


👤 feet
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


👤 monroewalker
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_...


👤 dilan-dio4
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).


👤 xzcvczx
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

👤 mikewarot
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.


👤 linsomniac

👤 wagslane
Personally I would either use a compiled language, or electron

👤 jart
Redbean because it's a single file distributable program that runs on six operating systems. Nothing else comes close to being as simple.

👤 freedomben
> 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?


👤 pestatije
JVM languages using GraalVM in Native Image mode:

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


👤 karmakaze
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.

👤 GOATS-
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.

👤 brundolf
Along with Go, Deno, etc, Rust also cross-compiles easily