Best Practices for Scientific Computing

Greg Wilson, D. A. Aruliah, C. Titus Brown, Neil Chue Hong, M. Ryleigh Davis, Richard Guy, Steven H. D. Haddock, Kathryn Huff, Ian M. Mitchell, Mark D. Plumbley, B. M. Waugh, Ethan P. White, Paul Wilson

Abstract

We describe a set of best practices for scientific software development, based on research and experience, that will improve scientists' productivity and the reliability of their software.

Introduction

Software has become as essential to modern science as telescopes or test tubes. However, while researchers are meticulously trained in laboratory protocols, approximately 90% of them are self-taught when it comes to computing. This lack of formal training often results in "fragile" software—code that is difficult to maintain, hard for others to verify, and prone to "cascading impacts" where a single undetected error can invalidate years of research.

This paper provides a practical roadmap of 24 evidence-based best practices designed to bridge the gap between professional software engineering and the unique, often exploratory nature of scientific research. By adopting these methods, researchers can make their computing more reliable, readable, and productive.

The Eight Pillars of Scientific Computing

The authors synthesize decades of collective experience from the Software Carpentry project and empirical studies into eight core categories:

1. Write Programs for People, Not Computers

The most important "user" of your code is your future self or a colleague. Because human working memory is limited, code should be broken into small, "chunkable" functions that perform a single task. Prioritizing readability and using meaningful variable names reduces the cognitive load required to understand and debug the software.

2. Let the Computer Do the Work

Scientists should avoid repetitive manual tasks. Using build tools, scripts, and automation not only saves time but also eliminates the human error inherent in manual data processing.

3. Make Incremental Changes

Working in small, manageable steps and using a Version Control System (VCS) like Git is the foundation of modern development. It allows researchers to track changes, collaborate effectively, and ensure the provenance of their data and results.

4. Don’t Repeat Yourself (DRY)

Every piece of data or logic should have a single authoritative representation. Duplication is a primary source of maintenance nightmares and inconsistent results. Emphasizing modularity and the reuse of existing, well-tested libraries is essential.

5. Plan for Mistakes

Software should be treated like any other piece of experimental equipment. Just as a scale must be calibrated, code must be "checked" using assertions and automated unit testing to catch errors early, before they propagate through a study.

6. Optimize Software Only After It Works Correctly

Scientists are most productive when writing in high-level languages like Python or R. Researchers should only move to low-level languages (like C++ or Fortran) if a profiler proves a specific section is a genuine bottleneck. Premature optimization is a common waste of valuable research time.

7. Document Design and Purpose, Not Mechanics

Documentation should explain why code does something and how the pieces fit together, rather than just restating what the code is doing. The "how" should be clear from the code itself if it is well-written.

8. Collaborate

Utilizing code reviews and issue trackers fosters a culture of shared responsibility and higher quality. Peer review for code is just as vital as peer review for manuscripts.

Impact and Results

While this guide is pedagogical rather than a quantitative study, it draws on established software engineering research to argue for significant benefits:

  • Productivity Gains: The time invested in learning these tools is almost immediately offset by the time saved in debugging and manual repetition.
  • Error Reduction: Empirical studies show that practices like modularization and code reviews significantly reduce error rates.
  • Reproducibility: These 24 recommendations are the prerequisites for reproducible research. Without version control and readable code, the chances of independent verification are remote.

Conclusion

Implementing all 24 practices at once can be intimidating. The authors suggest an incremental approach, introducing tools over time. However, the long-term goal is a shift in scientific culture. Universities and funding agencies must move beyond "self-taught" models and formally support the training of scientists in these essential computing skills to ensure the continued integrity of digital-age research.

Summary updated

BibTeX
@inproceedings{wilson2014best,
  author = {Greg Wilson and D. A. Aruliah and C. Titus Brown and Neil Chue Hong and M. Ryleigh Davis and Richard Guy and Steven H. D. Haddock and Kathryn Huff and Ian M. Mitchell and Mark D. Plumbley and B. M. Waugh and Ethan P. White and Paul Wilson},
  title = {{Best Practices for Scientific Computing}},
  booktitle = {PLoS},
  year = {2014},
  doi = {10.1371/journal.pbio.1001745},
}
Figure