Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi-platform gui app in C(P)ython or D

I really like D(2) language and would like to use it for multi-platform GUI application, but I see that its ecosystem is not quite developed. After moving from Linux to (Free)PC-BSD, I see there is even no 64bit compiler ready in the ports and one is not sure if any of GUI libs (QtD, gtkD, wxD) are ready for serious project and we would like to start with the project as soon as possible.

Otoh, I was previously recommended to try with Python which is mature, with many tools, GUI libs etc. but there was question about speed - we have to use one C lib for calculating Ephemeris and write several libraries which would use that C-lib.

However, this might be good (perfect) job for Cython, so my question is what do you think about writing GUI-part in Python (Qt,EFL) and use Cython for performance-critical stuff (binding external C lib and writing our own libraries) instead of (waiting for) D to become ready for serious projects?

like image 523
gour Avatar asked Dec 04 '22 22:12

gour


2 Answers

I'm obviously biased as a Cython core developer, but I can certainly recommend it. The combination of CPython and Cython provides an otherwise hard to reach level of developing speed, platform stability, portability, low-level coding and FFI capabilities, and execution performance, including a very easy optimisation path from quick and simple to highly tuned code at C speed.

I can also warmly recommend Qt as a GUI toolkit. It works very nicely with Python.

like image 110
Stefan Behnel Avatar answered Dec 07 '22 10:12

Stefan Behnel


This is an interesting question for me, as D is my favorite programming language and Python is my second favorite. Right now, as much as I like D, I have to admit that the ecosystem is somewhat immature.

GtkD is ready for fairly serious projects, but isn't quite up to the standards of the GUI toolkits in other languages, especially with regard to documentation. I used it for a plotting library and it worked pretty well, but with some minor hiccups. DWT just recently added support for D2. AFAIK WxD is only a binding, not a D-ified wrapper. QtD still had a few miscellaneous issues, like requiring a patched compiler for certain features. Generally, you can do a GUI project in D2 right now, but it won't be completely smooth sailing.

While Cython is a nice attempt to mitigate pure Python's slowness, it has a few significant weaknesses that make me prefer D when I need performance or the ability to do low level work:

  • It requires explicit type declarations if you expect to get C-like performance out of it. If you try to write generic code, you'll pay a significant performance penalty. With D you can write efficient generic code very easily by using templates.

  • Cython doesn't/didn't properly implement some of the cool features that make Python interesting. For example, it only recently got support for closures. I don't know how rapidly this situation is improving or what other limitations remain.

  • If threading is involved, you still have Python's global interpreter lock.

  • Having to use both Cython and a regular CPython interpreter and keep Cython code in separate modules from regular Python code feels a bit kludgey. There is generally friction along the interface between the languages, especially if you care about efficiency. For example, Numpy types don't "just work" efficiently in Cython.

like image 39
dsimcha Avatar answered Dec 07 '22 10:12

dsimcha