Lurker News
I'm looking for advice om whether I should publish my research code? The paper itself is enough to reproduce all the results. However, the implementation can easily take two months of work to get it right.

In my field many scientists tend to not publish the code nor the data. They would mostly write a note that code and data are available upon request.
I can see the pros of publishing the code as it's obviously better for open science and it makes the manuscript more solid and easier for anyone trying to replicate the work.
But on the other hand it's substantially more work to clean and organize the code for publishing, it will increase the surface for nitpicking and criticism (e.g. coding style, etc). Besides, many scientists look at code as a competitive advantage so in this case publishing the code will be removing the competitive advantage.

Comments (353) 192 threads

Earlier comments
JoaoCostaIFG#
I'm currently a student getting a master's in computer science. In my experience, having the code available in research papers is rare, but useful. Many times I find myself struggling to understand how something can be implemented or, when presented with choices, choosing one when reading research papers. When the paper has the code published I am able to follow it better.

Some papers link to the code instead of including it. Maybe I'm just unlucky, but this usually leads to dead links (but that's a different topic altogether).

rasmusei#
I work as a researcher and I try to publish full source code for all my publications. On the point of increasing surface for nitpicking, I agree in principle that's a risk, but in practice I have not experienced any such problems in my field. I am in a field of applied natural science where most researchers write terrible code, if any, and so I suppose there are not much expectations or even concepts of coding style.

There is a nice Perspective piece in Science from 2011 [1] touching on the question of cleaning up the code. It suggests basically the same thing as several of the comments in this thread: if you don't have time or motivation to clean up the code, don't.
"even incremental steps would be a vast improvement over the current situation. To this end, I propose the following steps (in order of increasing impact and cost) that individuals and the scientific community can take. First, anyone doing any computing in their research should publish their code. It does not have to be clean or beautiful (13), it just needs to be available. Even without the corresponding data, code can be very informative and can be used to check for problems as well as quickly translate ideas. ... The next step would be to publish a cleaned-up version of the code along with the data sets in a durable non-proprietary format."
[1] Peng (2011) Science 334 1126-1127 https://doi.org/10.1126/science.1213847

yellowapple#
Well I'm no scientist, but the one thing I do know about science is that if it can't be replicated then it ain't really science. Seeing as how the code is pretty important for expediently replicating your work, it seems like doing so in the interest of facilitating that replication takes precedent over any sort of "competitive advantage". If that sort of transparency ain't common in your field, then maybe this is your opportunity to lead by example and change that?
jll29#
Publishing the code is great, as some of the questions a reader of your paper may have can only answered by looking into the source code, as no paper has enough space to talk about all implementation details in a real-life complex system.

There is value in scrutinizing the code - not w.r.t. coding styles or standards but to discover bugs in the implementation, which are very common. Scientists are only human, and scientific software is less often checked by a second pair of eyes. There is also value in trying to replicate a study from scratch with a fresh implementation only from the details in the paper. Many conferences, for instance the European Conference on Information Retrieval (ECIR), Europe's largest scientific search technology conference, has a replication track only for replication papers, and these are often the most interesting/insightful papers. It occasionally happens that a result is not caused by what the authors think, but is merely an artifact of the implementation code. A very famous MIT researcher (not naming him or her here on purpose) fell into this trap in their Ph.D. thesis, but it can happen to anyone, really. Scientific results become objective knowledge as others solidify the body of knowledge by carrying out replications and arriving at the same results.
Whatever your decision about past code, going forward, if you plan to release all future research code, you will likely write better code in the first place, as you will constantly be aware that people will be looking at it, and that can only be a good thing.

Load more comments