
The various tokens in your code (variables, classes, functions, namespaces, etc.) can be named using one of these three styles, broadly speaking:
...
For further actions, you may consider blocking this person and/or reporting abuse
nim-lang.org is "Style Agnostic", AKA Style Insensitivity,
you can use Snake Case or Camel Case the way you like it.
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 offirstName
, orFirstName
and you'll always be fine.Yep, even in php, function names are case insensitive. A call to
someFunc()
orSomeFunc()
or evensomefunc()
all go to the same function.I see some devs prefer
firstName
overfirst_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'm from Java/Dart background, I also had a similar question for python.
I was thinking why we should type 1 more "_", of course this will take very short time for 1 variable or 1 method, but we will have many of them in a program.
I don't mean underscore is bad, it depends on what you prefer!
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 ofto_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.
My bad, you are correct!
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.
Lets not forget the highly authoritative MACRO_CASE!
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.
A great overview of naming conventions across various programming languages! Understanding the difference between camelCase, PascalCase, snake_case (you call it underscore case), and kebab-case is essential for maintaining clean, consistent code. It's important to follow the conventions used by your team or community, especially in large projects.
The article also highlights how some languages, like Python and Ruby, lean toward snake_case, while others, like JavaScript and Java, favor camelCase for variables and PascalCase for classes. Be sure to adapt to the conventions most commonly used in your language or framework for better readability and maintainability.
For switching between these cases quickly, check out our converters for camel case, pascal case, snake case, and kebab case.
$howaboutnotusingany = "nice?";