Python vs. C#

Joe Cheng code at joecheng.com
Tue Aug 12 10:16:33 EDT 2003


Hi Doug,

I have no particular love for C#, but your criticism seems a little too
harsh...

> I've used C# full time for over two years.  Finally I got disgusted
> with it and swtiched my entire company over to Python.

That must include plenty of time with the beta, then?  Is that where most of
your bad experiences with C# were encountered?

> From my experience I have found the following:
> -C# is buggy and inconsistent.
I haven't seen this...

> -C# debugger is a piece of crap, the immediate window is worthless
I've found the debugger (VS.NET, VS.NET 2003) to be easy to use, and work as
expected.  You can easily hook into existing processes, so you can for
example debug client and server pieces from the same window.  The main
complaint you might have is a lack of "Edit & Continue" support.  Is there
something as good for Python? (an honest question)

> -C# Garbage Collection algorithm is worthless, essentially it never
> collects until it's way to late.  By that time you are screwed.
Can you elaborate?  My understanding is that the CLR's GC is a quite
sophisticated, performant, generational garbage collector.  And if I'm not
mistaken, interacts with the OS memory manager to vary its parameters
depending on how much free memory is available system-wide.

> -C# static typing is a major pain in the ass, it causes far more bugs
> and errors than having loose types like C ever did.
I've heard the argument that static typing slows down development, but
actually *causing* bugs??  Over C-style typing!?  I'd like to hear more.

> -The .net widgets are slow and *really* buggy.  Events get lost, they
> choke are large volumes of text, and the drawing.dll just pukes on
> load randomly.
OK, some of the widgets are slow and buggy... but I believe most of the few
bugs I've encountered have been due to problems in the underlying native
Win32 widgets.  But I agree, this is an area where they could stand some
improvement.

> -The lack of a multi-line string drives me bananas.  Try building up a
> big HTML form using a string builder sometime.
> (this is just the beginning of a long list)
I believe if you prepend the string with @, then multi-line strings are
accepted.  (However, you still need to \escape any literal double quotes.)
They really need to add multi-line strings to Java... long SQL statements
are also pretty annoying to concatenate, grrrr.

> Python:
> -Internally consistent, cleanly designed, to the point of being
> beautiful
It is pretty nice.

> -Dynamic typing is amazing
Sure, if that's what you're into...

> -First class functions (try mimicking that in C# - ha)
Delegates get you a lot of what you need in C#.  They are less convenient
than fcfs in the same way that C# collections or arrays are less convenient
than Python's (from a static/dynamic typing point of view).  And C# will get
anonymous delegates in the next version, which will be nice--a little bit
like Ruby blocks.

> -Tuple unpacking is a god send
> -List types are the cats meow
> -Dictionaries are blazingly fast
> -using metaclasses and the magic methods gives you amazing power and
> flexibility
Agreed, agreed, agreed, agreed.  Working with collections in Python is a
joy, and metaclasses and magic methods are things you simply can't get in
C#.  (Well, there are dynamic proxies... but it's definitely not the same)

> Overal C# is a buggy, slow, half implementation of Java.  It's written
> by committe for people dumber than themselves.  If you need to perform
> some function that pushes the limits of the language, it will either
> choke, or throw an error saying it was explicitly disallowed.  It's
> painful attempting to write real world apps in C#.

I've encountered more bugs in Java than C# (ok, I've worked a lot longer
with Java...) and certainly would not call C# slow compared to Java.  And
it's *certainly* faster than Python, by 5-10x if I remember correctly
(unless you count C... but then you could pull the same trick with C#).
C#'s startup time compared to Java is nil, and the benchmarks between the
two for sustained performance have been inconclusive from what I've seen.

Certainly the designers of C# were designing for people dumber than
themselves--that includes almost everyone else in the world. :)  But I
disagree with the lowest-common-denominator argument you're making.  The
same has been said of Java since its inception, yet Gosling insists at every
turn that he designed the language so *he* could work faster and better.  If
anything, C# gives you more rope to hang yourself with than Java.

> When you can come back with some real world experience using some of
> these languages you are bashing then your opinion might mean
> something.  Right now you are just spewing Microsoft hyperbole and
> propaganda.

On the flip side, I think Python can stand on its own merits without needing
its advocates to exaggerate the shortcomings of its competition--assuming
that is what you're doing.  If not, and you encountered the behavior you
described above with a release version of .NET, I (and a whole legion of
rabid Java coders on TheServerSide.com) would love to hear about it...

Please take this post in the spirit in which it was intended--I want only to
balance your unrestrained criticism of C# from the perspective of one who
has had a pretty OK experience with it, not take anything away from Python.
And again, C# is not my favorite language--not even over Java.








More information about the Python-list mailing list