Snake case
Words joined with underscores
- 2 min read
- 2 chapters
Related on Lably
Through Computing, Variable (high-level programming language) and Function (computer programming)
A variation is screaming snake case, where words are written in all caps (stylized as SCREAMING_SNAKE_CASE). This convention is used for constants in programming languages like C/C++, Python, Java, PHP, as well as for environment variables.
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 (1978), and contrasted with pascal case (a type of camel case). However, the convention traditionally had no specific name: the Python programming language style guide refers to it simply as "lower_case_with_underscores".
Within Usenet the term snake_case was first seen in the Ruby community in 2004, used by Gavin Kistner, writing:
BTW...what *do* you call that naming style? snake_case? That's what I'll call it until someone corrects me.
As of 2015, 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.
Sign in to keep reading
One more chapter is free with a Lably account.
Examples
The following programming languages use snake case by convention:
- ABAP
- Ada, with initial letters also capitalized
- C++ Standard Library and Boost for symbols. C++ does not have a widely agreed-upon naming convention for classes and functions by its wider community.
- C, for some type names in the standard library, and since C11, in some function names.
- Eiffel, for class and feature names
- Elixir, for atom, variable, and function names
- Erlang, for function names
- GDScript, for variable and function names
- Java uses SCREAMING_SNAKE_CASE for static final constants and enum values.
- Kotlin uses SCREAMING_SNAKE_CASE for constants and enum values
- Magik
- OCaml, for value, type, and module names
- Perl, for lexical variables and subroutines
- Oracle SQL and PL/SQL, 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, 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
- PL/I
- R, for variable names, function names, and argument names, especially in the tidyverse style
- Ruby, for variable and method names
- Rust, for variable names, function names, method names, module names, and macros
- Tcl
- Terraform (software), for resources and variables
- Zig, for variables

