• You are not logged in.
  • Index
  • General
  • which position is better between ( ; ) and ( ' ) for a C++ user in CP?

    which position is better between ( ; ) and ( ' ) for a C++ user in CP?

    • Started by Aditya9106
    • 7 Replies:
    • Reputation: 1
    • Registered: 21-Jun-2022
    • Posts: 7

    Today, I am switching to Colemak DHk from QWERTY (60-70 wpm on monkey type) on an ANSI keyboard because my left hand hurts a lot after typing. Also, my left hand is much weaker than my right hand.

    As a C++ user, "Semicolon" ( ; ) is used most of the time in the code. Way more than "Quotation marks" ( ' ). So my question is, which position is better between these two positions (requires less effort and is faster to type)? Should I swap the position of these two as a C++ user in competitive programming? Because typing speed is one of the crucial factors in CP.

    Last edited by Aditya9106 (21-Jun-2022 16:14:05)
    Offline
    • 0
    • Reputation: 117
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 975

    Some thoughts:
    - there isn't a huge difference in quality between the two positions, so I don't think it'll make much difference either way.
    - even as a programmer, you probably write more text than you think, so I wouldn't base decisions too much on purely code factors.
    - if speed is crucial for stuff like CP, you might get additional benefit from looking at Extend, as it will eliminate need for far-off keys like Enter and Backspace.
    - even so, I'd suspect the bottleneck is going to be thinking rather than typing. Don't underestimate the benefit of comfort vs speed.

    Personally, I prefer to have apostrophe in the position directly above O, as it's better for the I-apostrophe bigram for words like I'm and I'll.

    Last edited by stevep99 (22-Jun-2022 14:00:29)

    Using Colemak-DH with Seniply.

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

    I'm not sure you're right about semicolon being used "way more". Have you got actual data on it? Because in some code corpora it looks different. Keep in mind that both single and double quotes are on one key, as is the case for colon and semicolon. Also note how much the hyphen/underscore key is used in coding! Its usage pretty much dwarfs both the quote and colon keys in the corpus I've looked at.

    https://dreymar.colemak.org/ergo-mods.html#symbols

    I agree with everything SteveP said. One thing I'd like to add is that aside of competitive whatever, my strong opinion is that navigation/editing matters a lot more than the typing layout when coding. So a good Extend layer or similar is absolutely crucial and way more important than the position of symbols.

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

    Offline
    • 1
    • Reputation: 1
    • Registered: 21-Jun-2022
    • Posts: 7

    @stevep99 and @DreymaR, thanks for replying.

    As far as I know, In C++,

    Apostrophe ( ' ) is used only for defining characters and comparing, inserting, and removing them from the string.

    Quotation marks ( " ) are only used to define and output a string (that's all).

    The semicolon ( ; ) is used at the end of every line and often after some words. Usage of ( ; ) let alone is higher than both ( ' ) and ( " ) combined in just 100 lines of code. What if the no. of lines is higher? What if strings and characters are not used in a particular problem/code? (and that's the case most of the time).

    Colon ( : ) is used for declaring iterators and outputting them and is also used in the Ternary operator. If we consider 100 problems, having 25 of the string and character-related. Colon will be used pretty much half of the total amount of ( ' ) and ( " ) combined in C++.

    I just looked at other languages' code, and It seems the above two statements are factual for other languages like C, C#, Java, Javascript, Python, PHP, etc.

    In short, usage of ( ; ) and ( : ) is way greater than usage of ( ' ) and ( " ) in coding.

    I wanted to ask that question because I will probably use Colemak DHk for the rest of my life. So why not make use of every small detail to improve my speed and comfort. I am already using DHk instead of DHm (even if it gives only a slight advantage). Also, using the Capslock and Left-Alt as the Backspace and Enter keys, respectively. 

    I will not swap ( ; ) and ( ' ) positions as both of you said ( ; ) (in DHk) is in a slightly better place, and it would be beneficial for me as a Programmer.

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

    Did you read my Sym mod topic? The McDickens corpus is text "including code" so it's not quite what you're asking for. But SteveP's corpus of the Linux source code should be good I think?

    It shows clearly what I'm trying to say: Every. Single. Programmer. Who. Pipes. Up. ... will fuss about the semicolon, while they might be better off seeing the hyphen-underscore problem and the larger picture. Indeed, semicolon/colon is more common than quote/doublequote in pure code (1.4% vs 0.4% in SteveP's corpus), but there is still a bigger picture to see there. The McDickens corpus including code has it the other way around, and it should represent a more useful example for most.

    Studying the Sym topic tables, you'll find that in pure code some letters are less frequent than punctuation keys. If you were really gung-ho about it you might consider demoting, say, the V key to the benefit of a punctuation key. I wouldn't do it myself, but I want to mention it.

    I personally find it much easier to use keys that mark boundaries, like the Enter key, even if they aren't placed directly in the home block (that said, I do put my own Enter on Extend+Space which is very convenient!). Punctuation that sits in the middle of the text flow, like commas and apostrophes, are much more crucial to the typing flow in my experience. I don't know how you actually treat a semicolon while you type.

    On a side note, people sometimes discuss which of the semicolon and quote positions is better. I think there's a fair amount of individual preference there, and neither is a bad position.

    It's perfectly fine for you to not swap the semicolon and quote keys like the full Sym mod does! But I'd still recommend that you consider the other half of the mod.

    Last edited by DreymaR (24-Jun-2022 10:24:49)

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

    Offline
    • 1
    • Reputation: 117
    • From: UK
    • Registered: 14-Apr-2014
    • Posts: 975

    On the broader topic of opimizing for progamming more generally, it's worth mentioning the value of a symbols layer.

    It's not just semicolon that gets used a lot (for the C, C++, Java guys anyway), there's also things like brackets, hyphen, underscore, etc. Most of these are in bad places by default. Putting these in a layer on easy-to-reach keys is highly worthwhile for progammers, and combined with extend, make code editing extremely efficient and elegant.

    Here's my current symbols layer for example:
    seniply_uk_matrix_symbols1.png

    Last edited by stevep99 (25-Jun-2022 10:32:53)

    Using Colemak-DH with Seniply.

    Offline
    • 1
    • Reputation: 1
    • Registered: 21-Jun-2022
    • Posts: 7

    I did not know about extend layer while writing this post. The extended layer will surely make things much easier as I can now use the symbol/number keys more efficiently. Also, I will no longer need to move my hands to type arrow keys.

    One other question that arrived in my mind after typing Colmake-DHk for quite a while is that the alphabet "C" is in a bad position which is used quite frequently and the alphabet "V" is comparably in a better position which occurs less frequently (from online sources). also, some other alphabets are not in the exact position according to their frequency.

    So, Is Colmake-DHk not a perfect layout either (must be close to perfect then)? Are the alphabets positioned in a way that the more number of words are typed comfortably and maybe faster regardless of their frequencies?

    Last edited by Aditya9106 (27-Jun-2022 14:30:05)
    Offline
    • 0
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    Yes, Extend layers are wonderful! Grats on joining the revolution.

    The main reason V is kept where it is, is compliance with the Ctrl+V shortcut. While the standard Colemak-DH does split up ZXC and V, the V is kept in its old QWERTY (non-Angled) position which is considered useful. Same with C which is kept for the Ctrl+C shortcut. If you want to forgo these design principles you can find somewhat different optimized layouts, which may suit your tastes. I haven't seen the point in trying out any of those yet.

    Some swap C and F and feel that it helps, but I don't believe much in it myself.

    Here's the newest layout creation from the AltKeyboardLayout server – Canary:
    https://github.com/DreymaR/BigBagKbdTri … uts/Canary

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

    Offline
    • 1
      • Index
      • General
      • which position is better between ( ; ) and ( ' ) for a C++ user in CP?