DDE vs. COM for Python Windows apps

Chris Angelico rosuav at gmail.com
Sat Aug 6 20:08:41 EDT 2011


On Sat, Aug 6, 2011 at 10:33 PM, Kevin Walzer <kw at codebykevin.com> wrote:
> The main complaint I've seen about DDE is that it is very old.

I can't speak about COM, as I have not used it to any great extent,
but DDE has a number of things going for it. Firstly though, "old"
does not need to be a criticism. How many network administrators use
ping(1) on a daily basis? Yet that utility was written in the early
1980s - in computing terms, that's pretty old.

DDE is implemented as window messages. This means it works with
anything that has a window; it might not be easy to send DDE requests
from a console application, and it would be quite tricky to receive
them in a console. It also means that the system can hang until the
request is dealt with. However, it is extremely simple and easy.

There are other options. The best thing to do would be to set down
your actual requirements, and then see what technology best fits them.
For instance:

* Do you need programs running on other computers to be able to
send/receive messages, or just on the local computer (ie, do you need
network support)?
* Do you need asynchronous requests/responses?
* Do you need to support multiple simultaneous requests?
* Conversely, must you explicitly forbid requests when another app is
using the API?
* Do you need to move significant amounts of data around, or could it
all be done with simple 32-bit integers?

If you need networking, far and away the best option is TCP sockets.
But your post suggests that something light-weight is what you're
after.

If you don't care about return values, or alternatively if you can
return an instant response, it might be easiest to simply use window
messages. You pass in a message number and two parameter integers, and
you get back a returned integer. That's enough for a lot of things,
but you have to be able to return very quickly.

You may wish to google for 'Windows IPC'; there's quite a few options
available. Deciding which one is best for your situation is partly art
and partly science... and partly faith in the future. I recommend
choosing the one that looks like the coolest and most fun to play
with; that way, even if the project fails, it's not been a complete
waste.

ChrisA



More information about the Python-list mailing list