under_scores, camelCase and PascalCase - The three naming conventions every programmer should be aware of

Prahlad Yeri on July 10, 2019

The various tokens in your code (variables, classes, functions, namespaces, etc.) can be named using one of these three styles, broadly speaking: ... [Read Full]
markdown guide

nim-lang.org is "Style Agnostic", AKA Style Insensitivity,
you can use Snake Case or Camel Case the way you like it.

var someVar, somePackage = "Camel Case"
echo some_var, some_package

var other_var, other_package = "Snake Case"
echo otherVar, otherPackage

var `kebab-case` = "Kebab Case"
echo `kebab-case`

var `for` = "Stropping allows to use Keywords as names"
echo `for`

type Cat = object  
var cat = "variable cat is not overwritten by Cat object"
echo Cat, cat

# echo prints to terminal (this is a comment)

## No name shadowing or overwriting here
## (This is a DocString, can be Markdown, ReSTructuredText or plain-text)

Its also for interoperability with other programming languages that may use different style,
eg. if you code Python with PyQt, it breaks the style beyond repair because everything is CamelCase on PyQt and everything is snake_case on Python.

Heres an Interactive Demo on the Nim Playground (click on RUN).


Never use any of those.

One reason: In some RDBMS, column name is insensitive about those cases.

Use first_name instead of firstName , or FirstName and you'll always be fine.


Yep, even in php, function names are case insensitive. A call to someFunc() or SomeFunc() or even somefunc() all go to the same function.


I see some devs prefer firstName over first_name, which i see is a way to confusion if you use , for example PostgreSQL as column name.

I don't understand why they prefer that option. Maybe because it's "prettier" ?


I believe it widely known as Kebab Case (kebab-case) instead of Underscore.


No, kebab case is different. Its the dash or hyphenated case, so dashes are used instead of underscores (to-string instead of to_string). The only place where kebab case is used is perhaps css class names (main-div, navbar-div, etc.).

The popular name for underscore case is in fact, snake case.


/kebab case/ as you call it is defacto standard naming convention in all Lisp's, starting room Scheme, trough Common Lisp, up to Clojure. It is phenomenon older than C and still going strong with her and current implementations.


I don’t know the naming, but probably in Java constant value you’re naming in all camel case characters with underscore between words. Good to add this too if this is the official naming convention.


Thanks, I've updated the post with this point.


Yeah, great. Good to point it too. But I mean SOME_VAL not Some_Val. Never seen this approach

Yep, SOME_VAL is full underscores, not a variation of camel case chars, and its the more popular one. Some_Val is a mix of camel and underscores, its less popular and rarely used.


What you refer to as camelCase is sometimes called lowerCamelCase and what you call PascalCase is sometimes called UpperCamelCase. Also the underscore_style is sometimes called snake_case.


Lets not forget the highly authoritative MACRO_CASE!

code of conduct - report abuse