Web and Desktop Applications – How to Create an App for Both Desktop and Web

desktop applicationweb-applications

Our team is currently developing a hybrid application. It is similar to Sigma Estimates – a GUI with tables, forms, a sidebar with a tree structure, etc. The software allows a user to work with a database in the cloud – create table structures according to records in the database.

If the connection to Internet is available, then the software, either a web app or a desktop app, has easy access to the database by sending requests. But a user can also make a copy of that database (precisely, a copy of the current version of the database), so that when there's no Internet, he/she can still access records in it. That is why a desktop app is needed.

I think it goes without saying, that both the web app and desktop app should have the same view, same logic regarding its components – tables and so on.

Should we develop a web app and then try to make a desktop version out of it or the other way around? What technologies could be used?

Previously we have looked into JavaFX, but we saw that it's too difficult to create a website out of that. Then we saw Electron, but we are not sure if it is the right choice, because it seams that Electron is only used for desktop.
We were intrigued by Slack's desktop app solution, but our software is slightly different and does not require constant connection to Internet.

Best Answer

There is a difference between coding only once and compiling/linking/building only once. The former is desirable; the latter (which I think you are suggesting) is usually not worth the bother.

Code the core of your application in a language which exists both on the desktop and on the web server (and on any mobile devices you can see it being ported to in the future). Design a standard API for it.

  1. On the server side, build a program which receives requests, uses your API to process them, and presents the results in whatever way is appropriate.

  2. On the desktop side, build a program which has a graphical user interface and uses your API to do the actual work.

Even though the internal logic may be the same, the server-side and desktop use cases are sufficiently different that "creating the same .exe file" is quixotic and unnecessary.

I've done this with a substantial project where the core is C++ and the periphery is C++ (server and Windows), Objective-C (Mac and iOS), and Java (Android). Properly partitioned, this reduced the development effort enormously without the heroism of making a single multi-purpose executable file.