HOME

TheInfoList



OR:

Snake case (stylized as snake_case) refers to the style of writing in which each space is replaced with an
underscore An underscore, ; also called an underline, low line, or low dash; is a line drawn under a segment of text. In proofreading, underscoring is a convention that says "set this text in italic type", traditionally used on manuscript or typescript ...
(_) character, and the first letter of each word is written in lowercase. It is a commonly used naming convention in
computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, for example for variable and
subroutine In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed. Functions may ...
names, and for
filename A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose different restrictions on filename lengths. A filename may (depending on the file system) include: * name &ndas ...
s. One study has found that readers can recognize snake case values more quickly than
camel case Camel case (sometimes stylized as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation. The format indicates the separation of words with a single ...
. However, "subjects were trained mainly in the underscore style", so the possibility of bias cannot be eliminated.


History

The use of underscores as word separators dates back to the late 1960s. It is particularly associated with C, is found in ''
The C Programming Language ''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
'' (1978), and contrasted with pascal case (a type of
camel case Camel case (sometimes stylized as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation. The format indicates the separation of words with a single ...
). However, the convention traditionally had no specific name: the
Python programming language Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming p ...
style guide refers to it simply as "lower_case_with_underscores". Within
Usenet Usenet () is a worldwide distributed discussion system available on computers. It was developed from the general-purpose Unix-to-Unix Copy (UUCP) dial-up network architecture. Tom Truscott and Jim Ellis conceived the idea in 1979, and it wa ...
the term snake_case was first seen in the
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called ...
community in 2004, used by Gavin Kistner, writing: However, former Intel engineer Jack Dahlgren has stated that he was using the term internally at Intel (and perhaps in dialogue with
Microsoft Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washi ...
engineers) in 2002. It is possible that the term developed independently in more than one community. , names for other delimiter-separated naming conventions for multiple-word identifiers have not been standardized, although some terms have increasing levels of usage, such as lisp-case, kebab-case, SCREAMING_SNAKE_CASE, and more.


Examples

A list of programming languages that conventionally use snake case *
ABAP ABAP (Advanced Business Application Programming, originally ''Allgemeiner Berichts-Aufbereitungs-Prozessor'', German for "general report preparation processor") is a high-level programming language created by the German software company SAP SE. ...
*
Ada Ada may refer to: Places Africa * Ada Foah, a town in Ghana * Ada (Ghana parliament constituency) * Ada, Osun, a town in Nigeria Asia * Ada, Urmia, a village in West Azerbaijan Province, Iran * Ada, Karaman, a village in Karaman Province, T ...
, with initial letters also capitalized *
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
, Boost * C, for some type names in the standard library, but not for function names. * Eiffel, for class and feature names *
Elixir ELIXIR (the European life-sciences Infrastructure for biological Information) is an initiative that will allow life science laboratories across Europe to share and store their research data as part of an organised network. Its goal is to bring t ...
, for atom, variable, and function names * Erlang, for function names *
GDScript Godot ( /ˈɡɒdoʊ/) is a cross-platform, free and open-source game engine released under the MIT license. It was initially developed by Argentine software developers Juan Linietsky and Ariel Manzur for several companies in Latin America prior ...
, for variable and function names *
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
uses SCREAMING_SNAKE_CASE for static final constants and enum values. * Magik *
OCaml OCaml ( , formerly Objective Caml) is a general-purpose, multi-paradigm programming language Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. ...
, for value, type, and module names *
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
, for lexical variables and subroutines *
Oracle An oracle is a person or agency considered to provide wise and insightful counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. As such, it is a form of divination. Description The word ...
SQL and
PL/SQL PL/SQL (Procedural Language for SQL) is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database (since version 6 - stored PL/SQL procedures/functions/packages/triggers since ...
, for all unquoted identifiers (tables, columns, indexes, constraints, PL/SQL variables, constants, procedures/functions, triggers,...), although not official by Oracle itself, still recommended by the majority of known "influencers" and used throughout the official Oracle documentation **All unquoted snake_case identifiers are actually internally represented as SCREAMING_SNAKE_CASE identifiers. *
Prolog Prolog is a logic programming language associated with artificial intelligence and computational linguistics. Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is intended primarily ...
, for both atoms (predicate names, function names, and constants) and variables * Python, for variable names, function names, method names, and module or package (i.e. file) names * PHP uses SCREAMING_SNAKE_CASE for class constants * R, for variable names, function names, and argument names, especially in the tidyverse style *
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called ...
, for variable and method names *
Rust Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO( ...
, for variable names, function names, method names, module names, and macros * Tcl *
Terraform (software) Terraform is an open-source infrastructure-as-code software tool created by HashiCorp. Users define and provide data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL), or optionall ...
, for resources and variables


See also

*
Camel case Camel case (sometimes stylized as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation. The format indicates the separation of words with a single ...
, more common in
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
and C# * Kebab case, more common in
LISP A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech. Types * A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lispin ...
*
Naming convention (programming) In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation. Reasons for using a na ...


References


External links


Snake case converter
{{Typography Capitalization Naming conventions Typography Source code