Not signed in (Sign In)

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  

    This question about the Atkin sieve includes an amount of C++ code that's much longer than the text of the post.

    I'm having trouble finding other examples, but I know there have been other such posts. Generally I think that many of us aren't willing to read large amounts of code, especially in unfamiliar languages. (C++ is hardly obscure, but I'm not a programmer.)

    Perhaps the "how to ask" page should include something like "if your post includes lots of code, this probably isn't the right place for it?" This seems to be in keeping with the general mathematical ethos that papers don't include code (at least, not outside of an appendix); most "experimental" papers that I've read seem to include a high-level description of the algorithm, maybe even in pseudocode, but not something somebody could actually run.

  2.  
    I made such a post. Most of the code was for graphing purposes; I haven't had time yet to follow up on my own question re: a Poincaré map. I think in certain carefully constrained contexts the inclusion of code can help. For instance if it's something that many folks could run without any real effort, then it can be used to illustrate a problem.

    Given that, and because MO isn't a place for publication of papers but a place to ask questions, I don't think it's necessarily helpful to take a firm stance on including code.
  3.  

    The asker has answered himself, and the question has since been closed. This particular question was inappropriate, but I agree there's no need for a "rule" about long chunks of code being disallowed.

  4.  

    That particular question was inappropriate.

    I agree that long chunks of code shouldn't be disallowed but I also agree with Michael that there should be something in the "how to ask" page asking people to describe their algorithms in higher level terms, rather than in code. Perhaps it's just me but I couldn't write c++ code if my life depended on it, without investing some time in learning the syntax. However I'm well capable of following the reasoning behind an algorithm, and could possibly be of help to OP's if they wrote in higher-level terms rather then code.

    If a question really is about the maths behind an algorithm, then that's fine and the question should be written in terms understandable to a lot of mathematicians. If however the question is sensitive tot which programming language it is written in, then it probably is not an MO question.

  5.  

    That particular question didn't belong on the forum, because the math was elementary. But I could imagine having a question where a program wasn't performing as expected and I didn't know whether the flaw was in my understanding of the mathematics or my implementation of the algorithm; I think it would be OK to post code in that case.

  6.  

    Just to make it clear, I'm not saying that long amounts of code should be disallowed.

    • CommentAuthorrwbarton
    • CommentTimeJan 27th 2010
     

    I tihnk it would generally be best to include an appropriately high-level explanation of what the code is about in English, so that people can determine whether they are interested in the question, together with a link to the code on a pastebin site (e.g. gist.github.com) for the full gory details.

  7.  

    There are many sites where you can post your code and have it nicely formatted, line numbers, easy download etc. I think linking to a code pasted onto one those sites would be a much better choice than pasting it directly into the question text. This may not apply if the code itself is the primary object of the question, but I don't imagine how it would be possible for a question appropriate for MO.

  8.  

    Ilya, as far as I can tell we are one of those sites, at least with respect to the first condition. Although see this discussion on SO as to why there are no line numbers: http://meta.stackoverflow.com/questions/7119/why-are-there-no-line-numbers-in-the-code-listings.

  9.  

    @Qiaochu: from that link (emphasis mine)

    Most code that is going to be posted on the site is going to be a short snippet where the relevant parts are the only ones going to be posted. Anything that gets a little longer will usually have comments in relevant parts explaining what's going on. We're programmers, I think that suffices. Allowing lines might encourage bigger code blocks, and that's not a behavior I think we want to encourage.

  10.  

    I feel like we shouldn't be more code-friendly than Stack Overflow, given that Stack Overflow clearly has a lot more people who can actually read code.