News for hackers. Stuff that matters.
Re:Book Review: The Programmer's Brain by edent on Sunday April 03, 2022 @09:11AM (#30896624)
Yes! I found that really interesting. It bemuses me that studies show $VariableName is more readable than $variable_name!
Re:Book Review: The Programmer's Brain by NateEag on Sunday April 03, 2022 @09:22AM (#30896702)
There is at least one study that supports snake case being more readable:

http://ieeexplore.ieee.org/xpl/articleDetails.jsp?reload=tru...

Re:Book Review: The Programmer's Brain by _dain_ on Sunday April 03, 2022 @02:51PM (#30899561)
>One main difference is that subjects were trained mainly in the underscore style and were all programmers.

so in this study, where the subjects were trained in snake_case, they found snake_case was better.

and in the other study, where the subjects were trained in camelCase, they found camelCase was better.

I bet if we did another study of programmers who used kebab-case they'd find that kebab-case is better.

I don't think there's any reason to believe any particular case style is better than any other. personally I like snake_case and kebab-case because I find the word boundaries easier to recognize, but that's just a preference on my part. I have no idea if it's objectively better.

Re:Book Review: The Programmer's Brain by NateEag on Sunday April 03, 2022 @10:06PM (#30902699)
Yeah, none of the study results I've seen have been strong. I don't trust them all that much.

I prefer snake_case and believe it probably is mildly more readable than camelCase.

The underscore comes closer to space-delimited words like we use in English, typographically speaking. It's hard for me not to think that must be easier to read that way.

Obviously I can't prove it's better, but it both makes sense to me that it would be and fits with my subjective experience.

Re:Book Review: The Programmer's Brain by jpcfl on Sunday April 03, 2022 @10:13AM (#30897062)
Studies show CamelCase is easier to type, which is what the book references. But, studies also show that snake_case is easier to read.

Code will be read more than it will be written, so it should be optimized for the reader.

Re:Book Review: The Programmer's Brain by drakmaniso on Sunday April 03, 2022 @11:15AM (#30897530)
It's more complicated than that. The study referenced in the book found that snake_case makes variables easier to read, but the whole program harder to parse (my guess is it's because of the visual similarity between the underscore and a space). With camelCase, it's the other way around.

I vote for kebab-case, but I didn't find any study where it was included...

Re:Book Review: The Programmer's Brain by edent on Sunday April 03, 2022 @10:27AM (#30897178)
The study referenced - https://ieeexplore.ieee.org/abstract/document/5090039 - says that coders and non-coders find CamelCase easier to read.

But I'm eager to find counter examples.

Re:Book Review: The Programmer's Brain by gls2ro on Sunday April 03, 2022 @12:13PM (#30897992)
I cannot access the study, but I find it odd that they say in abstract:

> Results indicate that camel casing leads to higher accuracy among all subjects regardless of training, and those trained in camel casing are able to recognize identifiers in the camel case style faster than identifiers in the underscore style.

What does it mean:

> those trained in camel casing are able to recognize identifiers in the camel case style faster than identifiers in the underscore style.

It is not normal if you train in reading something => you are good in recognizing that things that you are trained than something else than you did not train for?

If anyone has access to the study, how many among 135 are programmers that were trained in camel case and how many in snake case?

Re:Book Review: The Programmer's Brain by _dain_ on Sunday April 03, 2022 @03:06PM (#30899677)
is it easier to type? I can give an objective reason why kebab-case may be easier to type: you don't have to press shift at any point.
Re:Book Review: The Programmer's Brain by jodrellblank on Sunday April 03, 2022 @07:01PM (#30901631)
The spacebar is huge and under both thumbs, because you use it a lot. - is far away under one fourth finger or pinky, it's bad to type. Shifted letters are common.

Seems like it should be shift+space inserts a variable-split-token and different editors can display it as a - _ or caps of the next character as desired. Like tab characters being configurable as a number of spaces.

Re:Book Review: The Programmer's Brain by _dain_ on Sunday April 03, 2022 @08:01PM (#30902040)
or just use Nim which is style-insensitive: case except for the first letter is ignored, as are underscores.