• You are not logged in.
  • Index
  • General
  • Programmer: reserve one key for each language

    Programmer: reserve one key for each language

    • Started by Julien__
    • 14 Replies:
    Poll
    yes
    50% (1)
    no
    50% (1)
    Voters: 3
    • Reputation: 1
    • Registered: 09-Jan-2017
    • Posts: 8

    I've always been annoyed by the fact that some programming languages make a heavy use of one symbol that's not particularly easy to reach.
    For instance:
    - there are a lot of ; in Java
    - but none in Scala, while Scala use a lot more : for type annotations
    - likewise php and other languages make heavy use of $
    - I don't really know about other languages but OCaml seems to use a lot of !, etc.

    So I came up with this idea: what if we had one key that's easy to reach, and whose output would change depending on the language we use?
    It could be mapped to : while typing proper english and scala, ; while typing java, also ; or & in C and C++, $ in php, etc.

    Would that be worth it in your opinion?

    Offline
    • 0
    • Reputation: 11
    • Registered: 06-Jun-2013
    • Posts: 551

    sounds like a job for emacslisp

    (i can't do those sort of jobs)

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,345

    Would it be worth it? Generally speaking, no. Your typing flow won't – shouldn't at least! – hinge on one or a few symbols no matter what. In my opinion, one should learn to keep a relatively good flow even when typing complex text with symbols. That's part skill, part mindset I believe.

    If you switch languages, you'll have to switch the meaning of your key accordingly. I guess that'd lead to confusion and take at least as much mental focus as the annoyance over a relatively frequent symbol in a less-than-optimal position?

    One should not use the standard locale (non-US/UK) layouts when coding, in my opinion. On the Norwegian layout for instance, ^`~ are only accessible on dead keys which is a right pain. My Universal Symbol locale layouts all have the expected symbols in the expected positions if you're used to the US layout. And that's pretty much a standard when thinking coding symbols.

    If using a ligature/macro compatible mapping system, one might consider making a few boilerplate macros instead, in easily reachable locations. {Semicolon, Enter} is a simple one.

    Last edited by DreymaR (10-Jan-2017 13:42:58)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 11
    • Registered: 06-Jun-2013
    • Posts: 551

    you do get programmer layouts of course, but thats simply a switching of the number row, i.e. symbols by default, no.s if you hold the shift..

    that might help?

    : and ; are pretty easy by default, qwerty or colemak

    @ is easy if your british, but it shouldn't really be there

    i'm british, but my @ is up above the 2, US style

    even thats not too difficult as you hit it so often for email addresses you grow accustomed

    likewise, if you're prone to hyperbole, you should find the ! isn't too much of a struggle either..

    there is the tangential observation that with coding, type speed is immaterial, as the thinking bit will dwarf it

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,345
    bph said:

    i'm british, but my @ is up above the 2, US style

    You lucky bastard. The Norwegian layout has it on AltGr+2. The travesty.

    Indeed, most of your coding speed will not stem from typing flow alone, as it's a lot of on-and-off typing and editing. In my opinion, Extend (or something similar) is your friend there.

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 117
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 976
    DreymaR said:
    bph said:

    i'm british, but my @ is up above the 2, US style

    You lucky bastard. The Norwegian layout has it on AltGr+2. The travesty.

    Surely AltGr is easier to use than Shift. Therefore I'd say AltGr+2 is easier to type than Shift+2.

    All the more reason for defining common programming characters in a custom AltGr layer, instead of using awkward (shifted) default keys.

    Last edited by stevep99 (10-Jan-2017 14:18:05)

    Using Colemak-DH with Seniply.

    Offline
    • 0
    • Reputation: 11
    • Registered: 06-Jun-2013
    • Posts: 551

    when I say my @ is above the 2, I only mean in terms of what happens when I press it... the keycap is printed " in the british style

    but large portions of whats printed on my keyboard keycaps bear little resemblance to what happens when you press them..

    shift is far easier for me, but thats probably because I have simply pressed them many millions of times more the alt gr

    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,345

    OK, AltGr is easy to hit – especially with the Wide mod. But I've been in situations where AltGr doesn't work due to short-sighted coding of web windows. Then it's no fun. ;-)

    Last edited by DreymaR (10-Jan-2017 15:06:21)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 117
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 976
    DreymaR said:

    OK, AltGr is easy to hit – especially with the Wide mod. But I've been in situations where AltGr doesn't work due to short-sighted coding of web windows. Then it's no fun. ;-)

    Typing anything longer than a couple of sentences into in web window is a setting up for a fail anyway. How many times have you typed something into a web form, pressed "save" or "send" or whatever, only for the session to have timed out, or there to be a server error. That has even happened to me on this forum!

    If it's a long text, better instead to type it in a text editor, and then just paste it into the form when ready.

    Last edited by stevep99 (10-Jan-2017 15:48:09)

    Using Colemak-DH with Seniply.

    Offline
    • 0
    • Reputation: 1
    • Registered: 09-Jan-2017
    • Posts: 8

    Well I agree that most symbol should be reached with ease without interrupting the flow...

    But if you're programming in low-level C, you basically type `*` before each identifier (e.g. `*ptr`), sometimes twice. That's something like 3 times per line...
    Likewise in PHP but with `$` instead of `*`.

    A symbol that is typed that often should be easy to reach in my opinion... Even without talking about shifts, some keys are easier to reach; for instance qwerty 8 is easier to reach than qwerty 6 because it's accessed with the longer middle finger.



    All this made me think about a way to inscribe the idea in a larger context: What if we had a key per programming entity instead of symbol?
    - For instance, in C++, template arguments are between `<` and `>`, likewise in Java for generics: `<` and `>`. But in Scala generics are between `[` and `]`
    - Function calls are made in list, c++, java, scala with `(` and `)` but `[` and `]` in objective-c
    - Some languages start their strings with `"`, others with `'`
    - What about comments? `//`, `"`, `;;`, `#`, `--`... Those are all comment delimiters in different languages !
    So what about a "function call" key that would behave as `(` or `[` when appropriate ?
    Likewise, we could have "block start", "generic argument", "string delimiter", etc.

    Last edited by Julien__ (10-Jan-2017 16:07:19)
    Offline
    • 0
    • Reputation: 11
    • Registered: 06-Jun-2013
    • Posts: 551

    i'm not sure what text editor you use, but if emacs then take a look at yasnippet

    emacs has automatic commenting built in based on the file mode, bound to M-;

    Last edited by bph (10-Jan-2017 16:50:58)
    Offline
    • 0
    • Reputation: 117
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 976
    Julien__ said:

    A symbol that is typed that often should be easy to reach in my opinion...
    ...
    So what about a "function call" key that would behave as `(` or `[` when appropriate ?
    Likewise, we could have "block start", "generic argument", "string delimiter", etc.

    I think you are overcomplicating it. AltGr layers are perfect for what you are talking about. For example, in my layout, AltGr-T produces a bracket, AltGr-R produces equals sign, AltGr-A produces underscore. They are all common programming characters and they are easier for me to type than many letters. AltGr plus a left-hand home-key is about as easy as can be.

    Using Colemak-DH with Seniply.

    Offline
    • 0
    • Reputation: 1
    • Registered: 09-Jan-2017
    • Posts: 8

    I agree that Alt-Gr is very useful. Being french, I'm already using it for: àôéîèèâɛêäöëï (to be typed by the left hand, same as Dvorak's voyels).

    Regarding symbols to be typed by the right hand, I'd need a home key to be reachable by the left thumb and I don't have any (osx). I thought about remapping caps-lock to alt, but that might be heavy on the left pinky as I'm already using caps lock for `esc` in vim/evil.

    Something else that I have in mind is to map numbers under the right-hand while holding capslock. I really hate writing numbers (such as "0961") using the upper row and thought that have a kind of numeric pad right under my right-hand might be easier on the fingers.

    Last edited by Julien__ (10-Jan-2017 18:02:20)
    Offline
    • 0
    • Reputation: 1
    • Registered: 09-Jan-2017
    • Posts: 8

    (edit):

    something similar to this: (using a slightly modified Dvorak where D/G and U/I are swapped)
    mini_577412Capturedecran20170110a180710.png


    But I use CAPSLOCK a lot, so this would be a sacrifice.

    Last edited by Julien__ (10-Jan-2017 18:11:48)
    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,345

    Have a look at my Extend layers (in my signature topics). I've made a NumPad layer but I don't think it's implemented for Mac as opposed to Extend1. I'm in the process of testing it out on protracted number entry sessions these days, and so far I like it well enough although it takes a little getting used to.

    I've learnt some things, for instance:
    • There should be two 0 keys like the broad one on a NumPad. This makes it easier to enter for instance '10' or '00' which are frequent.
    • I need an accessible colon key for time entries (10:00, 09:30 etc – for my list of work hours!).
    • A nav/edit block is very useful and although it's a bit confusing to move it to the left hand it's still nice

        DreymaR's Extend2 layer:
     * ,----.    ,-------------------. ,-------------------. ,-------------------.
     * |    |    |MPau|MRwd|MFFd|Ejct| |WRef|BriD|BriU|Slep| |www |Mail|App3|App4|
     * `----'    `-------------------' `-------------------' `-------------------'
     * ,-------------------------------------------------------------------------.
     * |    | !  | @  | #  | $  | %  | ^  | P7 | P8 | P9 | P* | P- | =  |        |
     * |-------------------------------------------------------------------------|
     * |      |Home| Up |End |Del |Esc |PgUp| P4 | P5 | P6 | P+ | (  | )  |      |
     * |-------------------------------------------------------------------------|
     * |*Ext2* |Left|Down|Rght|BSpc|NLck|PgDn| P1 | P2 | P3 |PEnt| '  | ,  |     |
     * |-------------------------------------------------------------------------|
     * |     |    | ^Z | ^X | ^C | ^V |Btn1| :  | P0 | P0 | P. | P/ |            |
     * |-------------------------------------------------------------------------|
     * |      |     |     |                             |Ext2 |     |     |      |
     * `-------------------------------------------------------------------------' 
    Last edited by DreymaR (11-Jan-2017 10:50:16)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
      • Index
      • General
      • Programmer: reserve one key for each language