Live data from Hacker News

Underscores are stupid

devblog.avdi.org

41–50 of 131 posts

Re: Underscores are stupid

#41
post #20

Interesting that he calles dashes "ordinary, easy-to-type, recognizable, [and] visually unambiguous." What he's referring to as a dash is actually a hyphen (-), which is pretty ambiguous when compared to the en dash (–) and em dash (—), both of which require modifier keys to type (and are frequently used in prose, to counter another of his claims). Fortunately, I've never seen em dashes or en dashes used in code.

Just to clarify your clarification, that symbol is HYPHEN-MINUS, U+002D. It is in the "Punctuation, Dash" category.

Re: Underscores are stupid

#42
Maybe it's just me, but I never notice issues like this. Some people want to completely optimize their experience, like when Vim users tell me it's better than Emacs because they don't have to reach for the cursor keys.

I dunno. For some reason this super-optimisation of keystrokes doesn't bother me. Avoiding reaching for the mouse is good, but I don't particularly care if I have to hit shift.* Maybe I prefer to think more and type less, or something. I can't quite say.

* Admittedly the French keyboard where all numbers in the top row are shifted, and symbols are unshifted, drives me kind of crazy, but that could just be due to hard in-grained training on an American keyboard layout.

Re: Underscores are stupid

#43
post #36

Earlier quoted context omitted.

Yes, but in this case it's not about readability, but about extremely significant whitespace. Forgetting a space and your code has a totally different meaning.

Whitespace is already extremely significant in programming. "foo[1]" vs "foo [1]" for example.

Depends on language, in Ruby those statements would be identical. But anyway, that's no reason to make things even worse.

Re: Underscores are stupid

#45
post #36

Earlier quoted context omitted.

Whitespace is already extremely significant in programming. "foo[1]" vs "foo [1]" for example.

Depends on language, in Ruby those statements would be identical. But anyway, that's no reason to make things even worse.

In Ruby those statements are the same when foo is bound to an array, but they are different when foo is bound to a function...

Re: Underscores are stupid

#46
Really just a matter of convention, and dash is too heavily associated with minus. A single underscore is a permissible variable name in some languages; in Go it has a special meaning (blank identifier). Would a single dash be as well? For example, how would you interpret

    i - -
	
Is it i (minus) (variable named dash)? And is `i--` a legitimate variable name? Maybe Ruby doesn't have this construct, but then it would have a completely different naming contention from existing languages.

Re: Underscores are stupid

#47
post #15

Earlier quoted context omitted.

and gets even worse if you bring variables into the game. a = 5 b = 3 everybody from nearly every programming language would expect that after c = a-b you will find c to be 2 not nil (or throwing an exception or whatever)

I've always found code without spaces around these symbols to be very undreadable.

And I have found the opposite. Horses for courses.

Re: Underscores are stupid

#49
"Underscores require me to hit the Shift key. When writing prose, I only hit the shift once or twice per sentence. In Ruby, I have to hit the shift key every few letters. Awkward. Inefficient."

There are languages that survive in spite of the heavy use of uppercase letters, without useless complains like this.

Let me repeat, in German:

"Es gibt Sprachen die trotz starker Nutzung von Grossbuchstaben ueberleben, ohne ueberfluessige Beschwerden wie diese."

Damn, I just broke my pinky..

Re: Underscores are stupid

#50
post #35

I've been thinking about trying to find a reasonable way to map the underscore to shift+space, but I'm not sure if that would somehow break some application that expects otherwise. It also seems to be quite difficult to achieve on Windows without registry hacks (I presume it would be easier on Linux, but haven't tried it yet).

It's very easy on Windows with the strange and wonderful AutoHotkey [1]. I recommend the more advanced AutoHotkey_L fork [2], but this script should work in either version.

Install AutoHotkey and then create a file called Underspace.ahk with this content:

    ; Underspace for AutoHotkey
    ; Converts Shift+Spacebar to underscore

    #SingleInstance force

    +Space:: Send _
Now launch that file.

Try Shift+Space and it should type an underscore for you.

If you want to stop the script later, find a green "H" in your system tray and right-click it.

After you try it, I'll be curious how it works out for you. Myself, after trying it for just a minute or two, I'm not so sure if I like it. I'm finding a lot of spurious underscores before capitalized words, or after a word like "I" that ends with a capital letter. That's because I've been sloppy about the timing of when I press the Shift key before or after a space.

So I won't be using this script myself (not that I need it - I don't like to code using names_with_underscores) but maybe others will find it useful.

[1] AutoHotkey home page: http://www.autohotkey.com/

[2] AutoHotkey_L: http://l.autohotkey.net/

(minor edit for clarity)

Post reply on HN