Fog Creek Software
g
Discussion Board




Python for Windows development?

I don't do much (or any) Windows development anymore.  I used to do alot of development in Visual Basic (and I still occasionally support those products).  I've also done some COM components in ATL.  Currently, I do alot of non-Windows C++ development and web scripting in PHP.

I'm in the early planning stages of an application targetted at Windows and I now have to make the platform choice.  I'm not interested in using VisualBasic anymore for a number of reasons: a) VisualBasic is being phased out. b) I want to take this opportunity to learn something new. c)  The application isn't really suited to VB.  I'd also rather poke my eyes out with a fork than do it in C++/MFC.

I have VisualStudio.NET installed and, although I've only done a few minutes of playing around with it, I like it.  But the recent discussion over distributing the framework has got me second-guessing that choice.  The product will be a download and I'm targetting only semi-technical consumers.  It also seems like below the surface it can get very complicated.

Based on some discussion in this forum and elsewhere I've been taking a look at Python.  On the surface, I like what I see:

wxPython seems like a very capable GUI library.  I was impressed with the example applications and their source code.

py2exe can convert your python programs into single-click-to-launch executes.  The python runtime is 3MB -- which is very small compared to the alternatives.

Python has a rich library of source code / modules for a number of tasks.  Including some state-of-art networking.  This is a major plus.

I'm curious if anyone else has done any python windows development and what they think of the language/platform as a whole for that purpose.  Or maybe I should just stick with .NET...

Almost Anonymous
Wednesday, February 25, 2004

Have you considered REALbasic?

I, too, am looking around for my development langauge for new programs.  (Our current 20 programs are in vb 3 and vb 6).

Our core architecture has been sorely in need of rewrite for years now.

I'm looking at REALbasic it's pretty slick.

It's OO, although not as powerful as Delphi.

But it compiles for Mac, Windows (98 and above) and...very soon... Linux.

(I personally think there's no real demand for Linux desktop apps.)

The real Entrepreneur
Wednesday, February 25, 2004

TrE: 5.5 is out as of today.  Haven't looked at it yet, though.

Sam Livingston-Gray
Wednesday, February 25, 2004

Yes, wxWindows is cool. But that depends on your point of view.

Put wxWindows and the Delphi VCL & IDE side by side, and see which is the development environment where you can develop a GUI faster.

wxWindows will LOSE big time. Delphi is the most efficient tool around, and VB is not far behind.


On the other hand, when you develop the program's algorithm, you will do it faster with Python. There is a real development speed increase that Python gives you over Java, Delphi or C++.


However, I found that for the apps I write, the speed increase due to Python is always eaten up by the slowdown due to slow building of the user interface with Python / wxWindows.

So, for me Python + wxWindows is a slower development environment than Delphi - I develop slower with Python + wxWindows than with Delphi.

MX
Wednesday, February 25, 2004

I strongly recommend Python, especially incomparison with VB and C++.

First, it is an exceptionally powerful language. The built in tuple, list and dictionary data types simplify run time data structures a great deal. Weak typing is something you either love or hate, I happen to like it, not least because it eliminates a slew of (declarative) code which is only there for the benefit of the compiler and does not contribute to solving the problem. Its exception handling is very clean and robust.

Second, it comes with a very extensive and well supported library.

Third, its cross platform capability (especially with wxPython) is second to none. You can use Windows specific capabilities, but I see no reason to do so. Apple, Linus and the various Unices may not be a huge percentage of the total desktop market, but they still account for several millions of seats world wide, so why throw away the opportunity?

Fourth, the general level of community support is excellent.

Certainly it is not as fast as a purely compiled language, but I've never found it particularly 'clunky'. In any event there are tools such as pyrex that convert python into C extensions to the python interpreter.

Go for it!

David Roper
Wednesday, February 25, 2004

When I use py2exe, the runtime is 700 k (but without UI).
Using wxPython would certainly be a good idea if you want to be cross-paltform. But for Windows-only-non-.Net apps, I'm afraid you can't beat VB/Delphi, at the moment. I don't know RealBASIC though.

Pakter
Wednesday, February 25, 2004

I need to be able to do some complex networking as well as some subtle GUI.  VB doesn't do complex networking or subtle GUI all that well.  Python might not be windows-oriented enough for what I need.  For example, I might have to run part of the application as a service.

RealBasic seems like a very good replacement for Visual Basic -- but I don't want to paint myself into a corner language-wise.  I at least know that .NET and Python are well supported and aren't going to go away.  Delphi seems to be going the way of Visual Basic.

Perhaps .NET is the logical choice and I should just live with the runtime requirements...

Almost Anonymous
Wednesday, February 25, 2004

If you want to do MFC-style stuff, you want PythonWin aka win32all.  It's very "windows-oriented" in terms of being close to the Windows APIs.  It also gives you the ability to write COM clients and servers.

If you like Delphi, there's some Delphi-Python integration stuff available; see under the "Scripting" thread in the Ask Joel forum.

If you want to do wxWindows, take a look at PythonCard and some of the other visual builders for wxWindows.

Finally, note also that py2exe can build NT services and COM servers as well as console and GUI apps.

Phillip J. Eby
Wednesday, February 25, 2004

I downloaded Boa Constructor (along with Python, wxPython, win32all, py2exe, etc) and I've been playing around with it.  It's fairly impressive -- I was able to drag'n'drag a simple GUI interface without any knowledge of Python and have it run.

I'm still a bit on the fence.

Almost Anonymous
Wednesday, February 25, 2004

One of the nice things about Python is that experimentation and prototyping is very cheap, since the language is so expressive. So even if you end up going with something else in the end, spend a little more time with Python experimenting; you'll get useful ideas that you can use regardless of what you end up using.

And you might just discover that you've just finished your application. :-)

Chris Tavares
Wednesday, February 25, 2004

Where are the biggest advances going to be? Which language framework is Microsoft pushing big time. Where are you going to find the biggest pool of resources to support / further develop the application?

Gotta be .NET hasn't it?

Betamax was superior to VHS but that was irrelevant in the long run.
Noone got fired for buying IBM.

More good reasons to favour .NET

The only downside, the ONLY downside (as long as we're excluding platform independence) is the runtime. But that won't be a problem for too long.

gwyn
Wednesday, February 25, 2004

wxWindows gives up some things by being cross-platform, but if it meets your needs go for it.

http://www.oreilly.com/catalog/pythonwin32/

..and python is the superior language of course ;-)

fool for python
Wednesday, February 25, 2004

"Betamax was superior to VHS "

Betamax was fatally flawed because the tape only held 60 minutes, not enough to record a movie.

wxPython is amazing, but it takes some study to really understand sizers. Once you can control them, and you understand how to create and handle cutstom events, it's really easy to make the GUI do whatever you want.

Tom H
Wednesday, February 25, 2004

I'm just completing a 6 month wxPython project for an office environment desktop app .  If wxPython had a better GUI builder it would be my tool of choice. 

My database,networking, business logic, and general event handling were a dream to write but I would get stuck in sizer hell anytime I had to creat a GUI. Once it was built I enjoyed the wxWindows api which is intuitive,  comprehensive, and amazingly featureful.

I tried using the few GUI builders out there for wxPython but they are either weak (Boa constructer), flaky (wxGlade), or immature.

Anybody out there looking for software ideas, I'd pay good money for a kick ass python IDE with a solid GUI builder, editor, debugger, and 1 click compiler. And bonus dollars if it had a super easy way to create installable packages for Windows, Linux, and OSX.

Oh yah, check out the mcmillan installer, sorta like py2exe, but it does all the tedious parts for you.

lumberjack
Thursday, February 26, 2004

Hi,

If you were into old school Windows development (C++, ATL, COM), you might like my 'Venster' library.
It is based on the excellent ctypes package and provides a
kind of minimalistic approach to Windows development with Python.
You can use it to create Py2Exe generated full blown windows gui apps (.exe) of under 1 Mb.

http://venster.sourceforge.net

A beautiful day
Thursday, February 26, 2004

Python does not, as some people seem to think, have weak typing. It has dynamic typing, which is not the same thing. A nice explanation about strong vs. weak and dynamic vs. static typing can be found at http://www.artima.com/weblogs/viewpost.jsp?thread=7590 .

Roel Schroeven
Thursday, February 26, 2004

Roel,

They say that you learn something new every day; I just did. Thanks for the link.

David Roper
Thursday, February 26, 2004

"""Where are you going to find the biggest pool of resources to support / further develop the application?

Gotta be .NET hasn't it?"""

Actually, if I was going for that argument, I'd say it has to be Java.  :)

Luckily, however, Python can integrate with either .NET or Java, and so is a pretty safe bet regardless of platform.  For binary integration there's:

http://zope.org/Members/Brian/PythonNet/

and

http://jpe.sourceforge.net/

for .NET and Java respectively.  And, if you want to compile directly to the platform of choice rather than use an "unmanaged" language, the IronPython CLR compiler is coming, and Jython is already here.

Python really is one of the most platform-neutral language choices you can make; saying that you shouldn't use Python because of .NET is like saying you shouldn't program in C because of Windows.  :)

Phillip J. Eby
Thursday, February 26, 2004

I'll second Mr Lumberjack's comment (because he's OK!). wxPython is good, but there's no good dialog editor for it. And it doesn't feature the 10,000,000 gadgets and addons you can get for MFC and VB. I don't think it would convert any MFC or VB users, but Python is such a nice language that many people don't really mind.

I haven't found the sizers _too_ painful, but it can be a bit tiresome to set up. You'd probably find it quite pleasant if you want to generate your dialogs on the fly based on lists of attributes, but if you're used to drawing them by hand it's much slower. The end result is generally nicer than the equivalent in MFC or VB, though, because you get resizable dialogs for free.

I don't use .NET, but I believe there are some packages to make Python play nice with .NET. Don't know if they generate the official .NET VM code, though, or whether it's just Python bindings for the .NET classes.

Insert half smiley here.
Thursday, February 26, 2004

What about db accesss on windows? Specifically MS Access.

Delphi had the benefit that you could put a native driver and not be dependent on Mdac, or Jet. Is this similar with python?

Karel
Thursday, February 26, 2004

Python can use either native DB drivers (Oracle, Sybase, PostgreSQL, etc. etc.) or ODBC.  See:

http://python.org/topics/database/modules.html

for a list.  In addition, any of the MS-specific COM-based DB access stuff (DAO, ADO, etc.) is available if you use PythonWin (which lets you access COM object from Python).

Another good source of infformation on Windows Python programming:

http://www.python.org/cgi-bin/moinmoin/WindowsBooks

It's a bit old at this point, but covers the basics for getting your feet wet on a wide variety of Windows-specific topics like COM, GUI options, DB access, etc.

Phillip J. Eby
Thursday, February 26, 2004

Python is an impressive language which shows a lot of potential as it grows (daily!) from being a nice scripting language.  cf. projects like psyco.sf.net , stackless.com , and codespeak.net/pypy/

I'd say C#/.NET 1.2 is very competitive in terms of language features and significantly faster in execution (though _perhaps_ a bit slower in development), but the fact that Python is open-source means a lot to me; it allows me to tailor anything to my needs, and not be quite as dependent upon any minor bugs in .NET.  Python also has better cross-platform support than C#, though mono / dotgnu are slowly improving.

IMHO, one of Python's main faults is its inability to statically bind variables to types (e.g. in function signatures).  Dynamic binding is very powerful, but a lot of useful type-checking and optimization can be performed when type information is known ahead of time (which, in practice, is perhaps 80% of the time?).  IIRC, this is the main stumbling block to efficiently compiling Python to .NET IL (i.e. Python.NET).

This fault also leads to hidden contracts with Python functions... i.e. sometimes you might have to go through the source code to determine exactly what (member data/methods) is required of an object that is passed to a function.  This can also lead to bugs which are a bit more difficult to track down.

IIRC, Guido intends to implement optional type annotation at some point in the future, though I don't know when.

If you'd like to study Python by example, I would recommend the cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/

wxWindows is quite advanced in most areas and strangely infantile in a few others.  Though it can take a while for patches to be accepted, being open-source means you can tailor it to your needs independently if necessary.  If cross-platform execution is important, wxWindows seems like an excellent solution.

Of course, between wxWindows libraries and Python's runtime, you might have a similar dilemma as when using the .NET runtime (at least when dynamically linking).  I remember something on Joel's site about a commercial .NET IL linker, so you *might* also be able to statically link with either of them.

Basically, if you like developing in Python more than C# or Java, want cross-platform support, and execution speed is not a high priority, choose Python.

@lumberjack:
in terms of commercial products:
- wingide.com is a very capable (Tk-based) Python IDE.
- wxDesigner at www.roebling.de is a good wx UI designer which can output to Python.

ingenuus
Wednesday, March 3, 2004

*  Recent Topics

*  Fog Creek Home