views:

533

answers:

9

I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?

The reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.

I'm doing this all self-taught as a hobby, btw

+8  A: 

A lot of us really like working with strongly/statically-typed languages. That's a big one there.

Joel Coehoorn
+1 Other than syntax, this is probably the single most important difference between C# and Python, and one I count an advantage. C# is (primarily; .NET 4 things) a statically typed language. Python is runtime typed language.
Randolpho
+1, this is a big one, it took me a long time to learn this lesson and now I sing it's praises every chance I get.
Mark
A lot of us really like working with strongly-, *dynamically*-typed languages. That's a big one there. :)
EOL
+7  A: 

There are lots of differences, advantages as well as disadvantages. I guess the main advantages would be along the lines of

  • Excellent Windows integration, including access to all standard GUI functions and other libraries.
  • JIT compilation, resulting in better performance than Python, in some or most circumstances. As has been pointed out, this is now also possible in Python.
  • On Windows, the IDE support is arguably better for C#. Visual Studio is a well established and advanced development environment and the "Express" editions are free for personal use. In a non-Windows environment, it's probably a draw between different editors.

The rest is basically up to personal preference (statically typed versus dynamically, C-like syntax or not, etc.).

calmh
I'm pretty sure the Express editions of Visual Studio 2008 are free for commercial use, if they're still available.
Steve314
@Steve314 Indeed.
calmh
Not that I'm pro python over C# (I like both for different things but usually prefer C#) but I'd just like to point out that there are several python virtual machines that do JIT compilation, and there are plans to merge Unladen Swallow (a very popular one offered by Google) into the default python codebase.
Randolpho
+1  A: 

The JITer, and the fact that it can produce tighter code due to it supporting static typing. The JITer can be worked around by using one of the non-CPython implementations, or dropping to i386 and using psyco, but the static typing can't be worked around as trivially (nor do I believe that it should be).

Ignacio Vazquez-Abrams
A: 

I've found it helpful to work with different languages, since they each have their strengths. Python is extremely powerful, but relies heavily on good coding conventions and practices to keep code maintainable. In particular, it does not enforce type safety or insulation, which means it is easy to abuse. C# is a modern object oriented language, with strong typing and other features to help enforce insulation and encapsulation. It's not as wildly flexible, but I've also found that larger C# programs are much easier to maintain (especially when you inherit them from other developers.)

Dan Bryant
Python is strongly typed too. It is not statically typed.
Mike Graham
It is, but the notion of a 'type' is much more mutable, since fields appear by usage rather than definition. In this sense, Python is strongly typed, but the types themselves are subject to change. This can be very powerful, but there are also advantages to working within a language with well thought out restrictions.
Dan Bryant
A: 

Well, the ease of coding is debatable. I find C# easier to code when you factor in the help you get from teh IDEs (e.g. the free Visual Web Developer).

So, portability is less of an issue if you factor in Mono. Performance can be better in some scenarios. I find the online documentation to be generally better in .NET.

Have you considered IronPython? If you guys are willing to use one of the .Net distros that have the DLR in them (4.0's your best bet there, but some of the DLR betas are alright), then you can write C# code and Python code and have them work together w/o any difficulties outside naming conventions being a bit different.

Paul
+8  A: 

Visual Studio - the best IDE out there.

James L
A: 

C# can directly access pointers via "unmanaged code", which can give it a performance advantage in some situations.

Joe Internet
So can python via C bindings.
Paul
I also find Python's ctypes to be on par with .NET interop
Mark
+1  A: 
  • C# is supported by Microsoft ;) (expecting comments)
  • C# is typesafe which comes with its advantages.
  • Nothing is better when you are developing windows applications.
  • Its syntax is also very well designed. Code looks pretty good.
  • Its worth learning because lots of code is written and is being written in it.
  • It feels so good when you code in C# in Visual Studio. I am still searching for such a nice IDE for Python.
  • With C# you can explore lots of interesting things .NET,WPF,WCF,XNA,ASP.NET,Jon Skeet's Blog... etc.
TheMachineCharmer
+1 for mentioning Jon Skeet with the awesomeness of c#
j0rd4n
I find it impossible to type these 2 chars `C#` without typing these 8 `Jon Skeet`.
TheMachineCharmer
A: 

If you prefer Python, but need to write code for .Net, apart from IronPython there's also Boo, which is a heavily-Python-inspired .Net language (including static types). You might want to give it a try.

ΤΖΩΤΖΙΟΥ