Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Snake case

From Wikipedia, the free encyclopedia
Words joined with underscores
This articlerelies excessively onreferences toprimary sources. Please improve this article by addingsecondary or tertiary sources.
Find sources: "Snake case" – news ·newspapers ·books ·scholar ·JSTOR
(August 2015) (Learn how and when to remove this message)
Piece of code from a module of theLinux kernel, which uses snake case for identifiers

Snake case (sometimes stylizedautologically assnake_case) is thenaming convention in which each space is replaced with anunderscore (_) character, and words are written inall lower case. It is a commonly used naming convention incomputing, for example forvariable andsubroutine names, and forfilenames. One study has found that readers can recognize snake case values more quickly thancamel case. However, "subjects were trained mainly in the underscore style", so the possibility of bias cannot be eliminated.[1]

A variation isscreaming snake case, where words are written inall caps (stylized as SCREAMING_SNAKE_CASE).[2] This convention is used forconstants in programming languages likeC/C++,Python,Java,PHP, as well as forenvironment variables.

History

[edit]

The use of underscores as word separators dates back to the late 1960s. It is particularly associated withC, is found inThe C Programming Language (1978), and contrasted with pascal case (a type ofcamel case). However, the convention traditionally had no specific name: thePython programming language style guide refers to it simply as "lower_case_with_underscores".[3]

WithinUsenet the term snake_case was first seen in theRuby community in 2004,[4] 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[update], names for other delimiter-separatednaming 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.[5][6][7]

Examples

[edit]

The following programming languages use snake case by convention:

  • ABAP[8]
  • Ada, with initial letters also capitalized[9]
  • C++ Standard Library andBoost for symbols.[10]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[11]
  • Elixir, for atom, variable, and function names[12]
  • Erlang, for function names[13]
  • GDScript, for variable and function names[14]
  • Java uses SCREAMING_SNAKE_CASE for static final constants and enum values.[15]
  • Kotlin uses SCREAMING_SNAKE_CASE for constants and enum values[16]
  • Magik
  • OCaml, for value, type, and module names[17]
  • Perl, for lexical variables and subroutines[18]
  • Oracle SQL andPL/SQL,[19] 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[20]
  • Python, for variable names, function names, method names, and module or package (i.e. file) names[3]
  • PHP uses SCREAMING_SNAKE_CASE for class constants
  • PL/I[21]
  • R, for variable names, function names, and argument names, especially in the tidyverse style[22]
  • Ruby, for variable and method names[23]
  • Rust, for variable names, function names, method names, module names, and macros[24]
  • Tcl
  • Terraform (software), for resources and variables[25]
  • Zig, for variables[26]

See also

[edit]

References

[edit]
  1. ^Sharif, Bonita; Maletic, Jonathan I. (2010). "An Eye Tracking Study on camelCase and under_score Identifier Styles".2010 IEEE 18th International Conference on Program Comprehension(PDF). pp. 196–205.CiteSeerX 10.1.1.421.6137.doi:10.1109/ICPC.2010.41.ISBN 978-1-4244-7604-6.S2CID 14170019.
  2. ^"Snake Case".Mozilla Developer Network. 8 September 2023. RetrievedNovember 10, 2023.
  3. ^abGuido van Rossum; Barry Warsaw; Nick Coghlan (2001-07-05)."PEP 0008 -- Style Guide for Python Code".
  4. ^Gavin Kistner (2004-02-23)."Appropriate use of camelCase".Newsgroupcomp.lang.ruby.Usenet: HBn_b.379957$xy6.2073499@attbi_s02. Retrieved2015-08-13.
  5. ^"StackOverflow – What's the name for snake_case with dashes?".
  6. ^"Programmers – If this is camelCase what-is-this?". Archived fromthe original on 2016-08-07. Retrieved2015-08-13.
  7. ^"Camel_SNAKE-kebab".GitHub. 23 April 2020.
  8. ^"Naming Conventions in ABAP Objects".help.sap.com. Retrieved2020-07-28.
  9. ^"Ada Programming Guidelines".
  10. ^"Boost Library Requirements and Guidelines". Retrieved2015-08-13.
  11. ^"Eiffel Class and Feature Names". 28 December 2019.
  12. ^"Elixir Style Guide".GitHub. May 2020.
  13. ^"Programming Rules". Archived fromthe original on 2010-09-04. Retrieved2017-08-11.
  14. ^"GDScript Style Guide".
  15. ^"Code Conventions for the Java Programming Language – Naming Conventions". Oracle. Retrieved2021-08-03.
  16. ^"Coding Conventions". Retrieved2023-02-03.
  17. ^"Xen wiki". Retrieved2017-03-15.
  18. ^Damian Conway (2005).Perl Best Practices. O'Reilly Media Inc. p. 44.ISBN 978-0-596-00173-5.
  19. ^"Quick Guide to Some Sources for Naming Conventions for Oracle Database Development".stevenfeuersteinonplsql.blogspot.com. Retrieved2020-12-30.
  20. ^Michael A. Covington; Roberto Bagnara; Richard A. O'Keefe; Jan Wielemaker; Simon Price (2009). "Coding Guidelines for Prolog (v.3)". p. 14.arXiv:0911.2899 [cs.PL].
  21. ^IBM (July 1965).IBM Operating System/360 PL/I: Language Specifications(PDF). p. 16. RetrievedNovember 12, 2023.
  22. ^Wickham, Hadley.The tidyverse style guide.
  23. ^"Ruby Naming Conventions".GitHub. May 2020.
  24. ^"Naming – Rust API Guidelines". Archived fromthe original on 2018-09-16. Retrieved2019-10-27.
  25. ^"Terraform Naming Conventions". Feb 2022.
  26. ^"Documentation - The Zig Programming Language". Retrieved2024-03-10.

External links

[edit]
Page
Paragraph
Character
Typeface anatomy
Capitalization
Visual distinction
Horizontal aspects
Vertical aspects
Typeface
classifications
Roman type
Blackletter type
Gaelic type
Specialist
Punctuation (List)
Typesetting
Typographic units
Digital typography
Typography in other
writing systems
Related articles
Related template
Retrieved from "https://en.wikipedia.org/w/index.php?title=Snake_case&oldid=1322856701"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp