Live data from Hacker News

Underscores are stupid

devblog.avdi.org

91–100 of 131 posts

Re: Underscores are stupid

#91
post #67

There's an easy fix for part of the problem: bind shift-space to underscore. Yes, you still require shift, but IMO it's the stretch not the shift that makes typing an underscore jarring. xmodmap -e 'keycode 65 = space underscore'

"the stretch"? Properly typing an underscore should utilize two hands and shouldn't require a stretch at all.

It moves your pinky, your smallest and least mobile finger, to move up two rows, which requires a typical person to completely flatten that finger. Either that, or you end shifting your whole hand. Which means that you end up moving your hand a lot while typing because the underscore may easily be the most common keyboard character encountered in some programs.

Re: Underscores are stupid

#92
I've got a feeling that HN crowd is lately loosing it's focus by spending it's time on "hipster" topics too much.

Page long commenting on a fluffy article ( e.g "5 * 5 - 3" beats "5*5-3" ) may be good for your mind but imho, this thing should not be on the front page.

Re: Underscores are stupid

#93
Underscores are silly! We only use them in code to separate words in tokens because the default natural word separator, whitespace, is already used to distinguish tokens.

At my old job, we had DSL that allowed and encouraged very descriptive variable and procedure names with space in them. To implement this unambiguously the language had to exclude all the operator characters from variable names and procedure calls with a sigil. A line of code may have appeared like this:

line slope estimate = @some function( x - step size ) / ( x - step size);

Feels a bit strange at first but quickly becomes natural, especially when dealing with wordy domains (math was a bad example).

Re: Underscores are stupid

#94

Earlier quoted context omitted.

Unless you use Emacs (as the author seems to), in which case you have S-Space bound to starting/ending selection. But in general yes, one can rebind underscore to something that doesn't require pressing Shift.

That's C-SPC.

Yeah, you're right. I wrote without checking, I have this command in muscle memory.

:).

Re: Underscores are stupid

#95

This misses one point when comparing Lisp to languages like Ruby. Lisp does not have infix notation. Therefore, you never have to worry that "foo-bar" (the symbol) could ever be confused with "foo - bar” the operation subtracting bar from foo. That’s because in Lisp, foo-bar is written "(- foo bar).” Since a Lisp programmer spends all his time writing "(- foo bar),” when he sees “foo-bar,” his brain easily parses it…

I'd add that it also works because nobody ever says "foo-bar". What "foo" and "bar" actually are, plus context, lets the (human) reader know what's going on.

Even if I don't know what programming language you're talking about, if I see x2-x1 or margin-75 I know you probably mean subtraction, and if I see last-name or message-id you probably mean a single identifier. I've seen plenty of Lisp code that says things like x2-x1 in docstrings (because it is shorter) and I've never found it to be confusing.

Re: Underscores are stupid

#96
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.

That's actually not very interesting. He was talking about hyphens, but calling them dashes, because normal people do that unless they are talking about typography.

Re: Underscores are stupid

#98

This may solve your problem: my.long.name = 1 a.short.name = 2 one.long.result = a.short.name - my.long.name one.string:trim:upper Use dots for identifiers and colons for class props and methods. Now we just need to design a whole new language :(

At least on a US keyboard, colons require the shift key, too.

Re: Underscores are stupid

#99
post #52

Earlier quoted context omitted.

I like the arrow since it reminds me sometimes that I'm working with a pointer and not an object on the stack

Pointers aren't always to objects on the heap, they can be pointing to locations on the stack as well.

Right, but I don't know what you're disagreeing with since I never said that they only point to the heap.

Re: Underscores are stupid

#100
post #17

I use case instead of underscore. Doesn't help the shift-issue, but reduces the length of identifiers e.g. file_not_found becomes FileNotFound.

IThinkItIsObjectivelyMuchLessReadable I_think_it_is_objectively_much_more_readable The difference in length is pretty small anyway.

You get used to anything. For instance, I find your 1st example much more readable, but I've been doing it for years.

Names tend to be pretty small anyway. Here are some random ones from the code I'm working on (Sococo Teamspace)

CreateVariant - a method

soLogWriteInfo - a method (I didn't write)

clHeadSSt - a circular list head for a stream

Post reply on HN