1

In my earlier days of programming, I was using Visual Basic for learning. It taught me many concepts, and I was able to make some cool programs (in my opinion, anyways...). I have expanded my horizon to basic C/C++, PHP, and MySQL.

One of my most favourite projects, I want to turn into a multi-platfrom (for x86/x64) windowed application, and have it open source. I decided on the license already, but I want to know, before I start developing in a new language, how can I choose which language to use, that is multi-platform, and allows for windows to be created? I do not wish to use web technologies, as the application will work with lots of local files at a time.

This is not a question about which technology is better, but about which one would be useful for this project. I know something has to be possible, because there are apps that run as Mac OSX binaries, Windows binaries, and even Linux binaries, all in windows (i.e. VLC Media Player, Firefox (Ice Wheazel), etc)

  • The applications you mention (VLC, Firefox) have separate binaries for each OS. – Gort the Robot Apr 13 '14 at 3:07
  • @StevenBurnap I understand that, but they have the same libraries and such, do they not? Just a different front end for each OS? – Canadian Luke Apr 13 '14 at 3:08
  • That depends entirely on the application. Usually there's some sort of compatibility layer, and libraries are used that are themselves ported to each OS. – Gort the Robot Apr 13 '14 at 3:10
  • Alright @StevenBurnap, I guess my question is, do I just make the libraries for my application (i.e. in C or C++), and then have people create front ends for different platforms? – Canadian Luke Apr 13 '14 at 3:14
  • There's no short answer. There are many approaches to this. If you want to write a multiplatform app, your best bet is to look at frameworks intended for this. – Gort the Robot Apr 13 '14 at 3:21
2

It depends primarily of what platforms you're aiming at.

If you target only PC platforms (which none of is very exotic), then you have many options regarding language (C++, Java, Python, Go, etc.) and cross-platform GUI framework (Qt, GTK, SWT, Swing, wxWidgets, etc etc). Portability shouldn't be main concern when choosing a language for PC-only program (pretty much everything that is not OS-specific should be portable).

If you want to target PC and something more (web or mobile), you need higher degree of portability. Architectural style is crucial, because you want to fence off platform-specific pieces from portable code. The most popular style that addresses portability requirement is layered architecture (portable code goes into middle layer). Each layer can (and often will) be written in different language. You may want to consider structuring your code in layers even in case of PC-only program (OS-specific things will probably pop out).

Language possibilities are narrowed when targeting something more than PC. Depending on which particular platforms you're interested in, it can also make writing everything in one language impossible (unless you're prepared for writing your own compiler).

  • For PC and mobile, C++ is the right choice to write portable code (logic layer) in, because all mainstream mobile platforms support it. For mobile GUI - Qt or platform-specific solutions (Java, ObjC and C#). Choosing Qt can speed everything up (most of the code runs everywhere) but some low-level knowledge of Qt and mobile platforms may be required to make it work. The more GUI you have, the more profitable choosing Qt will be.
  • In case you want to target PC and web, you have Java, Python and Go languages. If you choose Java, you will have everything more homogenous (frameworks like GWT and Vaadin enable writing client-side code in Java). If you choose Go, you will have younger (more fresh) language than Java, that requires less boilerplate, and doesn't need VM to run (less parties involved = less problems), but you will need different language for web GUI (JavaScript or Dart).
  • Things get really complicated if you want your program to run on PC, web and mobile and you want PC and mobile version to be self-sufficient (working without server component). In this case there is no single language that will run everywhere. I would probably take PC+mobile approach for logic code (write it in C++) and then, either create bindings to other language available on web platform, or write server software in C++. Another possibility is to write logic in Java (PC+web approach) and then write (using LLVM) a compiler that translates java to languages available on targeted mobile platforms. Either way, extra effort is needed to make it work on third platform type.

Above list is neither exhaustive nor complete.

After choosing technologies, I recommend designing interfaces between layers, then planning the implementation.

1

Each OS uses its own file formats for executable files and shared libraries and each OS also has its own API for applications to interact with it. This means that generally, binaries built for OS A can not be used on OS B.

There are two ways to write applications that can be used on multiple platforms:

  1. You use a virtual machine (VM) that hides all/most of the differences between the OSes. Web technologies are based on this (with the browser providing the VM), but also a languages like Java and interpreted languages.
  2. You build separate binaries for each OS that you support and you use cross-platform libraries to hide most of the differences between the OSes from your main application logic.

When choosing a language for multi-platform development, the main considerations are

  • What platforms do I want to support
  • What languages am I comfortable in using
  • For which of those languages are there VMs or compilers targeting all of the required platforms
  • Do those languages support the features I want (e.g. a GUI), possibly through libraries
  • For natively compiled languages, for which do there exist cross-platform libraries that support all required platforms or am I prepared to write one myself.
  • You may want to check embarcadero's rad studio. They have a cross platform framework which makes development easy, especially the gui – John Kouraklis Jun 19 '16 at 18:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.