I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange. Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?
Yes, I do think that Python would be a good replacement. I understand that the Twisted Python framework is quite popular.
Assuming that you have control over the environment which this application will run, and that the performance of interpreted language (python) compared to a compiled one (C) can be ignored, I believe Python is a great choice for this.
I'd say that if:
- Your C code contains no platform specific requirements
- You are sure speed is not going to be an issue going from C to python
- You have a desire to not compile anymore
- You would like to try utilise exception handling
- You want to dabble in OO
- You might choose to run on many platforms without porting
- You are curious about dynamic typing
- You want memory handled for you
- You know or want to learn python
Then sure, why not.
There doesn't seem to be any technical reason you shouldn't use python here, so it's a preference in this case.
If I was faced with a similar situation I'd ask myself a couple of questions:
- Is there anything more important I could be working on?
- Does Python bring anything to the table that is currently handled poorly by the current application?
- Will this allow me to add functionality that was previously too difficult to implement?
- Is this going to disrupt service in any way?
If I can't answer those satisfactorily, then I'd put off the rewrite.
Remember as well, you can leave parts of your program in C, turn them into Python modules and build python code around them - you don't need to re-write everything up-front.
Yes, I think Python is a good choice, if all your platforms support it. Since this is a network program, I'm assuming the network is your runtime bottleneck? That's likely to still be the case in Python. If you really do need to speed it up, you can include your long-since-debugged, speedy C as Python modules.
If this is an embedded program, then it might be a problem to port it since Python programs typically rely on the Python runtime and library, and those are fairly large. Especially when compared to a C program doing a well-defined task. Of course, it's likely you've already considered that aspect, but I wanted to mention it in the context of the question anyway, since I feel it's an important aspect when doing this type of comparison.