Re: Python vs. C#

Discussion in 'Python' started by Duncan Booth, Aug 11, 2003.

  1. Duncan Booth

    Duncan Booth Guest

    "Brandon J. Van Every" <> wrote in
    news:3f357a9b@shknews01:

    > So again my question is, language-wise, what can I get done with
    > Python that I can't get done with C#? What is easy to express in
    > Python, that is tedious, difficult, or impossible to express in C#?
    >

    C# (or rather the CLR) has collection types that are superficially similar
    to Python's list and dict types. A lot of C# programming becomes much
    easier when you start using ArrayList et. al to do things in a Pythonic
    manner, BUT with C# you cannot manipulate objects without casting them back
    to a known type. This is a pain. If I have two objects and they are both
    integers, then in C# I have to cast them to 'int' before adding them. Or if
    they are strings I have to cast them to string before adding them. In
    Python I know they are a suitable type, so I just add them without thinking
    about it.

    What this means is that you waste a lot of energy in the C# universe
    defining type-safe subclasses of the collections just to avoid cluttering
    your code with a lot of superfluous casts.

    Python has a much more flexible syntax for function arguments. You can have
    optional arguments, keyword arguments, you can even have functions where
    you don't know the names of all the keyword arguments in advance. C# just
    has overloading, so you need to define a new overload for every optional
    argument and you can't call a function missing out some arguments from the
    middle of the list.

    Tuple unpacking. C# just has naff reference arguments. Need I say more?

    Slicing of sequences.

    Python lets you write lists and dictionaries inline where you need them,
    much more convenient than in C#.

    Functions are first class objects in Python. C# delegates have some neat
    features (async calls and multicasts), but the effort of using a delegate
    in most situations is just too much.

    Don't get me wrong, C# is quite good, but it just has too much syntactic
    clutter obscuring the code.

    --
    Duncan Booth
    int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
    "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
     
    Duncan Booth, Aug 11, 2003
    #1
    1. Advertising

  2. Duncan Booth

    Robin Becker Guest

    In article <Xns93D4651C68054duncanrcpcouk@127.0.0.1>, Duncan Booth
    <> writes
    >"Brandon J. Van Every" <> wrote in
    >news:3f357a9b@shknews01:
    >
    >> So again my question is, language-wise, what can I get done with
    >> Python that I can't get done with C#? What is easy to express in
    >> Python, that is tedious, difficult, or impossible to express in C#?
    >>

    Eiffel.Net is alleged to have multiple inheritance, but I must admit I
    wasn't entirely convinced by one of the explanations I saw. In fact at
    the end of the piece it was stated that multiple inheritance was allowed
    only for Eiffel classes. On the other hand there are a bunch of features
    that will apparently arrive with later revisions of the CLR and multiple
    inheritance is one of them.

    I suspect it will be a long time before serious meta classes arrive.
    --
    Robin Becker
     
    Robin Becker, Aug 11, 2003
    #2
    1. Advertising

  3. Duncan Booth wrote:
    >
    > Don't get me wrong, C# is quite good, but it just has too much
    > syntactic clutter obscuring the code.


    Ok, so Python is "more flexible" than C#. If I start doing problems that
    require a lot of flexibility, I'll remember this about Python and consider
    it. To date I've not been working on such problems, but that could change.
    And C# might still prove to be "flexible enough."

    --
    Cheers, www.3DProgrammer.com
    Brandon Van Every Seattle, WA

    20% of the world is real.
    80% is gobbledygook we make up inside our own heads.
     
    Brandon J. Van Every, Aug 11, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    770
  2. Paul Moore
    Replies:
    0
    Views:
    654
    Paul Moore
    Mar 1, 2008
  3. Martin v. Löwis
    Replies:
    0
    Views:
    691
    Martin v. Löwis
    Mar 1, 2008
  4. Senthil Kumaran
    Replies:
    0
    Views:
    600
    Senthil Kumaran
    Jan 17, 2011
  5. R. David Murray
    Replies:
    0
    Views:
    792
    R. David Murray
    Jan 17, 2011
Loading...

Share This Page