CamelCase? snake_case? Something else? And why?

  • @nromdotcom@lemmy.ml
    link
    fedilink
    83 years ago

    I like whatever the accepted standard is for the language I’m using at the time.

    So for python and ruby we’re talking snake_case variables and PascalCase classes, for javascript camelCase variables and PascalCase constructors, for go camelCase for unexported and PascalCase for exported.

    Don’t really see how one might have a personal favorite that they apply to all languages equally.

    • Dreeg Ocedam
      link
      fedilink
      43 years ago

      Yeah, the best is when a language already has a standard formatting and that is used by every library. Good examples are Go and Rust which have an “official” formatting tool that is developed. So you can just stick to it and not think about it.

      Consistency is the most important part, the rest matters a lot less.

    • Adda
      link
      fedilink
      13 years ago

      Exactly this. I have lacked this comment here and was surprised no one has mentioned it earlier. One might prefer one format over the other, whenever there is a standard though, one should immediately switch to it and stick with the standard for the given language. Not what the discussion asked for though, so that might be the reason.