strager.net

Naming conventions

Capitalization and word separation
Language and dialect Functions Types Fields Constants Modules Other Notes
C++ Standard library lower_snake (ex) lower_snake (ex) lower_snake (ex) lower_snake (ex) lowercase UpperCamel (named requirements) (ex)
Google UpperCamel (ref) UpperCamel (ref) lowercase, lower_snake (ref) kUpperCamel (ref) lower_snake (ref) Url, Html
Haskell lowerCamel UpperCamel lowerCamel UpperCamel (data constructors) UpperCamel Case of the initial character is enforced.
lowerCamel (nullary functions)
JavaScript lowerCamel UpperCamel lowerCamel CAPITAL_SNAKE
Python PEP8 lower_snake (ref) UpperCamel (ref) lower_snake (ref) CAPITAL_SNAKE (ref) lower_snake (ref) URL, HTML (ref)
Legacy
Rust lower_snake UpperCamel lower_snake
Common container functions
Language Container Container emptiness test Add item to container Notes
C++ std::vector c.empty() c.push_back(x), c.emplace_back(x)
std::unordered_map c.emplace(k, v), c.insert({k, v})
Generic algorithms using iterators std::empty(c)
Haskell Prelude.Foldable null c
[] (list) c:x Prelude.null used to be specific to lists, and each type such as Data.Map.Map had its own function also called null. Now, Prelude.null is usable with any Prelude.Foldable.
Data.Map Data.Map.insert k v c
JavaScript Array c.length == 0 c.push(x)
Map c.size == 0 c.set(k, v)
Object Object.keys(c).length == 0 c[k] = v
String primitive c, c.length == 0 c + x In a boolean context, empty strings are falsy, and non-empty strings are truthy.
Python list c, len(c) == 0 c.append(x) In a boolean context, empty containers are falsy, and non-empty containers are truthy.
str c + x
dict c[k] = v
set c.add(x)