Note: This post relates to content in the eighth edition of the MLA Handbook. For up-to-date guidance, see the ninth edition of the MLA Handbook.

To cite source code—the written portion of a piece of software or a larger program—begin with the MLA format template.1 In what follows, I explain how elements on the template apply to source code and show you how to construct an entry.

Author

Source code can be written by a person, a group of persons, or an organization (e.g., Chromium Authors). Authors are usually specified in the code itself or, on a website like GitHub, as the owner of the repository in which the code appears. If individual contributors are not given, treat the organization named as the owner of the license or the holder of the copyright as the author. If the organization is both author and publisher, begin your entry with the title. 

In the rest of the post, I walk you through the process of creating a works-cited-list entry for a work of source code, Buffer.java, where the publisher is the author.

Title of Source

Source code is typically presented in discrete text files, and the file name can serve as the title. When citing titles in MLA style you would normally standardize the capitalization. However, you should not do this for titles of source code. The cases of characters are meaningful in a programming context, so you should reproduce the file name exactly as you found it. Provide the file extension when you give the title. Examples of file extensions on source code files include .java for Java code, .cc for C++ code, and .py for Python code. To cite the source code for Buffer.java, begin your entry with the title:

Buffer.java.

Title of Container

The container will be either the name of the software or the package in which the code is found.2 A package is a container of source code files within a larger program. The code for a piece of software is contained in the software itself, and so the software is the container. For Buffer.java, the container is Apache Hadoop, a collection of software:

Buffer.java. Apache Hadoop,

Version

Since source code often exists in several versions, provide the version of the code you consulted. This could be a version of software, a particular revision in a repository, or a commit hash (a unique string of letters and numbers that identifies a version of a piece of code). This is important information because both URLs and source code tend to change, so providing as much information as possible makes it more likely that readers will be able to find what you are citing. In the example that follows, the commit hash appears after the package name and specifies the version of the code being cited:

Buffer.java. Apache Hadoop, commit ef9946cd52d54200c
658987c1dbc3e6fce133f77,

Publisher 

The publisher for the software or the package in which the code is found is usually the organization that produced the code. Here, the software that contains the source code is published by the Apache Software Foundation:

Buffer.java. Apache Hadoop, commit ef9946cd52d54200c658987
c1dbc3e6fce133f77, Apache Software Foundation,

Date

The date may not be specified in source code, in which case you can omit it. If you do see a date, provide it:

Buffer.java. Apache Hadoop, commit ef9946cd52d54200c658987
c1dbc3e6fce133f77, Apache Software Foundation, 2015.

Since there is no information relevant to the “Location” element, this is the end of container 1.

Title of Container 2

If you are consulting code on a website, you will need to provide information for that website as the second container. In what follows, the website GitHub is the second container. No publisher is specified for the website GitHub, because it is published by GitHub (MLA Handbook 42).

Buffer.java. Apache Hadoop, commit ef9946cd52d54200c658987
c1dbc3e6fce133f77, Apache Software Foundation, 2015. GitHub,

Location

If you are documenting source code on a website, provide the URL as the location. The MLA recommends removing “http://” and “https://” protocols from URL addresses in printed works, in which the creation of hyperlinks is irrelevant, although if the protocol is anything else, such as “ftp://,” you should include it. If you are citing these sources in a format that has the ability to display hyperlinks—for instance, if they will be displayed in html—do include the protocol. If the URL does not provide the full path to the file, you should include the full path as the file name. In the example that follows, the URL comes after the container and provides the full path to the file.

Buffer.java. Apache Hadoop, commit ef9946cd52d54200c658987c1dbc3e6fce133f77, Apache Software Foundation, 2015. GitHub, github.com/apache/hadoop/blob/
release-3.1.0-RC1/hadoop-tools/hadoop-streaming/src/main/
java/org/apache/ hadoop/record/Buffer.java.

The examples of in-text citations that follow are adapted from links posted on MIT’s website devoted to academic integrity (“Writing Code”). For in-text citations, if you are citing a particular method, class, subroutine, or block of code, provide the line number or numbers if known.

“The method OutputTraceToStream may be found in stack_trace_win.cc, source code written for the Chromium project” (Chromium Authors, line 59).

“As the developers note, this ‘utility class’ was intended to give ‘applets the ability to detect proxy host settings’” (PluginProxyUtil.java).   

Works Cited

Chromium Authors. stack_trace_win.cc. Chromium, commit c566864c0ebfa9f46a8b61cb6c587444580fe494, Adobe Systems Incorporated, 2011. GitHub, github.com/adobe/chromium/
blob/master/base/debug/stack_trace_win.cc.

PluginProxyUtil.java. HttpClient, version 3.0, Apache Software Foundation. Apache Software Foundation, svn.apache.org/repos/asf/
httpcomponents/oac.hc3x/tags/HTTPCLIENT_3_0/src/contrib/org/
apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java.

Notes

I thank Ryan Williams, former senior web developer at the MLA, for his assistance with this post.

1. A fuller definition of source code, as defined by Merriam-Webster’s Collegiate Dictionary, is “a computer program in its original programming language (such as FORTRAN or C) before translation into object code usually by a compiler” (“Source Code, Noun”). The Linux Information Project specifies that “source code” is “the version of the software as it is originally written (i.e., typed into a computer) by a human in plain text (i.e., human readable alphanumeric characters)” (“Source Code Definition”).

2. Usually when citing works in MLA style, you would not consider software to be a container. For example, in the case of a work downloaded from the Internet as a PDF and opened with Adobe Reader DC, Adobe Reader DC is not the container but the tool you used to open the work. When you’re citing source code, however, the software is the work.

Works Cited

MLA Handbook. 8th ed., Modern Language Association of America, 2016.

“Source Code, N.”  Merriam-Webster Unabridged, 2018, unabridged.merriam-Webster.com/collegiate/source%20code.

“Source Code Definition.” The Linux Information Project, 23 May 2004, www.linfo.org/source_code.html.

“Writing Code.” Academic Integrity at MIT: A Handbook for Students, integrity.mit.edu/handbook/writing-code.

Photo of Joseph Wallace

Joseph Wallace

Joseph Wallace copyedits articles for PMLA and writes posts for the Style Center. He received a PhD in English literature from the University of North Carolina, Chapel Hill. Before coming to the Modern Language Association, he edited articles for Studies in Philology and taught courses on writing and early modern literature.