what are the advantages of C# over Python

Question:

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

Asked By: Kefka

||

Answers:

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

Answered By: Joel Coehoorn

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.).

Answered By: Jakob Borg

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).

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.)

Answered By: Dan Bryant

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.

Answered By: Paul
  1. Visual Studio – the best IDE out there.

  2. Of the statically typed languages in circulation, C# is very productive.

Answered By: James L

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

Answered By: Joe Internet
  • 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.
Answered By: Pratik Deoghare

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.

Answered By: tzot

If you are not interested in using the .NET framework, you can instead use python and pyQt or Tkinter as Python now has an IDE support for Visual Studio called Python Tools for Visual Studio (PTVS) that gives you syntax prompts just like how you get in VB and C# in visual Studio. But if you need to use .NET also, use Iron Python and then Python Tools for Visual Studio and in visual studio choose compiler as Iron Python. Visual Studio is supported in 2013 and 2012 versions. I would say it is the best IDE for python and what more is it is being supported by MSFT too

Check the link here
https://pytools.codeplex.com/

NOTE: You can use ptvs with either the 2.7 version or 3.0 version. I use 2.7 version as I am used to it, but for beginners I would suggest to use 3.0 as it has got many advantages over the 2.7 version. BUT DONOT INSTALL BOTH OF THEM IN THE SAME System. Also Install Visual Studio Shell Isolated and then Integrated before installing PTVS. Also make sure your python version matches with the Operating system Bit Version.

๐Ÿ™‚

Answered By: logicacker

Reengineering and maintainability are very important issues. I’ve done lots of JavaScript programming and really do know it well. But having to maintain large code bases of JavaScript is a nuisance; reengineering possibilities and discoverability are way worse than with C#.

I’ve got no direct Python experience, but am really sick of untyped, loosely typed and interpreted languages. Compilers are checking complete programs and so prevent errors, which would otherwise occur during runtime.

Clearly, performance also is an issue. But regarding the performance of modern interpreters and modern hardware, this is mostly less important than general maintainability and stability.

Besides, the C# / .NET ecosystem is just great. The default system libraries are stable and performant and there are 3rd party utilities for most everything.

And the C# language is mostly standardized, which helps with longtime stability.

Answered By: cskwg

Uncle bob said:
โ€œYou donโ€™t need static type checking if you have 100% unit test coverage.โ€

Check this article:
https://instil.co/blog/static-types-wont-save-us-from-bad-code/

Answered By: Noha Abdllatif
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.