Skip to Main Content

Computer Science

A guide to help computer science folks at NYU get to the resources they need.

Citing Code

Given that you'll use code you don't write, it's natural that you should cite that code!

It can be hard to to know what resources need to be cited and what resources don't. Generally, if you used a function or algorithm that you did not create and it came from someone else then this should be cited so as to give the creator credit. Ideas and programs that are "common knowledge" do not generally need to be referenced or cited.  If there is only one way to program for a specific task and this is so commonly used then it may not need to be cited (like printing "hello world").

I would recommend in general citing things that affect the analytical result you are presenting. For example, you don't cite Microsoft Office for helping you write your paper, but DO cite scikit-learn as software that contributed to your analysis!

A code citation should include the following fields:

  • Title: the title of the code/software package or a brief description of it if missing a title
  • Author or creator: the entity/entities responsible for creating the code (e.g. maintainers, an institution or company)
  • Date of publication: the date the code was published or otherwise released to the public
  • Publisher: entity responsible for hosting the code (e.g. GitHub, an archive)
  • DOI (or URL if none exists): a persistent link to the code
  • Version number or Date Downloaded: if a version or release number exists, that is a great pointer to the specific code you used. if that doesn't exist, using the date that you last downloaded the code is great
  • (optional) Commit Hash: if you are citing a Git repository, I recommend also adding in the commit hash. these pointers help your readers know exactly which version of the code that you used, which is helpful for reproducibility

You should also use a citation manager to keep track of all these citations! I recommend Zotero - check out our Zotero guide.

StackOverflow Comments

You should be citing citing specific code snippets you use from StackOverflow -- if you don't know, it is a popular place to look for help on writing code, and people often will re-use code snippets from StackOverflow. User submitted content, including code snippets, are licensed under a Creative Commons ShareAlike license (read more from StackOverflow directly). Content written after May 2, 2018 is licensed under the CC BY-SA 4.0, and snippets written earlier use the earlier version of the license. You can view the terms of this license here.

Citing code tutorial (video 33 minutes, 18 seconds)