Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt programming: More productive in Python or C++?

Tags:

c++

python

qt

pyqt

Trying to dive into Qt big time but haven't done a large project with it yet. Currently using Python, but I've been thinking -- which is really the better language to use in terms of programmer productivity?

In most comparisons between the languages, Python is the obvious answer, because you don't have to mess with memory management and all that.

However, with Qt I'm not so sure. It provides enough added features to C++ that (from what I can tell) a line of Python code is roughly equal to a line of C++ code most of the time (excluding some additional things like class definitions and structure components). Qt does nearly all the memory management for you as long as you stick with its classes, and provides equivalents to the nice containers you would find in Python.

I've always preferred statically typed languages, but have gotten on the Python bandwagon for various reasons. If programmer productivity is similar with C++, however, I may jump back that way for its other benefits -- more efficient code and fewer dependencies for users to install.

Thoughts?

like image 316
Micah Yoder Avatar asked Jun 29 '10 09:06

Micah Yoder


People also ask

Is Qt better with Python or C++?

Python is an obvious winner in terms of programmer productivity. True, you can write even a complex Qt application much faster in Python then in Qt and my Python skills are far behind the C++ ones.

Which language is best for Qt?

Most Qt developers use C++ (the language that Qt is written in), often in association with QML. There are however, other programming languages that can be used with Qt.

Is Qt good for Python?

For Qt/C++, Qt Creator is an excellent choice, but we also have other options such as MS Visual Studio with the Qt plugin. However, when searching for an IDE that supports both, Qt and Python very well, we quickly run out of options. Either we have good Qt/QML support or we have good Python support.

Is Qt written in C?

Qt is not a programming language on its own. It is a framework written in C++. A preprocessor, the MOC (Meta-Object Compiler), is used to extend the C++ language with features like signals and slots.


2 Answers

If one or the other, I'd actually suggest Python in spite of being a C++ enthusiast. With Python code you don't have to bother with the MOC, portability, build times, etc. Just compare the work involved in implementing a QT slot in C++ vs. PyQT or PySide, e.g. I find it to be much less of a pain to deal with widgets this way (much greater productivity). You can still invoke C++ code from Python in cases where you need the added performance.

If you do use a combination, consider extending Python rather than embedding it. Python is generally better suited to embed C/C++ code than to be embedded into a C/C++ system. It also tends to make more sense that way as applications are generally composed of far more mundane, non-performance critical code than performance-critical code, so writing your application primarily as a python application with C/C++ functions attached to it fits that kind of system design better.

like image 168
stinky472 Avatar answered Sep 24 '22 07:09

stinky472


My Opinion (having tried out C++ and Python in general and specifically in Qt case): Python always wins in terms of 'programmer productivity' and 'peace of mind'. PyQt represent Qt very well and hence question doesn't remain of "Qt with Python" or "Qt with C++", in general python is more productive unless off-course you need speed or something which isn't available in python.

Best way for you to arrive at the answer would be to write a simple project first in C++ and then same project in python and compare, but that could be biased towards python as after coding the project once you may find it easy in Python, so try another project too and first do it in Python and then in C++.

like image 30
Anurag Uniyal Avatar answered Sep 22 '22 07:09

Anurag Uniyal