-1

I am aware of the existence of several threads on the topic, but I am looking for fresh hand-on experience, that I was unable to find.

I have an application written in C++ (core, linear algebra and image processing) and python (interaction with the operating system, aka text files save, plot production, etc). The two are glued together with SWIG, an awesome tool that widely recommend.

I want to write a GUI for all the major OS (macos, Linux and windows) to help the user to interact with the application, and avoiding the user to modify the python script directly. Using this answer and kivi as a library, or pyQT. Then, as it usually happens, I spoke with a friend and he suggested me to go for Electron or/and photon, and javascript for the GUI. SWIG support also javascript, so I could create bindings also for Javascript, V8 and node.js

More in detail: my application is a python script that is basically used as a configuration file. Inside the python script several methods of the C++ classes are called with various parameters that the user can change. Currently the user is required to edit the python script, and I would like to go for a more user-friendly GUI with some sliders etc. Another reason I use python is to read external files, mostly csv-like, parse them and use them to call C++ methods. The C++ classes are compiled with gcc/clang/MSVC and then wrapped in some python by SWIG. No multithreading, and I don't plan to implement it in the future. I am interested, for future plans, to include some OpenGL objects in the GUI, and for this a Web-based approach, with WebGL and maybe three.js, could be useful since I already have quite some code for it.

Time: ideally the user starts the GUI, sets the parameters, press a button, waits for more or less 30 sec, and then looks at the results. Maybe the user will do it more than once.

Is there a strong argument for going either direction? I am thinking to create a test app to evaluate, but how can I measure the performance of either approach?

BiA
  • 121
  • 1
  • 6
  • 2
    Please describe more your application. Is it multi-threaded? Does it run for a significant amount of time (e.g. a few minutes) without user-visible feedback? Is it free software that we could glance into? So **edit your question** to improve it – Basile Starynkevitch Jun 27 '17 at 14:43
  • What is the role of Python? Do you [embed](https://docs.python.org/3/extending/index.html) it in your application to enable scripting it. – Basile Starynkevitch Jun 27 '17 at 14:58
  • I added some details in the "more in detail" section, are those enough? If not I can expand, but I am afraid of adding useless info. – BiA Jun 27 '17 at 16:20
  • I am now reading the embedding idea in python, and I guess that is very similar to what SWIG does: from their website "SWIG is typically used to parse C/C++ interfaces and generate the 'glue code' required for the above target languages to call into the C/C++ code. " – BiA Jun 27 '17 at 16:21

1 Answers1

0

It is a matter of opinion.

So your choice is between a web based GUI (using perhaps electron or photon - and I know neither of them -, but you should also consider libonion or Wt or other HTTP client libraries directly usable from C++) and a native desktop based GUI using Qt.

I want to write a GUI for all the major OS (macos, Linux and windows) to help the user to interact with the application

You should first be aware that both desktop GUIs (à la Qt) and web GUIs are event-loop based. The loop itself is generally provided by the GUI library, so the control flow is managed by that library, not by your main program. And the GUI loop is run very often (you should not have, in the main thread, some processing started from the GUI which lasts more than a few tenth of seconds, notably with desktop -non web- GUIs).

Another point is that true web applications should be session-aware and be able to deal with several clients (i.e. several browsers) at once.

I would suggest making your application a Qt application (assuming only one user at once would use it) in C++. It probably is simpler. Be aware that the GUI itself should run in the main thread.

Also, any Javascript based approach requires you to master another programming language.

But how can I measure the performance of either approach?

A Qt based approach (with your Qt -behavioral- code in C++, and some C++ code generated by Qt tools) is probably (all other things being equal) faster to run. However, you should probably care more about development (human) time than about execution (computer) runtime.

PS. Perhaps electron and photon are other desktop GUI frameworks above the atom editor for node.js; then what I told about Qt still stands for them. However, you'll apparently code for them using Javascript and not C++

Basile Starynkevitch
  • 32,434
  • 6
  • 84
  • 125
  • thanks for the answer! mastering other programming languages is not a problem. I am fairly good also in JS, even if I don't extremely like it. I have been working with QT and Embarcadero C++, and I always disliked writing GUIs in C++ since most of the time it is a bit overkill. Lot of work to write and maintain, for a GUI that looks out-dated on more or less any device. If there was no other option, I would go for QT anyway. – BiA Jun 27 '17 at 16:23
  • Are you aware of [QML](https://www.qt.io/qt-quick/)? – Basile Starynkevitch Jun 27 '17 at 16:50
  • now I am, thanks! it looks very promising, I'll give it a try, maybe with http://pyqt.sourceforge.net/Docs/PyQt5/qml.html – BiA Jun 27 '17 at 17:07