Tags
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.
I’m curious… Did you check out IronPython? It has great .NET and COM interop. You also have access to WPF in IronPython if you decided you wanted to use it.
Great article.
IronPython is my plan B if I ever want to use .NET in the future. At this point it has the same problem as C# or VB.NET, which is the runtime installation.
Now, one interesting option would be to host the new DLR in my application. I had a go at hosting Silverlight 2.0 in a VB Classic application but did not get very far (lots of crashes).
Just FYI…
We (Microsoft) have announced that we are working to make things better for client applications that want to use WPF or Windows Forms. We will be releasing a “servicing release” to .Net 3.5 that will include a client focused installer that will need less than 30MB to install on a Windows XP machine that has no .Net Framework on the system already.
On top of that, a brandable (by your app) installer will help end-users install the framework + your application more quickly and simply than ever before.
We realize that Framework deployment is an issue, and are focused on improving things. We’d love to hear any feedback.
Look for a beta soon…
Thanks,
Rob Relyea
WPF Team
http://robrelyea.com/blog
Python for Win32 is also available in on-line PDF through O’Reilly’s Safari service.
http://safari.oreilly.com/1565926218?cid=orm-cat-readnow-1565926218
do you know any information about this subject in other languages?
Bayrak, you should be able to do the same with most applications written in C, C++, Delphi, Visual FoxPro, etc, as long as they support COM or can call into C style libraries.
HI,
nice articles you have on your site! I’m also a fan of vb6 and python and even mentioned it on one my sites (vegitz.blogspot.com).
my friends and i have also tried making an MVC for vb6 but we came up short and scrapped it, but having seen your article gives us another reason to try it again.
Actually, I was looking for a Book “Moving from VB6 to Python” :)
I am having a *lot* of issues transitioning from the VB6 IDE to the rather rag tag GUI kits available for Python. (I am using wxPython right now).
It was so easy when you could have a project with 8 independent forms and talk to them (or any control on them) just by using the forms name…
Forms could be “static” while your main code ran, etc. etc….
Also, the ability to easily place whatever you want anywhere you want…
Som a book helping to ease the transition would have been nice…
I am sorry the post did not live up to your expectations :-) But I agree with you there is probably some market out there for a book to migrate VB6 applications to non Microsoft technologies.
I played with a couple of “IDEs” for python but never used them for a real application. Did you try PyQT? In the end I ended up dropping VB6 altogether and moving to WPF/c#. Nevertheless I am using CPython and IronPython to automate application testing amongst other things.