# Stack Overflow vs. Competitive Programming Questions

I like to keep an eye on what people are saying about competitive programming, so I subscribe to a Google Alert for that phrase. Almost every day, I get a few results. While programmers are opinionated about a lot of things, this topic seems to bring out especially strong opinions. Here are some places where you might see discussions about competitive programming:

Quora

Quora has more posts containing this phrase than any other single site. When it comes to competitive programming, Quora users are surprisingly tolerant of repetitive questions, beginner questions, very specific questions, and just plain weird questions. Despite the deluge of questions, experienced competitive programmers hang out on Quora and provide advice. If you’re interested in the topic, Quora is a good place to find answers.

A famous Quora question about competitive programming: How is competitive programming different from real-life programming?

Contest sites

Forum and blog posts from the contest sites (TopCoder, CodeForces, CodeChef, etc.) sometimes show up in the results, but not as much as you might think. This is probably because people don’t need to specifically use the “competitive programming” phrase in their posts. What else would people be talking about on those sites?

A secret Facebook group, announced on CodeForces: Rebirth of competitive programming group

News sites

When something happens in the world of competitive programming, like a major contest or a well-known competitive programmer switching jobs, it is sometimes picked up by a news site. Then other news sites who can’t afford to write their own stories copy the first news site, resulting in a flurry of alerts for the same story.

This article showed up on a number of sites: How Competitive Coding Platforms Are Changing the Tech Hiring Landscape

Educational sites and blogs

This category covers sites that write about competitive programming for the purpose of learning and education. It includes blogs like this one, as well as the occasional announcement of an in-person event like a class or meetup.

A local competitive programming group (if you live in Boston): Boston Code Dojo – Competitive Programming

Sorry, wrong number

Television programming (i.e., TV shows) is also a type of “competitive programming.” Fortunately these don’t appear too often, so they don’t really clutter the results.

What’s this professional wrestling story doing in my programming feed?: “compete with competitive programming

Reddit

Reddit has a lot of programming discussion, and sometimes the topic of competitive programming comes up. Because it’s Reddit, there are often strong opinions. But usually both sides speak up.

/r/learnprogramming is happy to answer these kinds of questions: Need some tips for competitive programming

GitHub

It’s common to post competitive programming solutions on GitHub, and sometimes these show up if people use the term in their readme files or code comments.

Don’t click if you think macros are evil: Basic C++ Template for Competitive Programming

## Stack Overflow

Once or twice per week, a question from Stack Overflow (or occasionally one of the other Stack Exchange sites) will show up in an alert. You might expect this. After all, Stack Overflow is the leading site for programming Q&A, and competitive programmers have questions like any other programmers. But clicking on the links to these questions leads to very different results from clicking on links to similar Quora questions, for reasons having to do with Stack Overflow’s moderation culture.

Fast deletion

Stack Overflow has strict content rules and a culture of enforcing them. Questions that the community (especially high-rep users) feels are low-quality or off-topic get quickly downvoted and/or deleted. It’s not unusual to get an alert for a Stack Overflow competitive programming question that is already deleted by the time I click on it.

Question quality

To some extent, the way competitive programming questions are treated on Stack Overflow is consistent with the way other types of questions are treated. One recent question (#32197358, quickly deleted) was entitled “knowing more about competitive programming” and asked how to “acquire knowledge about competitive programming.” Some variant of this question shows up regularly on Quora as well, and although the community there isn’t quite as hardcore about question quality, questions like this usually get merged into the canonical version of the question. On Stack Overflow, there is no canonical version of this question because it is off-topic for the site. But a question entitled “knowing more about Java” that asked how to “acquire knowledge about Java” would meet the same fate.

Competitive programming questions that manage to avoid getting deleted often attract some interesting comments. I picked a few recent examples to illustrate the issues that come up.

Example #1: Unable to get this competitive programming trick that most top coders use?

In this question, a user asks about a C++ macro found in the solution to a TopCoder problem. After a couple of weeks, the question has a handful of downvotes, ten comments, and no answer. A few comments provide some information, but others, such as these, are less helpful:

• “Top coders would not write or use this sort of thing” and “Nice to read what ‘top’ coders do years ago.” If you mention TopCoder in a Stack Overflow question (and sometimes even on Quora), expect to hear what people think about “top coders.”
• “Making macros is evil” (that’s the whole comment). A common sentiment on Stack Overflow.

This type of commentary is fairly common in Stack Overflow questions about competitive programming. People get fixated on the competitive programming idioms rather than what the question is asking.

This question is on meta.stackoverflow, so it’s a question about Stack Overflow rather than a question about programming. In this question, a user remarks on some of the same issues I brought up in the previous example: he answered a competitive programming question, and got downvoted by people who were hung up on how C++ programmers shouldn’t be using #define and <bits/stdc++.h>.

This Meta question did get a good answer about how to make a competitive programming question on-topic for Stack Overflow. However, some of the comments on the question illustrate the challenges involved in even approaching the subject:

Cheating on coding competitions is on topic at SO. Just don’t assume that you’ll find many programmers that think this is fair play or a worthy use of their free time or a practical problem that needs to be solved for the benefit of humankind. (Hans Passant)

In this comment, Hans Passant, one of the top five users on Stack Overflow, jumps to the conclusion that the only reason to ask about a competitive programming problem is to cheat on a live contest. Furthermore, his reference to a “practical problem that needs to be solved for the benefit of humankind” summarizes the common Stack Overflow opinion that there is no practical value to providing help with a competitive programming problem.

Here’s the response from the problem author:

I am talking about offline practice. Any running contest can not be discussed. But there should be a platform where competitive programmers can show their approach, code and where they are stuck. They should also give some documents which prove that it is not a part of any running contest. If someone proved to be cheated, he could be banned immediately. Most of the online judge problem has done by any other before. So, there should not be free programmer who would solve for the benefit of humankind. (manetsus)

That sounds like a reasonable clarification of the intent of the question, and some details about how manetsus thinks a Q&A site for competitive programming questions would work. Here’s how Hans Passant begins his reply:

“Should”? Some programmers have an odd sense of entitlement, it is not the American way.

This strikes me as a bit of bullying. Manetsus could have more clearly worded his comment as something like: “I’m looking for a platform where competitive programmers can show their approach, code and where they are stuck. Is Stack Overflow the right place for that?” But interpreting his comment as “there needs to be a platform where…” is a rather literalistic approach to an innocent comment.

In a later comment, another user piles on:

“But there should be a platform where competitive programmers can show their approach”. Highly agreed. When will you have it ready? (Gimby)

The combative tone of the responses to this neutrally-worded and relevant question would be surprising if this were any other topic, but it’s not uncommon when the topic is competitive programming.

Example #3: Why should I not #include <bits/stdc++.h>?

This question is about <bits/stdc++.h>, a C++ header file that some competitive programmers use. The purpose of the header is to save coding time during a competition by eliminating the need to #include headers individually. Using Stack Overflow’s self-answer feature, frequent C++ contributor Lightness Races in Orbit asked and answered this question in response to seeing questions about stdc++.h on Stack Overflow.

Lightness Races in Orbit advises against using stdc++.h because it is a non-standard, GCC-specific header that leads to slower compile times and potentially larger executable sizes. Another user, Kuba Ober, agrees, claiming that stdc++.h is “a figment of someone’s imagination” because it’s not part of the C++ standard.

In his answer, Lightness Races in Orbit provides a link to a similar question on Quora, and points to that question as an “example of why Quora is bad.” The consensus in the Quora answers is that using stdc++.h is a good idea in contests, since it is supported by most online judges, and it saves coding time. Some Quora answers do point out that using the header increases compile time and creates a dependency on a particular version of GCC.

The difference between the Stack Overflow answers and the Quora answers to this question illustrates the difference in attitude toward competitive programming on the two sites. The Stack Overflow consensus: stdc++.h is nonstandard and therefore no one should ever use it, even for competitive programming or college classes. The Quora consensus: stdc++.h is supported by the major online judges, and it saves time in a competition, so why wouldn’t you use it?

In my answer to this question, I suggested that people use stdc++.h for competitive programming and not for production code. I got this comment from Lightness Races in Orbit:

Meh, if a programming competition is judging broken, non-standard code then I don’t really get the purpose of it. “Who can make the most broken code the fastest” yay! Well done, I guess….

In other words, he doesn’t accept any exception to the rule against using nonstandard headers. It doesn’t matter that the context is a programming competition where code is not going to be maintained over time or ported to different platforms. If competitive programmers are violating that rule, then programming competitions are pointless and their code is broken.

This is a duplicate of another question. That one also mentions competitive programming, but it got an answer and some constructive comments.

The example #4 question has a comment that sheds some light on the consensus Stack Overflow opinion of competitive programming. After one commenter suggests “stop wasting your time on competitive programming” and the question author asks him to elaborate on his comment, user Blastfurnace writes:

I think the issue with competitive programming is the horrific coding styles used. Most of the code is barely readable, loaded with idiotic macros and single-character variable names. Write-only code that wouldn’t pass the simplest code review in the real world.

I.e.: studying competitive programming is a waste of time because it encourages poor coding style, and the only valuable code is maintainable code.

Here’s how I would summarize the Stack Overflow criticisms of competitive programming:

1. Solving contest puzzles has no practical benefit, so it’s not worth spending time answering questions about them.
2. Competitive programming encourages poor coding style and non-standard practices that are useful only for quickly writing code that won’t be maintained over time. Therefore, we shouldn’t be encouraging people to spend time on it.

I don’t see any justification for the first criticism. Not all code is written to solve a real-world problem. Thousands of Computer Science students every year write code solely for the purpose of learning to code. Their code will never be run in a production environment or maintained over time. After college, sites like Codecademy provide a way for programmers to continue learning in a sandbox environment. There’s even a Stack Exchange site, Programming Puzzles & Code Golf, that focuses exclusively on artificial problems. Competitive programming sites also encourage users to write code to solve puzzles. If someone has a question about a competitive programming puzzle, it should be treated the same way as a question about a Codecademy exercise or a homework problem. The rules for good questions still apply, but the fact that it isn’t real-world code shouldn’t matter.

The second criticism is more subtle. The argument is that by promoting bad style and nonstandard practices, competitive programming runs the risk of reducing the quality of real-world code, as competitive programmers carry bad habits into their programming jobs.

I can understand this concern. It’s certainly possible that a competitive programmer could use a competitive programming coding style in an inappropriate context. Regular Stack Overflow users see a lot of bad coding style. So when they come across a programming culture that seems to encourage bad practices, they want to speak up about it. When the author of a competitive programming question also ignores best practices for asking questions (e.g., explain what research you have done so far), that’s another red flag.

However, it’s a stretch to throw out competitive programming as a whole just because of concerns about standards and coding style. When I’m writing puzzle solutions, I happen to use the same coding style as I do when writing real-world code. For example, I use long variable names and short functions. But right now I’m doing mostly offline solving. If I was spending a lot of time in coding competitions, I might do things differently. An analogy: the type of driving style that is appropriate on the track at the Indy 500 would get a driver pulled over on a public freeway. Different styles are appropriate in different contexts. For some participants in a programming contest, the challenge is to prove that they can solve a problem and implement a solution quickly. The readability of their code is irrelevant because they submit it to the judge and then discard it.

I think much of the reaction that Stack Overflow users have to competitive programming questions comes down to their opinion of the value of competitive programming. If someone believes that CP is pointless, then every error a question author makes is exaggerated. “Not only are they ignoring the question rules, but they’re asking about something pointless!”

On Quora, there are enough users who buy into the inherent value of competitive programming that CP questions can get direct answers rather than answers that only focus on the fact that someone is using a CP-specific programming style.

In 2014, there was a failed attempt to create a Stack Exchange site dedicated to competitive programming. Why did the proposal fail? One reason is that Stack Exchange has strict rules about accepting new sites. They would rather prevent a site from starting than create a site with insufficient engagement from its users. Even Programming Puzzles & Code Golf, a fairly popular site, has languished in Beta status for years because it can’t quite meet the metrics that Stack Exchange requires.

But the other reason is that supporters of the site weren’t able to muster enough support. If the competitive programming community is going to get their own Stack Exchange site (which I think would be worthwhile), more people will need to buy in to the Stack Exchange approach to Q&A. In the meantime, it won’t hurt to get more quality CP questions on Stack Overflow. To that end: