1

Why is Python faster than C# on my computer?

Ten downvotes and 4 close votes? Really?

The question is based on a fundamental misunderstanding of code timings. Primarily opinion-based would apply to questions that are not objective. Aren't we always telling people to time their code instead of second-guessing it?

The community's challenge, should they have chosen to accept it, was to educate the user about how these timings work.

10
  • 14
    Well... Why is this language faster than that language in this weirdly constructed and very artificial test without a reproducible environment is not a question that's particularly useful in my opinion. The Is not useful part of the downvote description seems to fit. Not sure about closing, though.
    – Erik A
    Commented Jun 8, 2018 at 14:29
  • Maybe loosely related: meta.stackoverflow.com/questions/291558/…
    – Tensibai
    Commented Jun 8, 2018 at 14:30
  • 8
    The Too Broad vote is indeed far and away the better close reason. There are innumerable factors that affect the performance of different programs in entirely different languages. People write entire books on topics like this. It's not like there's just one single correct answer for why the timings of the two programs are different.
    – Servy
    Commented Jun 8, 2018 at 14:30
  • 4
    Just from the title, I know nothing about OP's system (hardware, OS, etc), what distribution of Python or C# compiler they're using. This would get a too broad from me Commented Jun 8, 2018 at 14:39
  • @James_Parsons Why not add a comment for OP to include it in the body of their post? The title seems long as it is.
    – chevybow
    Commented Jun 8, 2018 at 14:44
  • @chevybow Had I come across that question myself , I would have indeed left a comment explaining that bit along with suggesting the StopWatch class Commented Jun 8, 2018 at 14:45
  • 10
    Well, standard mistake. Whenever you ask "why is X better than Y" then be sure to only tag it [x] and never [y]. Commented Jun 8, 2018 at 14:46
  • 6
    Obligatory Eric Lippert blog post: ericlippert.com/2012/12/17/performance-rant Commented Jun 8, 2018 at 14:59
  • 2
    As the first commenter so eloquently stated: You're evaluating entire languages based on their speed of printing?
    – Davy M
    Commented Jun 8, 2018 at 17:44
  • 5
    @DavyM: Yep. Instant truth. But ignorance is the reason we are here; if everyone were fully enlightened, there would be no need for Stack Overflow.
    – Robert Harvey Mod
    Commented Jun 8, 2018 at 17:44

3 Answers 3

20

So there are two different issues here, close votes and downvotes. Let's start with the close votes.

While I can understand why someone might choose Primary Opinion Based (note at this point that only 3 people have thus far), this is indeed not a great choice of close vote. The existing Too Broad close reason is far better. There are just tons of different reasons why two different programs written in two radically different languages will perform differently. And on top of that they're affected by all sorts of different factors. There's differences inherent to the language, differences inherent to how the program was written in each language, the context in which the program was run (OS, software, hardware, etc.) and so on. There's just so much going on in a question like that in trying to explain the results of the two programs and why and how they are different.

Questions like these often walk a pretty tight line between Too Broad and Primarily Opinion Based based on how you interpret them. If you interpret them as asking for every relevant factor, it's Too Broad, if you interpret it as asking for what people think the most important factor(s) are, then it's opinion based. This is why I say that I understand the POB votes, even if I would cast a Too Broad vote myself.

As far as votes, there are all sorts of other factors, in addition to the ones above, that come into play.

Some people may feel that the underlying program is not useful to use as an example and that explanations about why it behaves different aren't going to be useful to people writing constructive programs.

Additionally the tone of the question...leaves a bit to be desired. It very much comes off as a "why is C# so much worse than Python, it's such a bad language" (particularly in the comments, where it really pushes that angle a whole lot more than in the question itself). That's simply not a recipe for getting a question well received. Language wars just aren't constructive discussions to have. In fact, it was the textbook example of the old "Not Constructive" close reason. I release that this isn't technically the literal question asked here, but honestly, especially given all of the comments, it's clearly the question that the question author is trying to get people to respond to. They got their wish, and lots of people have indeed responded to the question as if that's what it's asking.

And of course, as always when it comes to downvotes, different people have different criteria for what they consider useful. These are some theories, presented by others, that I also agree with. I'm sure others are voting for other reasons as well. But most importantly, assume good faith here. Just because you read a question and think it's useful doesn't mean that anyone that anyone who downvoted it is a mean spoilsport that just wants other people to have a bad time. You're far better off assuming that they honestly don't think that the question is a useful one, even if you can't understand what their reason is, specifically.

12
  • A decent retort. I would only point out that there are many questions that are affected by the "many factors" problem, but this one isn't; there's really only one clear answer.
    – Robert Harvey Mod
    Commented Jun 8, 2018 at 16:17
  • 2
    @RobertHarvey Well so far no one has even tried to say what that one answer is. There are two answers posted that just say that Python is faster and provides no real reasons at all. So if there is one clear reason, no one has said what it is.
    – Servy
    Commented Jun 8, 2018 at 16:21
  • Er... what? "You're comparing the speed they write to console."
    – Robert Harvey Mod
    Commented Jun 8, 2018 at 16:28
  • 1
    @RobertHarvey Yeah. The question is why writing to the console is faster in Python. Saying, "you're comparing the speed that they write to the console" is just restating the question.
    – Servy
    Commented Jun 8, 2018 at 16:33
  • 1
    I think you're being obtuse to try and make a point. The OP's original premise (before Shog's edits) is that Python is faster that C#. The cure is to correct the premise, not declare the question hopeless.
    – Robert Harvey Mod
    Commented Jun 8, 2018 at 16:34
  • 3
    @RobertHarvey No, that wasn't the OP's stated premise. They were asking why one program was faster than another program. That the title didn't include all of the details of the body of the question is of course a necessecity. Now, the comments indicate that the OP is clearly trying to push an agenda, and they are demonstrably trying to use this example as a way of saying, "see, look how bad C# is, it can't even print to the console as fast as Python" (hence the poor reception) but the question was never (overtly) asking which language is universally faster.
    – Servy
    Commented Jun 8, 2018 at 16:38
  • 2
    @RobertHarvey Now the reason that the question is hopeless is not that the title didn't reflect the fact that the body of the question was asking about two specific programs, rather than the languages as a whole, but rather the fact that the OP is clearly not acting in good faith (and also the fact that there isn't any inherently useful information to be found in the answer to the actual question asked, even if assumed to be asked in good faith).
    – Servy
    Commented Jun 8, 2018 at 16:40
  • 2
    And yet, the folks who posted comments and answers to the question didn't seem to find it all that difficult to identify the problem with the OP's code.
    – Robert Harvey Mod
    Commented Jun 8, 2018 at 16:52
  • 3
    @RobertHarvey The OP was just trying to show people how much better they think Python is than C#. Having two answers just say, "yeah, Python is just better than C#" is obviously great for them. It's exactly what they want to hear, and not useful in the slightest to any actual programmers trying to solve actual problems. You're correct that the people answering and commenting correctly identified that the question wasn't asking a sincere question about why two programs performed differently, and thus neither answered that question. That's exactly why the question should be closed.
    – Servy
    Commented Jun 8, 2018 at 16:55
  • 4
    Oh, interesting. I didn't interpret the question that way at all. Are people really that sensitive to others dissing their favorite language (if that, in fact, was actually the OP's intention)? I personally couldn't care less.
    – Robert Harvey Mod
    Commented Jun 8, 2018 at 17:00
  • @RobertHarvey Interesting indeed. Ideally, the natural course of action would be editing any flame bait away and handling it as a normal question (cf. Shog's answer).
    – duplode
    Commented Jun 8, 2018 at 18:13
  • People are definitely that sensitive, @Robert. But I don't think the OP intentionally triggered it (source for both assertions: deleted comments on one of the answers).
    – Shog9 Mod
    Commented Jun 8, 2018 at 22:38
10

The community's challenge, should they have chosen to accept it, was to educate the user about how these timings work.

I'm 99% sure I disagree with this premise, based on the fact that what we're really trying to do with OPs at all is to help them, not teach them.

I should defend that.

The main crux of the OP's concern is that they're timing two different languages with similar operations. Similar operations.

There are enough nuances with Python alone that make comparing what it's doing to a standard loop in C# unfair at worst, and incomparable at best. Throw in differing hardware (e.g. they're on a laptop, I'm on a Threadripper 1950X) and throw in different environments, and you have a recipe for "it depends a lot on..."

There's also the naive approach to timing and benchmarking here, but even then that's a separate issue.

There's also the matter of, if one were to squint at this, it'd read something similar to "Shark vs Gorilla".


So, with all that said, I believe that this question definitely should be closed. It's too broad. The degree of answers we could provide would be unsatisfactory to anyone looking for a comparison of this. It's also the case that I don't see anywhere that we can readily help the OP with their problem, but I see plenty of opportunity to teach them, which doesn't sound like what we should be doing.

But hey, I could be wrong there.

5
  • 4
    I didn't expect Threadripper 1950X to be an actual product
    – user247702
    Commented Jun 8, 2018 at 15:32
  • @Stijn: Where were you last November?? :D
    – Makoto
    Commented Jun 8, 2018 at 15:33
  • 1
    “Give a man a fish and you feed him for a day.  Teach a man how to fish and you feed him for life.”   So are you saying that we should be handing out fish sandwiches, because teaching is bad (or, at least, it isn’t our job / mission)? Commented Jun 8, 2018 at 18:34
  • 3
    @G-Man: Believing that we have an obligation to teach everyone seeking help on Stack Overflow is a corruption and over-extension of the original stated mission: be a repository of answers for every developer question. Today, it's impractical to dedicate resources and energy to teaching an OP, but teaching is often conflated with the fact that, when we do help, we also teach them a little bit. It's important to make these two actions as distinct and mutually exclusive as possible lest we get OPs like the prior who believe it's acceptable to post questions which beg for teaching.
    – Makoto
    Commented Jun 8, 2018 at 19:15
  • Sounds almost as if you’re saying, «what we’re really trying to do with OPs is to throw their questions into oysters that will produce pearls that readers can admire for perpetuity.  If the question-asker derives an immediate benefit, that’s a side-effect that we’re willing to tolerate.» Commented Jun 8, 2018 at 19:28
6

Everyone is over-thinking this. The original title put the question firmly in "language war" territory, so a bunch of folks came out of the woodwork to defend their PLATFORM_OF_CHOICE.

Or, as Hans so eloquently put it,

Well, standard mistake. Whenever you ask "why is X better than Y" then be sure to only tag it [x] and never [y].

I edited the title and reopened.

3
  • 3
    In an ideal world, folks would be warier of falling into such traps, and bolder in disarming them through edits.
    – duplode
    Commented Jun 8, 2018 at 17:35
  • 1
    @duplode technically, in an ideal world everything would be done using magic and everyone would just know everything so Stack Overflow would have no reason to exist.
    – user4639281
    Commented Jun 8, 2018 at 23:37
  • 1
    Dude... @Tiny... You think dealing with prima dona rock star ninja programmers is bad, think how much it'd suck dealing with dona rock star ninja dudebro dark wizards. Ideal world? Ehhhhh
    – Shog9 Mod
    Commented Jun 9, 2018 at 0:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .