Motivation and Intro

Motivation

Scientific coding varies greatly from a software developer’s workflow. As a scientist, you’re most likely experimenting with your code and might have a lot of experiments occuring simultaneously, whereas a software developer might have a more solidified goal in mind.

Everyone optimizes their time while prioritizing different areas. Generally scientists optimize for:

  • correct science
  • publishing

Unfortunately for most scientists who code, science education hasn’t caught up with the wide application of Computer Science. Best practices are low on the priority list; things like setting up a dev environment, keeping up with documentation, and writing tests to make sure your code is actually doing what you think it is.

nbdev!

Here I’ll walk through a tool called nbdev, a package that’s meant for exploratory programming, that trades a small amount of effort for auto-generating documentation and easier tests:

  • set it and forget it
  • auto-generating documentation
  • easier tests
  • how to update your files

nbdev lets you use LaTex. \[\sum_{n=1}^{\infty} 2^{-n} = 1\]

Takeaways

If you’re ever going to code, it makes sense to invest some time right now to learn coding best practices. This will both help future-you understand your code, help potential collaborators understand your code, and make it easier to publish your code(especially to something like JOSS)!

Consistency is key so have a system and stick to it, whether it’s nbdev or jupyter notebook notes or lots of comments.