RE: Python vs. C#

Discussion in 'Python' started by Jimmy Retzlaff, Aug 12, 2003.

  1. Brandon J. Van Every () wrote:
    >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."


    You almost get it. While not many problems "require" Python's
    flexibility, a large number of problems can be more effectively
    addressed by leveraging that flexibility. Put another way, you can often
    create better solutions in less time.

    Not many of Python's individual features are unique among languages
    available today, but there is an amazing synergy among Python's features
    that is hard to comprehend until you've used them to solve some
    non-trivial problems.

    In the early days of the PC there was a similar debate over the use of
    Assembly versus higher level languages like C and Pascal. Not many
    problems "required" the features of those higher level languages, but
    people came to understand the benefits in the vast majority of
    applications (benefits like time/money, maintainability, and
    reliability).

    Jimmy
     
    Jimmy Retzlaff, Aug 12, 2003
    #1
    1. Advertising

  2. Jimmy Retzlaff wrote:
    >
    > In the early days of the PC there was a similar debate over the use of
    > Assembly versus higher level languages like C and Pascal. Not many
    > problems "required" the features of those higher level languages, but
    > people came to understand the benefits in the vast majority of
    > applications (benefits like time/money, maintainability, and
    > reliability).


    Well, I think mainstream commercial industry sees the writing on the wall
    regarding garbage collection. But that's probably the current level of
    consensus on "yes, we need a better solution for this." Python advocates
    tend to pooh-pooh strong typing, and I'm wondering if in a large-scale
    industrial context, if that's really a valid stance to take. At any rate, I
    expect more years of evolution with languages such as Java and C# before
    mainstream industry starts thinking that the more exotic things Python does
    are "better solutions" for something that definitely needs fixing.

    --
    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 12, 2003
    #2
    1. Advertising

  3. On Tue, 2003-08-12 at 03:20, Brandon J. Van Every wrote:
    > Well, I think mainstream commercial industry sees the writing on the wall
    > regarding garbage collection. But that's probably the current level of
    > consensus on "yes, we need a better solution for this." Python advocates
    > tend to pooh-pooh strong typing, and I'm wondering if in a large-scale
    > industrial context, if that's really a valid stance to take.


    I've used Python for most of my university projects so far (at least
    where I could choose what to use), and I've had professors look at me
    asking why I chose "an outsider" like Python over languages (considered
    to be "stronger") such as C++ and SML (whatever...).

    They only asked until they had a look at the code I had produced. :)

    Where other people had written huge amounts of C++ code for a renderer,
    which was incomprehensible even to the original programmer after about a
    weeks time, my code remained "relatively" short and clean (I had to
    write it in 72 hours), nicely structured into separate modules, and with
    a well designed class inheritance scheme (which is pretty important for
    a renderer, for the user to be able to integrate his/her own objects
    later on).

    Metaclass programming aided me a lot here. And, yeah, I love
    doc-strings!

    None of my competitors could offer this, whatever language they chose
    (one chose Perl, all others C++...).

    None of the professors even spoke about garbage collection, none spoke
    about dynamic typing, they were all just amazed at the expressive powers
    Python put in my hands, all with simple syntax and a without a huge STL
    (such as C++s).

    I was even asked to give a Python lecture later on (not in an official
    course, but for the interested). :)

    I don't think that "static typing" (Python is strongly typed btw., just
    to correct your statement) is any concern for most people (even for most
    executives, I guess my professors count as that too), just getting a
    working solution for a problem quickly, smoothly and readably. And
    that's what Python excels at.

    > At any rate, I
    > expect more years of evolution with languages such as Java and C# before
    > mainstream industry starts thinking that the more exotic things Python does
    > are "better solutions" for something that definitely needs fixing.


    Yeah, I can agree here. But in my experience, if I can show the people
    what power Python comes with ("batteries included"), after their
    amazement stops, they'll all start asking which book to buy to start
    learning. Even with the "power-play" Sun and Microsoft did to boost Java
    and C#, Python still seems as a valid and interesting alternative to
    most people I know (except those living in the "Microsoft-Universe", of
    course, but I guess I'll never save them from that big black hole
    anyway).

    Just my 5 eurocents.

    Heiko.
     
    Heiko Wundram, Aug 12, 2003
    #3
  4. Jimmy Retzlaff

    Terry Reedy Guest

    "Brandon J. Van Every" <> wrote in message
    news:bh9eri$vhr5i$-berlin.de...
    > Python advocates tend to pooh-pooh strong typing,


    Disinformation nonsense. Python objects are more strongly typed than
    C variables. Does C# have casts?

    TJR
     
    Terry Reedy, Aug 12, 2003
    #4
  5. Heiko Wundram wrote:
    >Brandon wrote:
    >>
    >> Python advocates tend to pooh-pooh strong typing, and I'm wondering
    >> if in a large-scale industrial context, if that's really a valid
    >> stance to take.

    >
    > Where other people had written huge amounts of C++ code for a
    > renderer, which was incomprehensible even to the original programmer
    > after about a weeks time, my code remained "relatively" short and
    > clean (I had to
    > write it in 72 hours), nicely structured into separate modules, and
    > with
    > a well designed class inheritance scheme (which is pretty important
    > for
    > a renderer, for the user to be able to integrate his/her own objects
    > later on).


    Yes your rendering code is nice looking. Is it fast? Were you working on a
    problem where it needed to be fast? I haven't been using C++ out of love.
    I've been using it for performance. And I don't think "what I can do in 72
    hours" is a valid test for big industrial system architectures. Is your
    code going to hold up in the face of dozens of programmers banging on it,
    and hundreds or thousands of programmers using it? And still be fast?

    > I don't think that "static typing" (Python is strongly typed btw.,
    > just to correct your statement)


    It is? Then I'm confused, because around here people keep talking about the
    beauty of avoiding types.

    > is any concern for most people (even for
    > most executives, I guess my professors count as that too), just
    > getting a
    > working solution for a problem quickly, smoothly and readably. And
    > that's what Python excels at.


    What you are saying is Python excels at prototyping, where speed and
    flexibility are paramount. You are not saying that Python excels as a big
    system architecture language, where stability and safety are paramount.

    > Yeah, I can agree here. But in my experience, if I can show the people
    > what power Python comes with ("batteries included"), after their
    > amazement stops, they'll all start asking which book to buy to start
    > learning. Even with the "power-play" Sun and Microsoft did to boost
    > Java
    > and C#, Python still seems as a valid and interesting alternative to
    > most people I know (except those living in the "Microsoft-Universe",
    > of course, but I guess I'll never save them from that big black hole
    > anyway).


    That "except" is, like, 1/2 to 2/3 of industry. I think you Python guys
    need to wake up that there's a much bigger, scarier, and more threatening
    world out there than the UNIX world of "engineering done right." That world
    is also not sitting still, it's on the move. For interoperability of
    langauges, UNIX has nothing to offer like the .NET Framework. DirectX is
    now ahead of OpenGL on vertex/pixel shader API capability and stability.
    The black hole, if not taken seriously, will swallow you. Either that or
    you're forced into "clone and conquer" in reverse.

    --
    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 12, 2003
    #5
  6. Jimmy Retzlaff

    Joe Cheng Guest

    > > I don't think that "static typing" (Python is strongly typed btw.,
    > > just to correct your statement)

    >
    > It is? Then I'm confused, because around here people keep talking about

    the
    > beauty of avoiding types.


    Python is "strongly" typed in the sense that every object has a type. It is
    not "statically" typed in that references do not have types. Statically
    typed languages generally require you to declare variable types (some
    languages infer them) and in return you get compile-time warnings when you
    try to call methods that do not exist or perform casts that are semantically
    impossible.

    I may be wrong but I believe C is an example of a language with static weak
    typing... you have to declare variable types and some types of errors can be
    caught at compile time, but you can perform unsafe casts and not only will
    the compiler not stop you but at runtime you won't get an exception--just a
    possibly corrupted value in memory.

    Java and C# have static strong typing.

    Python has dynamic strong typing. So, if you can keep the types of your
    objects straight without the help of the compiler, you get the benefits of a
    concise syntax while enjoying type safety at runtime.

    Someone correct me if I've gotten it wrong...
     
    Joe Cheng, Aug 12, 2003
    #6
  7. Jimmy Retzlaff

    John Guest

    > I've used Python for most of my university projects so far (at least
    > where I could choose what to use), and I've had professors look at me
    > asking why I chose "an outsider" like Python over languages (considered
    > to be "stronger") such as C++ and SML (whatever...).


    > They only asked until they had a look at the code I had produced. :)


    Likewise. And I actually succeeded in getting several people
    interested. I love Python. But I love C# just as much and it is hard
    to say which one I love better.

    No too long ago, I had to create a tool for an information retrieval
    project. I needed RegEx, GUI, Containers and Database features. And I
    needed to make this fast. First I looked at Delphi. It had by far the
    BEST GUI framework. Nothing else even comes close for GUI RAD. In most
    cases, I just need to go a web site like www.torry.net and simply pick
    from a choice of open source components. BUT it did not have RegEx.
    Sure there was a lib or 2 out there but nothing standard. Same story
    with containers.

    Then I started with Python. Python had everything I needed. But my app
    was GUI rich and it was taking too long to layout the interface. Even
    with Boa Contructor, it still was taking a while. I had already
    finished writing most of the classes for the app.

    I switched to C#. Surprise. It took me hardly any time to port the
    Python code to it. For everything I needed from Python, I had direct
    analogues in C# (at least in the context of my app). And I finally
    wrapped everything up quite quickly. I enjoyed C# as much I enjoyed
    Python. Of course, the user was quite dismayed when I told him about
    the 28 MB of dependencies. But the software did exactly what it was
    expected to.

    As for static typing, that never slows me down. What makes C++ slower
    to program in not declaring types. It's the memory details to watch,
    complex developmental cycles (not just compile time), lack of quick
    libraries (batteries included) that we get with languages like Perl
    and Python etc.

    What enhanced my C# experience has a lot to do with mature tools than
    with the language per se. The VS2003 IDE is far more complete than
    PythonWin and Boa. Code Completion, Help integration for example is
    far more mature and often means I rarely have to refer to the docs.

    The standard library is fantastic as well. MS finally made a
    developmental tool that is hard to point fingers at.

    Personally I would like to see Python in a .NET environment. Not some
    silly IDE add-in like Visual Python. One comment in this thread was
    that Python's dynamic typing makes it difficult to port it to .NET.
    But Perl is dynamically typed too. And ActiveState has a feasible .NET
    language with Perl. What gives for Python? I don't know much about the
    language internals but I believe true integration of Python into VS
    will do it a world of good.

    Adding onto "what C# can do that Python can't?", I am now developing
    an app for the PocketPC with the Compact Framework in C#. The app is
    every bit as professional as an experienced programmer might have
    developed with eVC. And I was able to do it in a fraction of time of
    it might have taken with C++ and MFC and this is my FIRST PocketPC
    app. Python cannot do that at this point of time.

    Similarly ASP.NET like development experience is hard to get from
    Python at this point. Yes! There are several webapp frameworks for
    Python and then there is Zope. But ASP.NET is something else and suits
    certain kind of web apps quite well (Though Zope is way to go for
    CMS). I am sure Python community will catch up eventually to this
    paradigm but for now it doesn't.
     
    John, Aug 12, 2003
    #7
  8. Jimmy Retzlaff

    Duncan Booth Guest

    "Joe Cheng" <> wrote in
    news:Jq%Za.8237$:

    > Java and C# have static strong typing.
    >
    > Python has dynamic strong typing. So, if you can keep the types of
    > your objects straight without the help of the compiler, you get the
    > benefits of a concise syntax while enjoying type safety at runtime.
    >
    > Someone correct me if I've gotten it wrong...
    >

    You have it about right. C# lets you define functions that take arguments
    of any type by boxing them as objects. However, to perform almost any
    operation on these values you have to cast them back to their original
    type. So a function that takes two objects and adds them together can't
    work unless you know the type you expected the objects to be. You cannot
    just add two objects, even if they are of the same type, you have to cast
    (unbox) them from object back to their real type (and you have to get that
    type *exactly* right, you can't for example unbox a short as an int) and
    then operate on them.

    [A couple of operations work directly on objects, you can convert any
    object to a string, and compare objects for equality directly].

    Python on the other hand will let you do something like adding two objects
    together, it will perform some permitted conversions automatically, e.g.
    extending int to float, but it won't attempt to do weird things like parse
    a string into a number, or for that matter automatically convert a number
    to a string.

    Both languages are strongly typed. The drawback with C# is mainly that you
    have to keep telling the language things that both you and the compiler
    already know. If I have an ArrayList filled with strings, and I want to
    pass one of them to a function taking a string argument, I have to
    explicitly cast the element of the ArrayList back to string. If the cast
    fails at runtime I get an exception. Why can the compiler not put that cast
    in silently and give me the same exception at runtime?

    --
    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 12, 2003
    #8
  9. Joe Cheng wrote:
    >
    > Python has dynamic strong typing. So, if you can keep the types of
    > your objects straight without the help of the compiler, you get the
    > benefits of a concise syntax while enjoying type safety at runtime.


    And how, in a large scale industrial systems context, are you supposed to
    ensure that Joe Programmer doesn't in fact screw it up?

    --
    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 12, 2003
    #9
  10. Jimmy Retzlaff

    Aahz Guest

    What's a troll? (was Re: Python vs. C#)

    In article <>,
    Theodor Rash <> wrote:
    >
    > --------------------------
    > /| /| | |
    > ||__|| | Please don't |
    > / O O\__ feed |
    > / \ the trolls |
    > / \ \ |
    > / _ \ \ ----------------------
    > / |\____\ \ ||
    > / | | | |\____/ ||
    > / \|_|_|/ | __||
    > / / \ |____| ||
    > / | | /| | --|
    > | | |// |____ --|
    > * _ | |_|_|_| | \-/
    > *-- _--\ _ \ // |
    > / _ \\ _ // | /
    > * / \_ /- | - | |
    > * ___ c_c_c_C/ \C_c_c_c____________


    ROTFL!

    Now, if you wanna make one *really* funny, make it with a panda. ;-)
    --
    Aahz () <*> http://www.pythoncraft.com/

    Let's see who gets this reference
     
    Aahz, Aug 12, 2003
    #10
  11. Jimmy Retzlaff

    Aahz Guest

    In article <Jq%Za.8237$>,
    Joe Cheng <> wrote:
    >
    >Python is "strongly" typed in the sense that every object has a type.
    >It is not "statically" typed in that references do not have types.
    >Statically typed languages generally require you to declare variable
    >types (some languages infer them) and in return you get compile-time
    >warnings when you try to call methods that do not exist or perform
    >casts that are semantically impossible.
    >
    >I may be wrong but I believe C is an example of a language with static
    >weak typing... you have to declare variable types and some types of
    >errors can be caught at compile time, but you can perform unsafe casts
    >and not only will the compiler not stop you but at runtime you won't
    >get an exception--just a possibly corrupted value in memory.


    http://www.artima.com/weblogs/viewpost.jsp?thread=7590
    --
    Aahz () <*> http://www.pythoncraft.com/

    This is Python. We don't care much about theory, except where it intersects
    with useful practice. --Aahz
     
    Aahz, Aug 12, 2003
    #11
  12. On Tue, 2003-08-12 at 06:45, Brandon J. Van Every wrote:
    > Yes your rendering code is nice looking. Is it fast? Were you working on a
    > problem where it needed to be fast? I haven't been using C++ out of love.
    > I've been using it for performance. And I don't think "what I can do in 72
    > hours" is a valid test for big industrial system architectures. Is your
    > code going to hold up in the face of dozens of programmers banging on it,
    > and hundreds or thousands of programmers using it? And still be fast?


    Yes, I was working on problems where the rendering code needed to be
    fast. Doing an import psyco solved all my earlier fears about lagging
    behind in performance terms against the people I had to compete with.
    And, is having an interpreted language really such a major concern in
    the age of computers operating at 2000+ Mhz? The final goal of the
    project was designing a 3D-ego shooter with the engine we had written.
    And it didn't run overly fast, but fast enough on the machine I tested
    it on.

    If I had had the time, I'd have worked most of the rendering code down
    to C, which I would've wrapped with SWIG or the like, but I was
    surprised how fast it even ran using plain Python with psyco. And I
    don't really want to express game logic, such as computer player AI, or
    the like, in C++. Do you?

    (genetic algorithms are plain cool here...)

    Just btw., my code help up to other programmers banging on it, and also
    held up to larger usage. Just because you have static typing doesn't
    mean that the code works together with an "evil programmer" (casting is
    lots of fun...). And because my code was understandable, other
    programmers who used it could read the code before using my library.
    This is impossible to do with an overly complex C++ library, in my eyes.

    > It is? Then I'm confused, because around here people keep talking about the
    > beauty of avoiding types.


    static typing = needing to declare types for all slots
    (slots==variables).
    dynamic typing = a slot can take up an object of any type (python's
    slots only take up references, everything is a reference).

    strong typing = types are checked on usage. If you don't use a correct
    type (like with an expression (float*)&"1234" in C, which makes no sense
    at all), you get an exception.
    weak typing = types aren't checked on conversion, so things like
    (float*)&"1234" work.

    Python is certainly strongly typed, but unlike C, it is dynamically
    typed. People also speak of static weak typing in C, as you can cast
    anything into anything else (without checks), what you can't do in
    Python. C++ is (was) the same, at least when I learnt it.

    > What you are saying is Python excels at prototyping, where speed and
    > flexibility are paramount. You are not saying that Python excels as a big
    > system architecture language, where stability and safety are paramount.


    Isn't a renderer and a game engine a big system architecture? I didn't
    just prototype it in Python, I could offer a complete system, which was
    very extensible. I could've never managed this in any other langauge
    without the usual headaches.

    > That "except" is, like, 1/2 to 2/3 of industry. I think you Python guys
    > need to wake up that there's a much bigger, scarier, and more threatening
    > world out there than the UNIX world of "engineering done right." That world
    > is also not sitting still, it's on the move. For interoperability of
    > langauges, UNIX has nothing to offer like the .NET Framework. DirectX is
    > now ahead of OpenGL on vertex/pixel shader API capability and stability.
    > The black hole, if not taken seriously, will swallow you. Either that or
    > you're forced into "clone and conquer" in reverse.


    I don't really know why you compare OpenGL to DirectX, they are just
    plain API specifications. Maybe on your Windows Box DirectX is faster
    than OpenGL (and offers support for more tasks), but this is a driver
    vendor problem. Most graphics drivers on Windows are developed with
    DirectX in mind, not with OpenGL. NVidia is IMHO an honorable exception,
    as their OpenGL code (sometimes) works faster than DirectX.

    And to a sidenote: Unix has always had a .NET Framework. The libraries
    ..NET tries to standardize have been available on Unix since a long time.
    And I don't especially like the thought that I have to choose a single
    Framework to do all I need, as this only makes me dependant on the
    original implementor (Microsoft in this case). And if you need a
    "portable" virtual machine, Python, Java, and Perl (just to name a few)
    have offered this since ages. .NET isn't such a big innovation as it
    claims to be...

    Heiko.
     
    Heiko Wundram, Aug 12, 2003
    #12
  13. Jimmy Retzlaff

    John Guest

    > > Python advocates tend to pooh-pooh strong typing,
    >
    > Disinformation nonsense. Python objects are more strongly typed than
    > C variables.


    Agreed!

    > Does C# have casts?


    Yes! Explicit! About the same level as Java.
     
    John, Aug 12, 2003
    #13
  14. Heiko Wundram wrote:
    > And, is having an interpreted language really such a major concern in
    > the age of computers operating at 2000+ Mhz?


    For those of us who are going to continue to increase our triangle counts,
    yes it is a concern. But if we can find a way to do those parts of the code
    in C++, and gracefully integrate them, the concern goes away.

    > And I
    > don't really want to express game logic, such as computer player AI,
    > or the like, in C++. Do you?


    C++ is appropriate for low-level AI, such as pathfinding and terrain
    analysis. I would not want to do high level AI in C++, and probably game
    logic would be better done in something else. The question is, what price
    do you pay for integration?

    > Isn't a renderer and a game engine a big system architecture? I didn't
    > just prototype it in Python, I could offer a complete system, which
    > was
    > very extensible. I could've never managed this in any other langauge
    > without the usual headaches.


    Yes it is, but you didn't write a big system architecture in 72 hours.

    > And to a sidenote: Unix has always had a .NET Framework. The libraries
    > .NET tries to standardize have been available on Unix since a long
    > time.


    I"m talking about language interoperability because of the Intermediate
    Language.

    --
    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 12, 2003
    #14
  15. Andrew Bennetts <> writes:
    > On Tue, Aug 12, 2003 at 02:03:58AM -0700, Brandon J. Van Every wrote:
    > > Joe Cheng wrote:
    > > And how, in a large scale industrial systems context, are you supposed to
    > > ensure that Joe Programmer doesn't in fact screw it up?

    >
    > By writing tests.
    >
    > Just because C++, C# or Java code compiles cleanly doesn't mean it's
    > correct.
    > Just because Python code parses correctly and gives clean PyChecker output
    > doesn't mean it's correct, either.
    >
    > In both cases, you need tests, preferably comprehensive, automated tests, to
    > verify that your code actually works correctly.


    I like the sentiment, but in practice there is no such thing as comprehensive
    tests.
     
    Christopher Barber, Aug 13, 2003
    #15
  16. Jimmy Retzlaff

    Peter Hansen Guest

    Christopher Barber wrote:
    >
    > Andrew Bennetts <> writes:
    > > In both cases, you need tests, preferably comprehensive, automated tests, to
    > > verify that your code actually works correctly.

    >
    > I like the sentiment, but in practice there is no such thing as comprehensive
    > tests.


    Without an agreed-upon definition of "comprehensive", this is arguable.

    "1. Including much; comprising many things; having a wide
    scope or a full view."

    Surely you'd agree that comprehensive tests are possible in this case.

    "2: including all or everything"

    In this case, although I'm unclear on the distinction between "all" and
    "everything", you're certainly correct, but it's an uninteresting point
    as it's too obvious. Certainly Andrew doesn't think anyone has tests
    which cover *everything*...

    And is your objection based on personal experience only, or do you
    consider others' situations. I would say that at my workplace we
    certainly have *comprehensive* and fully automated tests for some of
    our code. And those tests do verify quite well that the code works.

    -Peter
     
    Peter Hansen, Aug 14, 2003
    #16
    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:
    750
  2. Paul Moore
    Replies:
    0
    Views:
    619
    Paul Moore
    Mar 1, 2008
  3. Martin v. Löwis
    Replies:
    0
    Views:
    659
    Martin v. Löwis
    Mar 1, 2008
  4. Senthil Kumaran
    Replies:
    0
    Views:
    579
    Senthil Kumaran
    Jan 17, 2011
  5. R. David Murray
    Replies:
    0
    Views:
    760
    R. David Murray
    Jan 17, 2011
Loading...

Share This Page