

Swap '_' with '-' to write code faster - ericrannaud
https://plus.google.com/106464412226321248435/posts/VrYLFL2PNxD

======
dkersten
Or use a language where '-' is allowed in identifiers. '-' looks better than
'_' anyway.

Personally, I decided a while ago that I spend such a disproportionate amount
of time writing code that its worth my while to customise my keyboard layout
to make writing code quicker and easier. I now use colemak with caps lock
mapped to control and left control mapped to backspace. I also mapped alt-gr
to hard to reach symbols (everything except those that are already on the main
keyboard), and since I can tap alt-gr with my right thumb real easy, I can now
type symbols like - = ( ) ! + * _ & @ ! 0 and others with ease (the listed
symbols are the easiest symbols for me because I have them mapped to my left
hand while my right hand presses alt-gr).

I spent ages debating with myself if its worth using a non-standard layout
that I won't have on other computers, but in the end I figured I do so much
coding on my own computer that if I had done this years ago (I used to think
its not worthwhile), I would have saved a lot of effort.

Some people say that thinking about code is the slow part, not typing, but the
way I see it is that the faster I can type code the more down-time I have for
the thinking, the faster I can experiment in a REPL and the faster I finish
mundane typing tasks where I don't need time to think.

I am now also planning on relearning my vi/vim commands to speed up my editing
even more as I have forgotten a lot of what I knew a few years ago when I used
vim a lot.

~~~
ericrannaud
> Or use a language where '-' is allowed in identifiers.

I have been a little obsessed with this question for a long time, and my
interest in the LISP family of languages was in part driven by the use of '-'.
This should have been a trivial consideration though. A keymap fix seems
rather more logical than a change of language.

I agree that being able to type code quickly and conveniently is important. We
only have so much time, while we have so much code to write.

~~~
dkersten
Well I didn't seriously mean that one should switch language to type faster,
just that the "problem" does not exist in languages that allow '-' in
identifiers and that I feel '-' also looks a lot more natural too. I
personally write a lot of C++ and Python code, neither of which allow '-' in
identifiers, but I often wish they did (and would happily give up the ability
to omit whitespace around operators) and while we're at it, why not allow + !
* and ? too.

Having said that, I'm all for switching languages (if your work allows it - I
totally understand that some people won't have that choice) if it speeds up
your development in some way.

------
makecheck
If you think about it most languages have sacrificed a lot simply to give
mathematical operators their "traditional" ASCII meanings. Had character
assignments been based on frequency of need or just convenience, you'd surely
have seen things like minus-signs in variable names more often.

I would love to see a UTF-8 or other Unicode keyboard so that it's very fast
to enter "real" symbols (partially programmable too). Why for instance does my
numeric keypad need _another_ "/" or an asterisk...it could now have "÷" and
"×" instead.

In the next few years, given more common Unicode support in keyboards and
companion programs (text editors and terminals already do a decent job), it
would be interesting to see a language evolve to require actual symbols for
known operators. Then you really would have to type "6 × 5 ÷ 3", not the ASCII
hack "6 * 5 / 3". It would also allow very interesting hyper-operators (as
seen in old environments such as the Mac's MPW Shell, and now Perl 6).
Wait...don't let Larry Wall see this or we'll have a "$≠" variable or
something in Perl 7. ;)

~~~
ericrannaud
Well, the problem is that I don't see how it would be possible to have a
keyboard like this that would be really fast to type with.

Even a visual keyboard, as on a tablet, that could arguably display any set of
symbols, would still not really be a solution. You can only show less than 100
keys at a time, and you would have to switch layouts all the time, e.g. to get
to that special 'alpha' or '!=' key.

I find full UTF-8 support in identifiers a regrettable idea because these
symbols are generally impossible to type quickly. This makes programming
languages less universal.

And I'm not even talking about symbols that look nearly identical but are
actually different Unicode characters.

The only solution that I would find acceptable, personally, is to display
certain identifiers or ASCII strings as fancy symbols. 'alpha', 'beta', '!=',
'ab / c' would be displayed using symbols, but the raw text file would contain
the ASCII name. When editing a symbol, the actual name would be typed in.

Or a syntax similar to Tex would be acceptable: '\alpha', '\dot',
'\frac{10}{100}'.

The display can be fancy, but the source file shouldn't be, IMO.

~~~
makecheck
If identifiers are displayed as symbols, that's really no different than
having keyboard support; in both cases you're hoping you can hit (ideally) one
key and have the keyboard do what you want. Keyboards already have modes like
the Shift key, it's just a matter of kicking the programmability up a notch.
And who knows, maybe keyboards grow slightly and gain a 2nd keypad (on the
left) with some new "common" keys.

Note that UTF-8 is quickly becoming the _new_ "raw text file". The encoding of
each symbol is very well defined and supported by programs already. It is
actually better to have that exact definition than an ASCII word that may or
may not be supported by all editors (and if it's not, as you said some symbols
look similar; which one is intended?).

I don't think keyboards will change much until some related tech becomes
cheaper, too. Two key ones I think are cheap mini-displays per key (so the
whole keyboard can display new glyphs if need be), and a companion touch-
screen for _drawing_ non-trivial glyphs that are needed only occasionally. Or
maybe they just give up on the idea of physical keys entirely and attach large
touch screens as "the whole keyboard" for a desktop machine.

~~~
ericrannaud
> Note that UTF-8 is quickly becoming the new "raw text file". The encoding of
> each symbol is very well defined and supported by programs already. It is
> actually better to have that exact definition than an ASCII word that may or
> may not be supported by all editors (and if it's not, as you said some
> symbols look similar; which one is intended?).

Not at all. You _see_ 'A' on your screen: is it uppercase Latin 'a' or is it
uppercase Greek alpha? Good luck, these are two distinct Unicode characters
(with different UTF-8 encoding, obviously), but most fonts will (rightly)
represent them identically.

How is your keyboard going to handle that? Your tablet keyboard? How do you
know which symbol to type in when editing code? It's completely unmaintainable
and unreadable.

In the scheme I described, if the word 'alpha' is not supported by the editor,
then it displays the string 'alpha'. That's of course not ambiguous. And a
good editor, in my scheme, would not display 'Alpha' as 'A' if it's well
thought of, it would just display 'Alpha', which is not ambiguous and clear.

If the source is UTF-8, on the other hand, should the editor display U+03B1 to
avoid the visual ambiguity of 'A'? Can you remember what Greek (or otherwise)
letter that is?

Finally, note that there are 12 Unicode characters for the Greek letter
alpha... See <http://en.wikipedia.org/wiki/Alpha#Computer_encoding>

So it's completely misguided to accept arbitrary Unicode characters in
identifiers. Because the only way to display such an identifier in an non-
ambiguous way is to display the binary encoding...

So, arguably, one could use a set of characters larger than ASCII for
programming. But the full Unicode range is not it, there is way too much crap
in there.

------
RandallBrown
how do you type minus then? Does this reverse the shift key?

~~~
ericrannaud
Yeah.

Press the key without modifier: get underscore '_'. Press the key with shift:
get '-'.

Return to default with: xmodmap -e 'keycode 20 = minus underscore minus
underscore'

(This is for a qwerty layout)

