> 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. Oh my, oh my, how do people ever cope with that vile "having to hit shift" that have regular capitalisation of all nouns etc. Surely such a thing is impossible, as is hitting shift when you need an underscore. I understand tha…
I wonder how the author types all the brackets in LISP without the shift key. I'll take an occasional underscore over that mess any day.
Underscores are stupid
81–90 of 131 posts
Re: Underscores are stupid
#82Re: Underscores are stupid
#83What colour do you want your bikeshed painted today? I for one, don't like the "->" operator in C. It requires two characters and the use of the shift key. I would like that the next standard just used "." for all member access and let the compiler work its magic and guess what needs to be done. Of course that would break a sizeable amount of legacy code, but who cares about that anyway. The important is that the cod…
I guess it'd break because of (a* +b) but that's just all the more reason to disallow whitespace around infix operators.
Re: Underscores are stupid
#84Re: Underscores are stupid
#85This 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 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.
Re: Underscores are stupid
#86I think they should make keyboards with the spacebar divided, and make the left half (or I guess the right if you're left-handed) into a shift key.
Japanese ThinkPad USB keyboard (with TrackPoint!): http://i.imgur.com/4dWVJ.jpg
Re: Underscores are stupid
#87There'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'
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.
Re: Underscores are stupid
#88What colour do you want your bikeshed painted today? I for one, don't like the "->" operator in C. It requires two characters and the use of the shift key. I would like that the next standard just used "." for all member access and let the compiler work its magic and guess what needs to be done. Of course that would break a sizeable amount of legacy code, but who cares about that anyway. The important is that the cod…
"let the compiler work its magic." if you want that, use a higher level language. One of the foundations of C is that there is as little implicit behavior as possible. I'd hate to be left in the dark whether my . will now result in a pointer or a dereferenced value and I doubt it would even work for the compiler to figure this out in all edge cases.
Re: Underscores are stupid
#891) The goal of a programming language is to be as unambiguous as possible. This is why we have syntax, and do not program in english. As soon as you use the same token identifier for two purposes, you introduce ambiguity.
Take markdown, for example:
* Hello *world*
In this line of code, which asterisk should be considered a bullet, and which an indication of emphasis? It seems obvious to a human, but codifying it in a set of rules for a computer is another matter, which introduces complexity and future bugs. (Eg., what do you do in this situation: `* Hello* world`. As somebody who is writing a full formal lexer for markdown, I can tell you first hand that it's an extremely annoying part of the specification.)Lisp does not have this problem, because it is governed by an extremely simple and effective set of rules:
- An identifier can contain most unambiguous special characters, including - ! ? / + = etc.
- There are no operators, only functions.
- A hyphen by itself is a perfectly valid identifier.
- The standard library includes a function named hyphen which performs a subtraction operation.
Taking that into consideration, it makes the entire situation completely ambiguous. `a-b` is one identifier. `a - b` and `- a b` are both a string of meaningless identifiers. `(a - b)` performs function `a` with arguments `-` and `b`, and `(- a b)` performs function `-` with `a` and `b`.
Ruby is actually interesting in that it is one of the few languages which, like lisp, does not have operators. You could remove ambiguity by doing `a.-(b)`. However, readability immediately goes out of the window. Much more so than in lisp's case. Consider this:
(4.*(5)).+((7.*(9))./(3)).+(1) #
It's semantically a perfectly valid expression, but how long did it take you to mentally evaluate it to 42? Compare with: 4*5 + 7*9/3 + 1
2) If you're going to be writing an article about it, please learn the right terminology. - is a hyphen. Dashes are – (en-dash) and — (em-dash). Hyphens separate contracted words. En-dashes indicate a range. Em-dashes indicate a aside, much like a parenthesis.Re: Underscores are stupid
#90Earlier 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…
Lot's of editors do. In Eclipse, for one, it's common to see function names and such shown as hyperlinks when you click on them (with underlines), which makes their definition open (like a function call is "linked" to the function definition).