, ,

When we started building GeneXproTools (then APS) back in 2000 we had the choice of building the user interface either with Visual Basic 6.0 or with MFC. We agonized over this issue for a while because our backend is all in C++ making MFC the better choice for interoperability. On the other hand we had very limited resources so we ended up choosing VB to save time. With the event of .NET VB development was stopped but with the help of third party components it has survived and improved quite a lot. Fast forward to 2008 and GeneXproTools is a large application with many components written in VB and C++. So basically nothing changed and but we are starting to feel the drag of a language, Visual Basic, that hasn’t evolved at all.

So, we started mulling over what to do. Move to MFC? Seems like a good idea, especially because Microsoft moved quite a bit in this area with the release of a new toolkit that finally brings MFC into this century. On the other hand it is still C++ and programming UIs in C++ and MFC is still harder and resource intensive.

Or should we go with .NET? This seems very sensible. There are lots of very nice third party controls, there’s a tone of code and documentation out there and it is comparable to writing code in VB Classic as far as resources are concerned. But the question is what version? Just like with VB 6 Microsoft dropped the development of Winforms and is concentrating on WPF which is a very exciting technology. But the problem is download size. WPF ships with Vista but has to be manually installed in XP. The download can be as large as 60 Mb if you go with the latest release of the framework and, what is more important for us; many companies restrict the installation of frameworks on their desktops.

It is a hard call to make because we want to improve many functional areas in the product, not just the base application. The ideal case would be a language and library that can interoperate with COM components and C libraries, has good tool support, it is more productive than VB Classic, has all the trimming of a modern language, has a good community and documentation and it is redistributable as a single library or group of libraries. C#, VB.NET and Java fit all the above criteria except for the last and MFC fails in the productivity arena.

In comes Python

I have been a long time fan of Python with its indenting significance and down to earth syntax. But it was always an idle kind of interest with lots of reading involved but no action. So, last week, when I had to make a decision on the direction to take for the next version of GeneXproTools I decided to give it a chance and started developing one of the new sub systems in Python.

Setting up the development environment was pretty painless. I installed Activestate’s distribution of Python 2.5, downloaded and installed Eclipse and PyDev and started playing with Python’s COM support. This part is critical for us because GeneXproTools is in divided into three blocks: the base which is the executable, the plugins, which are the several screens and the backend processing units. All communication between these blocks is done through custom COM interfaces and any new features within each block must be able to implement several interfaces too.

Python has support for COM although I only found one book about it (Python Programming On Win32) which it is out of print. You can find second hand copies at a premium rate or you can have O’Reilly reprint it for you. But, best of all, there is a full chapter on Python and COM available at the publisher’s website which is enough to get you started. There is also a very active and helpful mailing list (python-win32) manned by no less than the python win32 development team. Having said this, it is not a seamless experience, especially if you are expecting the same level of hand holding as in VB Classic. Working with Python and COM resembles to working with C and COM. But it works and I could find workarounds and solutions to all the issues with help from the documentation, the mailing list and the Win32 Extensions website.

After a week of hard work I was able to implement a large proportion of a new screen for the upcoming GeneXproTools 5.0 where 90% of the code is Python. And I am surprised that it was so easy. All my programming experience is in languages like C#, VB and C++ and Python felt very natural and all the small syntactical differences were a pleasure to discover and use. Granted that I am not writing Python like a true Pythonista, but these early results are very encouraging and were enough to make me adopt python for the foreseeable future.

Of all the dynamic languages we looked into – and GeneXproTools generates code in 16 languages, many of which are dynamic – Python seems to be the most accessible of all and one of the few that is windows enabled from the start.