Python vs. C#

Joe Cheng code at
Tue Aug 12 07:22:52 CEST 2003

(Disclaimer: I'm a relative newbie to Python; I started learning it a few
months ago because of all the buzz on about it and Ruby (also
worthy of consideration if you like Python).  On the other hand, I've been
programming full-time in C# since January (before that I programmed almost
exclusively in Java for a few years).)

>From a purely language point of view, I think the comparison can be boiled
down to two main points.

* Python is dynamic, C# is static.  You've got a C++ background, so it
doesn't sound like you would consider C#'s static typing a liability, nor
would you likely fall in love with metaclasses and the like.  So, most of
the arguments along the lines of "C# is too inflexible" will probably not be
relevant to you.

* Python has some _really_ convenient syntactic sugar.  Being able to
declare lists, tuples, and hashes as literals can be nice.  List
comprehensions would knock out half the for/foreach loops I have to write in
C#.  I also consider the indents-instead-of-braces to be syntactic sugar--I
for one really like them (the indents, that is).  You can simply write code
faster in Python; this is not really controversial.  I'm a newbie in Python
but very familiar with C#, and still for a given programming task I'd likely
be able to do it almost as fast in Python.

* It's usually easier to read a given chunk of Python code than the
equivalent chunk of C# code--as long as it's clear what types you're dealing
with (a given in C#, not so in Python) and you're not doing any clever
dynamic stuff like the "memoize" function someone else talked about in this
thread.  C# code is cluttered but simple; you could say Python code is
readable but potentially tricky.

And just to throw in some further real-world differences, that I'm not sure
have been covered yet in this thread:

* .NET has, as you'd expect, really strong Win32/COM interop stories.  If
you're building, say, a consumer-quality desktop app, these are really

* .NET has a really nice remoting framework in .NET Remoting.  It is not
only quite performant and flexible, but dead easy to use.  Same for XML
handling, and (from what I hear--is anyone actually building any??) web

* I (and most serious programmers I've talked to) don't see a great deal of
value in the multi-language support of .NET, unless perhaps you are a class
library vendor (and all the .NET libraries I've seen have been written in

* I don't really like VS.NET, but I have to admit, I haven't heard of
anything even close for Python.  (On the other hand, in everything but GUI
builders, the best Java IDEs blow away VS.NET.)

* C#/.NET has to be one of the most mature "version 1.1" programming systems
in history.  (I'm too young to be making definitive statements about
programming history, though...)  You can tell by reading Chris Brumme's blog
the amount of sophistication they have already achieved.  Frankly, it's a
little frightening how much MS can accomplish in just a couple of
years--when they want it bad enough.

* Math.sin(x) versus sin(x)?  Really, who cares??

* The .NET community does not seem as clever and innovative, nor as
passionate, as the Python community.  You sorta get the sense that everyone
who works with .NET is getting paid to do so, while Python hackers bang away
on their keyboards with glee.  And it feels like 90% of the innovation in
the .NET realm comes from Microsoft itself (or perhaps, 60% from MS and 30%
from the Java open-source community--NAnt, NUnit, NLucene, etc.).

To summarize, I don't particularly like C#--I'd rather be programming in
Java with IntelliJ or Eclipse.  There's nothing really fun and exciting
about programming in it day-to-day (well, maybe if you're coming from C++
you'll be excited about not having to worry about memory leaks or
segfaults).  The libraries generally work as billed, the compiler gives
useful warnings, the debugger is well-integrated and easy to use, the
documentation is comprehensive if not particularly deep in places.

In contrast, I like Python very much (well, actually, Ruby is the one that I
really like--but close enough).  Python is worth knowing, if for nothing
else, then at least for banging out one-off scripts or string processing
programs or command line utilities (even ones of significant complexity).
The syntax feels nice, the conciseness is very refreshing, the interactive
programming environment is addictive.

However, when it comes down to building the big, hairy, slightly nasty (just
admit it) software that brings home the bacon, sometimes it's just gotta be
C#.  And if you live in Seattle, I'd say it's gotta be C# all the way.

More information about the Python-list mailing list