Live data from Hacker News

Underscores are stupid

devblog.avdi.org

111–120 of 131 posts

Re: Underscores are stupid

#111
post #65

Earlier quoted context omitted.

He's discussing this in the context of writing code, not typography. I think it's fair to assume we're starting with the premise that we would only choose characters that are easily typed on common keyboards. Choosing uncommon characters in programming languages, such as en-dashes and em-dashes, is choosing to deliberately make our lives more difficult [1]. I think it's pretty clear from the article that his comments…

Well, the author himself is pretty ambiguous. While most of the article talks about code, the author mentions underscores being ambiguous in the context of underlined fonts. (I don't even think my text editor [for code] supports underlined fonts.) He also mentions only using shift once or twice per sentence when writing prose. So it would seem that the author is just hating on _ in all contexts. Which is kind of sill…

I don't even think my text editor [for code] supports underlined fonts.

Well, mine does, and I used to have a co-worker who actually used it for coding. So there you go. :-)

Re: Underscores are stupid

#112
post #96

Earlier quoted context omitted.

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.

No. "normal people" call them hyphens. I think it is a mainly USian curiosity to call hyphens dashes. The Rest of the World calls hyphens, well, hyphens. It's only the US that call them dashes. I've no idea why that is.

people outside the US call them dashes as well, though perhaps not with the same frequency. ... --- ... is not 'dot dot dot hyphen hyphen hyphen dot dot dot', for example

Re: Underscores are stupid

#113

Earlier quoted context omitted.

C is full of implicit type conversions. I think the key is that C is based on value semantics and not references, and that makes pointers full-blown values with their own address, conversions, … - something closer to C's integer types than to other languages' references, and equally picky about operators.

The C type conversions I know of seem quite trivial. Can you give an example of something non-trivial? And I don't mean something like the float f = some_integer / some_other_integer trap, those should be obvious.

The automatic dereferencing in "pointerToStruct.foo" might have to loop until it arrives at a struct. I think such a loop would be unique in C, but I don't feel it'd make C any higher level.

Similar in concept: &function and function are the same. If you have a fixed-size array: ary, &ary and ary[0] are the same when passing them into a function.

Then there are all the other numeric conversions, where "unsigned" is a common trap, and truthiness.

Even if most conversions are trivial, I wouldn't call C a very explicit language. Compared to what?

Re: Underscores are stupid

#114

Earlier quoted context omitted.

The C type conversions I know of seem quite trivial. Can you give an example of something non-trivial? And I don't mean something like the float f = some_integer / some_other_integer trap, those should be obvious.

The automatic dereferencing in "pointerToStruct.foo" might have to loop until it arrives at a struct. I think such a loop would be unique in C, but I don't feel it'd make C any higher level. Similar in concept: &function and function are the same. If you have a fixed-size array: ary, &ary and ary[0] are the same when passing them into a function. Then there are all the other numeric conversions, where "unsigned" is a…

pointerToStruct.foo would just be equivalent to pointerToStruct->foo. No loop required.

The main problem with this is that it hides memory accesses. The offset of x.y.z.w relative to &x can be determined at compile time, so if &x is available, accessing x.y.z.w requires roughly only one load instruction. (DISCLAIMER: ABI- and compiler-dependent. One instruction is an estimate. This estimate may not be precisely true for all possible programs across all CPUs and compilers.) But x->y->z->w requires 3 pointer dereferences, even if you have x to hand. 3 load instructions and therefore 3 memory accesses. (The same disclaimer applies.) People already complain enough about the inefficiency of C++ operator overloading, and the difficulty of spotting when it occurs just by examination of the source code...

Additionally, this change wouldn't play nicely with C++ operator overloading.

I just set up my text editors to insert -> when I press .

Re: Underscores are stupid

#115

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 thin…

It's like the difference between wearing silk underwear and hessian underwear. Or being able to code while listening to an audio book vs needing peace and quiet. It's not a question of thinking less, or thinking more, or being more careful. Some people can put up with this stuff, and some people can't.

Re: Underscores are stupid

#116
> That’s a trade-off I’ll gladly make if it means using dashed identifiers instead of underscores.

Not me. I would gladly trade off having to expand all my equations for having to type underscores a few times. In fact, this is very subjective - and one could argue having to sacrifice compactness of expressions is stupid.

Re: Underscores are stupid

#118
post #85
post #68

Earlier quoted context omitted.

I don't think this has anything to do with infix versus prefix. It works in Lisp because the reader knows (roughly speaking) that symbols are terminated by whitespace or parentheses. If you wrote a version of Ruby that was still infix but where you needed to put spaces around all symbols, then "foo-bar" would work fine there, too.

Such rules ("all operators must be space-hugged") are special cases, and I think raganwald's point is that such special cases make at-a-glance mental parsing more difficult. Lexing and parsing in Lisp is much more straightforward than in, say, Python. Hence, mental lexing and parsing has fewer barriers. This is a direct result of using s-expressions, which implies no in-fix operators.

It is a special case in other languages, in lisp it is one of a very few highly consistent rules

Re: Underscores are stupid

#120
post #10

Writing almost exclusively in a underscore-encouraging language like Python has numbed me to these issues.

With me as well, though it is getting slightly annoying to the people I work with that it's been transferring over into some of the PHP code I have to write.

It's not as if underscores aren't used liberally in the standard library. Which is probably a hangover from C.
Post reply on HN