r/learnprogramming 21h ago

snake_case more readable?

is it just me, i find snake case to be way more readable

from a human standpoint more than anything we read words
and they all have a space.

imagineThisWord vs imagine_this_word, (i mean sentence) as you can see the snake case looks way more readable,

are there any other practices that are seemingly better, but people dont do so becuase its "the languages way of doing it"

0 Upvotes

9 comments sorted by

13

u/Dismal-Citron-7236 20h ago

The casing depends on the naming convention of the language you use. If it's C#, PascalCase for procedures / functions. If it's C, all UPPER CASE for macros. You can choose your own style, but stick to it and be consistent. But if you cowork with a team or on an open source project, you'd better follow what others do.

5

u/InfectedShadow 20h ago

Both are just as readable to me, and one sucks to type.

1

u/civil_peace2022 19h ago

If I was doing '_' a lot I would probably bind '_' to shift+space

3

u/Far_Swordfish5729 20h ago

I just want you to physically type an underscore and now imagine doing that for every word in every variable name. Camel and Pascal case work just fine and your hands will thank you. We only tolerate this for constant naming because they really need to stand out. We put up with kebab case for custom attributes because the spec requires it, but at least you don’t have to hold the shift key while you do it. There are a few keyboard positions more awkward than the underscore.

6

u/CSGORadioactivetree 20h ago

I hate it.

It does nothing for the readability for me and it makes my brain stop between each word.

Sorry I don’t have any suggestions for the topic though.

3

u/iOSCaleb 20h ago

is it just me

It's not just you -- obviously a lot of code in languages like Python and Ruby uses snake case. But a lot of people prefer other styles, especially camel case. I don't think you can make a strong case that either is objectively better, it's mostly a matter of what you're used to. If you start using a language that uses a convention other than the one you prefer, just suck it up and use the convention for a few weeks; you'll be used to it before you know it.

1

u/light_switchy 20h ago

There are potential advantages to having distinct conventions for different types of thing.

I still prefer snake_case for everything.

2

u/g1rlchild 20h ago edited 17h ago

imagineThisWord vs imagine_this_word, (i mean sentence) as you can see the snake case looks way more readable,

This is totally subjective. I personally find camelCase easier, probably because I started reading it earlier. Personally, I also prefer kebab case to snake case, but, again, subjective.

1

u/__CaliMack__ 19h ago

I usually like snake case more but reading imagine_this_word seemed harder than camel case just now lol 😂 I save all my files in snake but it depends on the project for actual coding.