Python vs C for a mail server

Jens Theisen jth01 at arcor.de
Sat Jan 28 07:33:00 EST 2006


Nicolas wrote:

> If it's just a way to throw a programming challenge at your friend's
> face, then you should check whether it's okay to use Python rather than
> C/C++, otherwise he could be charged of cheating by using a more
> productive language :).

Though this comment of mine is likely to start a religious war, it might  
also bring up some useful points.

I'm a bit relucted to swallow the common view of Python being a so- 
productive language, especially compared to C++. I value C++  
productiveness actually much higher than it's performance.

To stick to the mailserver example, I'm pretty sure I'd do it in C++. I  
got very exited about Python when I first saw it, but I've encountered  
several problems that hindered productivity dramatically.

One thing is the lack of static types. The problem is not only that the  
compiler can't tell you very basic things you're doing wrong but also that  
code isn't intrinsically documented:

def send_mail(mail):
        ...

What can I do with mail? In C++, you're looking up what type it is  
(presumably by pressing M-x in Emacs on the word before it) and have a  
look on it's type definition. In Python, it can be quite difficult to tell  
what you can do with it because the information of what will be passed in  
can be several layers up.

Also there is not even symbol-safety: self.not_defined will never rise a  
compile-time error.

And to address the memory management critisism about C++: Unless you have  
cyclic structures (you probably won't have in a mail server), just use  
smart pointers and you don't have to be concerned more about it than you'd  
have to be in Python.

I aggree on C++ libraries being weak on unicode strings though, or even  
generally weak in the libraries (you have the C libraries, but they're not  
very type safe or elegant to use).

I'm aware that C++ is a horrible monstrosity, an argument whiches weight  
depends on the OP's friends C++ experience.

Please don't be offended, but if anyone could make a point of how Python's  
disadvantages in these regards could be alleviated, I'd be very  
interested.

Jens




More information about the Python-list mailing list