Skip to content
Surf Wiki
Save to docs
general/capitalization

From Surf Wiki (app.surf) — the open knowledge base

Snake case

Words joined with underscores


Words joined with underscores

Snake case (sometimes stylized autologically as snake_case) is the naming convention in which each space is replaced with an underscore (_) character, and words are written in all lower case. It is a commonly used naming convention in computing, for example for variable and subroutine names, and for filenames. One study has found that readers can recognize snake case values more quickly than camel case. However, "subjects were trained mainly in the underscore style", so the possibility of bias cannot be eliminated.

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:

, 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

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, but not for 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

References

References

  1. (2010). "2010 IEEE 18th International Conference on Program Comprehension".
  2. (8 September 2023). "Snake Case".
  3. Guido van Rossum. (2001-07-05). "PEP 0008 -- Style Guide for Python Code".
  4. Gavin Kistner. (2004-02-23). "Appropriate use of camelCase".
  5. "What's the name for snake_case with dashes?".
  6. "Programmers – If this is camelCase what-is-this?".
  7. (23 April 2020). "Camel_SNAKE-kebab".
  8. "Naming Conventions in ABAP Objects".
  9. "Ada Programming Guidelines".
  10. "Boost Library Requirements and Guidelines".
  11. (28 December 2019). "Eiffel Class and Feature Names".
  12. (May 2020). "Elixir Style Guide".
  13. "Programming Rules".
  14. "GDScript Style Guide — Godot Engine (3.0) documentation in English".
  15. "Code Conventions for the Java Programming Language – Naming Conventions". Oracle.
  16. "Coding Conventions".
  17. "Xen wiki".
  18. Damian Conway. (2005). "Perl Best Practices". O'Reilly Media Inc..
  19. "Quick Guide to Some Sources for Naming Conventions for Oracle Database Development".
  20. (2009). "Coding Guidelines for Prolog (v.3)".
  21. (July 1965). "IBM Operating System/360 PL/I: Language Specifications".
  22. Wickham, Hadley. "The tidyverse style guide".
  23. (May 2020). "Ruby Naming Conventions".
  24. "Naming – Rust API Guidelines".
  25. (Feb 2022). "Terraform Naming Conventions".
  26. "Documentation - The Zig Programming Language".
Info: Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about Snake case — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report