KDE Development Using Python Talk at FOSDEM 2005 by Simon Edwards
These are my rough notes only, corrections welcome.
Python is a high level interpreted programming language. Simple syntax, object oriented, garbage collection, dynamic typing, builtin list & hash datatypes are among the key features. The community attitude and language have some core values that really help. Readability counts and is more important than being able to write it as fast as possible or in one line, although Python is considered as a means to do Rapid Development.
He shows an example of a simple programme. Can we guess what it does? It downloads and prints the weather in Brussels, the code is so easy to understand that the audience can see what it does straight away. Although Python does dynamic typing, it doesn't generally do implicit type conversion, e.g. conversion between strings and floats are necessary. Good books include "Dive into Python" and "A Byte of Python". It's fun, removes a lot of the chore work of C++.
A binding translates between two programming languages, in this case C++ and Python. Function calls are in Python, it will check the types and match them to C++ ones then pass the C++. The bindings are a lot of glue to bind the languages together, but they can be generated nearly automatically by SIP. SIP, the bindings generator, reads the C++ headers and automatically converts that into a Python library. SIP removes the burden of a lot of repetition for the coders and generates probably a million lines of C++, so you might want to go and watch "Lord of the rings" while you're compiling kdebindings. PyQt is the bindings for Qt, they are well tested and popular, besides the GPL, there are also commercial licenses available. Thousands of licensees are already using the proprietary version. PyKDE, or course, is the KDE bindings.
Looking at an example of a KDE Python program. It looks similar to any C++ KDE program but without the C++ overhead. The C++ API is transparently translated, so it's easy for seasoned C++ KDE developers to use Python for the job. Simon shows an example using DCOP. In C++ DCOP needs an interface compiler for glue but here that is not needed, it just works. Python generates the objects referred to on at runtime, so this is problably a lot easier to use than the C++ version.
Signals and slots are an important aspect of programming Qt. Of course these are also available using python. The syntax is slightly ugly because you have to use a C++ declaration in your python code: connect(self.combo, SIGNAL("activated(int)"),self.slotCombo). Matthias Ettrich asks why the design is like this, Qt has very few overloaded types, you just watch out for those types and the problem goes away. The philosophy was to start with C++ as much as possible and not invent too much, but he agrees it's probably not the most beautiful solution and that there's room for improvement in this area.
What's the cost? Is it slow? Most of the time you don't notice the difference, because most programs are being I/O bound anyway and the speed critical stuff like drawing the widgets is done in C++ code anyway. There is some memory overhead for the Python interpreter and binding libraries. Startup adds a second or two compared to C++, it's not something to loose sleep about.
On the other hand your performance goes a lot faster. There are only 24 hours in the day (although Scott Wheeler points out that KExtendedDay overriding Day class should be a part of KDE 4). An experienced programmer can probably learn Python in an afternoon, the syntax is small enough to keep in your head so you don't need to look things up too often. Productivity goes up twice compared to C++. Garbage collection gets rid of all the memory beasties that take days to work out what is going on. Debugging is much nicer and faster. You don't end up fighting with autoconf and the build system because there's no compilation step.
KDevelop has some support for Python, such as a class browser, but probably the best IDE for PyKDE is Eric 3, which itself is written in PyQt. It features a debugger among other useful features, such as unit testing, version control. It also would be nice to have a volunteer to improve Python support in KDevelop. Distutils is a nice build/install system to do most of the 'framework stuff', like checking whether (Py)KDE is installed, parsing commandline arguments, etc. PyKDE also creates an easy entry point for new programmers. Not at least, it's possible to create KControl modules in Python.
Alexander Dymo was worried about Simon's comments on the lack of Python support in KDevelop so during the talk he has been managed to integrate KDevelop's Qt Designer to work with Python. As far he knows Eric does not have this feature. Spontaneous applause. However, it is of course possible without a lot of hassle to use Qtdesigner's .ui files with python.