DEV Community

Discussion on: Cross compilers, native compilation, or some kind of VM (like Java)?

Collapse
 
chand1012 profile image
Chandler

The issue with supporting all three of the major platforms (Linux, Windows, macOS) is that without using CI/CD with unit testing you're going to have to try and run the program on all of the systems. This is why when I do attempt to write a program that is supposed to run on multiple OSes I tend to leave out macOS as I don't have access to an OSX machine nor an easy way to create a VM for macOS. I have in the past made a macOS VM on my laptop but that took days of tinkering and is very frowned upon by Apple. Plus, assuming you don't do any tedious workarounds, you absolutely need an Intel processor to get it up and running.

In my opinion, the easiest way to create cross-compiling/running apps with little in the way of issues with OS compatibility is probably going to be Java, or something similar. You are allowed to bundle a JRE with your application (provided you meet Oracle's TOS or decided to use an open source alternative like OpenJDK), and there are still a great deal of users who still have a JRE on their computers. This is assuming they would have another application that requires it, which if they're running older software is definitely the case. Plus, if a GUI is needed, Java has a few cross-platform libraries available for that. Finally, you could go the old fashioned route of just saying "You need to have a Java installation to run this program".

Python isn't a bad choice, but packaging the application is a pain, because like Java, it needs a way to run. Now you could go the intermediate route and run Python on the JVM with Jython, but unless a library is written in pure Python, or you end up just using Java libraries, you're going to be limited as to what you can use to write your application.

If native is a requirement, I think Go would be the best option. You can easily cross compile for basically any platform, and most of the popular Go libraries had cross compatibility in mind when they were written. The issue is going to be with GUIs. This is because, while Go has plenty of cross compatible libraries, there is only a handful of underdeveloped cross platform GUIs. If this program is command-line only anyway, I'd write it in Go.

Finally, what I would actually do: Don't distribute an application to the user at all. With how the world of development is going and how the web is evolving I think that desktop applications are dying, with exceptions. Video games (contrary to what everyone is trying to tell us) will still be native, there are plenty of scientific computing, engineering, software development, among many others, that would require access to the operating system or the user's hardware. Unless you absolutely need access to a regular end-user's hardware or operating system, most people are going to be just fine with using said application in their browser, "on the cloud" as the marketing teams say.

Sorry for the speech, just thought I would put in my two cents.