Snake case explained

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 lowercase. 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.[1]

A variation is screaming snake case, where words are written in all caps (stylized as SCREAMING_SNAKE_CASE).[2] 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".[3]

Within Usenet the term snake_case was first seen in the Ruby community in 2004,[4] 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 engineers) in 2002.[5] 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.[6] [7] [8]

Examples

The following programming languages use snake case by convention:

See also

External links

Notes and References

  1. Book: An Eye Tracking Study on camelCase and under_score Identifier Styles . 10.1109/ICPC.2010.41 . 978-1-4244-7604-6 . 2010 IEEE 18th International Conference on Program Comprehension . 2010 . Sharif . Bonita . Maletic . Jonathan I. . 196–205 . 10.1.1.421.6137 . 14170019 .
  2. Web site: Snake Case . Mozilla Developer Network . 8 September 2023 . November 10, 2023.
  3. Web site: PEP 0008 -- Style Guide for Python Code . 2001-07-05 . Guido van Rossum . Barry Warsaw . Nick Coghlan .
  4. Appropriate use of camelCase. Gavin Kistner. 2004-02-23. comp.lang.ruby. HBn_b.379957$xy6.2073499@attbi_s02. 2015-08-13.
  5. Web site: 2013-05-10. Quora.
  6. Web site: StackOverflow – What's the name for snake_case with dashes? .
  7. Web site: Programmers – If this is camelCase what-is-this? . 2015-08-13 . 2016-08-07 . https://web.archive.org/web/20160807114459/http://programmers.stackexchange.com/questions/104468/if-this-is-camelcase-what-is-this .
  8. Web site: Camel_SNAKE-kebab . . 23 April 2020 .
  9. Web site: Naming Conventions in ABAP Objects. 2020-07-28. help.sap.com.
  10. Web site: Ada Programming Guidelines .
  11. Web site: Boost Library Requirements and Guidelines . 2015-08-13.
  12. Web site: Eiffel Class and Feature Names . 28 December 2019 .
  13. Web site: Elixir Style Guide . . May 2020 .
  14. Web site: Programming Rules . 2017-08-11 . 2010-09-04 . https://web.archive.org/web/20100904160816/http://www.erlang.se/doc/programming_rules.shtml#REF10726 .
  15. Web site: GDScript Style Guide .
  16. Web site: Code Conventions for the Java Programming Language – Naming Conventions . Oracle . 2021-08-03.
  17. Web site: Coding Conventions . 2023-02-03.
  18. Web site: Xen wiki . 2017-03-15.
  19. Book: Perl Best Practices . limited . O'Reilly Media Inc. . Damian Conway . 2005 . 978-0-596-00173-5 . 44.
  20. Web site: Quick Guide to Some Sources for Naming Conventions for Oracle Database Development. 2020-12-30. stevenfeuersteinonplsql.blogspot.com.
  21. Coding Guidelines for Prolog (v.3) . Michael A. Covington . Roberto Bagnara . Richard A. O'Keefe . Jan Wielemaker . Simon Price . 14 . 2009 . cs.PL . 0911.2899 .
  22. Book: IBM . IBM Operating System/360 PL/I: Language Specifications . July 1965 . 16 . November 12, 2023.
  23. Book: Wickham, Hadley. The tidyverse style guide.
  24. Web site: Ruby Naming Conventions . . May 2020 .
  25. Web site: Naming – Rust API Guidelines . 2019-10-27 . 2018-09-16 . https://web.archive.org/web/20180916230852/https://rust-lang-nursery.github.io/api-guidelines/naming.html .
  26. Web site: Terraform Naming Conventions . Feb 2022 .
  27. Web site: Documentation - The Zig Programming Language. 2024-03-10.