Best Keyboard Layout For Coding

0 views
Skip to first unread message

Orencio Suhag

unread,
Aug 4, 2024, 8:13:21 PM8/4/24
to ciatrimesol
Ioften hear complaints that programming languages that make heavy use of symbols for brevity, most notably C and C++ (I'm not going to touch APL), are difficult to type because they require frequent use of the shift key. A year or two ago, I got tired of it myself, downloaded Microsoft's Keyboard Layout Creator, made a few changes to my layout, and have not once looked back. The speed difference is astounding; with these few simple changes I am able to type C++ code around 30% faster, depending of course on how hairy it is; best of all, my typing speed in ordinary running text is not compromised.

My questions are these: what alternate keyboard layouts have existed for programming, which have gained popularity, are any of them still in modern use, do you personally use any altered layout, and how can my layout be further optimised?


I suspect this last is probably going to be the most controversial, as it interferes the most with running text by requiring use of shift to type common contractions. This layout has significantly increased my typing speed in C++, C, Java, and Perl, and somewhat increased it in LISP and Python.


Some of the replacements you have suggested, e.g. the top row with the special characters doesn't make a ounce of difference as the outside finger on the other hand should be moving to shift at the same time.


Now manually or by writing a program Redefine your layout in the following way. Put most frequently used symbol in a central position closer to your strong hand. The second symbol goes to your weak hand in central position. The third symbol goes back to your strong hand...and so on. Then you gradually move from central position of the hands into more "distant" areas of the keyboard. When all keyboard is full then you continue the process of assigning keys but this time with Shift key pressed. The other difference would be that you do not rotate strong and weak hand for each symbol when the Shift is down. With shift key down first you would fill in central positions on the keyboard and then move to more distant positions.


But this is not based on any sound research, and I'd also love to see a layout optimized (Optimization including stuff like hand alteration etc, also ZXCV preservation, ...) with a sourcecode based corpus, because all these layouts seem to be optimized for prose only. For example, 'f' is a very common letter in C (if, for).


This is based on a 6-key-swap partial optimization taken from Carpalx with preservation of the usual Cut/Copy/Paste/Undo shortcuts and modified to give a better access to the usual programming characters.


Make a simple key logger, then count the number of times each key is pressed. Run it for a day or two, then save the output to a text file. Do this every once and a while. It doesn't matter what layout you are using, as you are just seeing which keys are being used the most.


If you want to make a good layout, you can't be afraid to go away from the norm. I'd suggest putting the top 11 keys along the home row, then the next top 11 keys as the top row (leave the 2 keys above the return key as the least used keys), then the 3rd top 11 keys as the bottom row. There should be 4 keys left over now. Take those and put them in the -= and ]\ slots. Congrats! You have now made a great keyboard layout for your purposes! =D


Overall, I think having a good text editor and knowing how to use it is better than trying to improve your typing speed. Being able to record and replay macros is sometimes a lifesaver, and a selection of shortcut-assigned code snippets can be handy because there's normally language-imposed limits on what can be turned into a library.


FWIW, I'm not claiming to be strong on all those. I've always been too biassed towards solving problems myself, and with too strong a tendency towards reinventing the wheel and grand architectural schemes.


Changing the keyboard layout is a bad idea since it would (perhaps) boost your typing speed on one keyboard, but severely damage your typing speed on other keyboards or on computers where you don't have your special keyboard layout. I've found that it is often better to adjust yourself to the defaults, that having to change them everywhere. (Personally, my fingers are heavily Emacs-biased, which causes lots of typing friction everywhere else.)


It seems like the whole world is fighting to know which keyboard layout is the best. Every country has its own adaptation with a few changes. However, there is one clear winner for developers, the US ANSI QWERTY layout.


It also made sense that the first computers adopted the layout of the typewriter, since it was known by people. Computers offered more options than the typewriter, and the layout evolved with time to become what we know today.


This is thanks to layers that we all use every day. We can long press a key to access accent, or change layer with keys around the space bar. This is designed to circumvent the limitations of small keyboards.


Using a smaller keyboard on smartphones made people realized that having a full size keyboard is not required. People can ditch the num pad to get an 80% or a tenkeyless (TKL). Removing the function row results in a 65% and removing the arrow keys a 60%.


I remember making mistakes and having to do some gymnastic with my fingers when I was using the Swiss layout. This is no longer the case, and I can confidently say that the QWERTY layout makes coding easier.


Again, using the US QWERTY layout will greatly help. The documentation I had to follow all used the standard US keyboard layout. In the rare instances I had to follow one I was able to solve my issue without any issue.


Quite often the mechanical keyboard community will perform group by. Manufacturer have tight schedule and a minimum order size. Keyboards enthusiasts are part of a niche but there are many creative people that will design a keyboard case or a keycap set. They will then share their design online and if enough people are interested (to meet manufacturer limits) will turn their designs into reality.


This process is quite long but every manufacturer produces at full capacity all the time and the group buy must fit in one of the available slot. This is why it can take up to 2 or 3 years before seeing your set.


In the mechanical keyboard community the most common layout is the ANSI, every group buy will offer ANSI options. The same cannot be said about the ISO or JIS layout. If enough people are interested they will offer an option but there are no guarantee.


This all changed when I changed job. I joined Proton which is a tech company with employee across the world. To ease logistics, they gave me a US QWERTY keyboard. Without this job I would probably never have used a US keyboard.


At first, I was a bit surprised; I was expecting a Swiss keyboard. The office manager offered me a Swiss keyboard but I declined since I have heard good things about the US keyboard and decided to give it a try before giving up.


Writing was quite easy, the alpha keys are very similar to the QWERTY layout. In about two day I was typing at my regular speed and only did some mistake while pressing the return key that was much smaller to the big one I was used to.


Coding was also easier but I had more muscle memories with those keys. I did quite a few mistakes at first and was frustrated. I even thought that the unmarked keys of the Swiss keyboard were a better solution.


With time I did less and less mistakes and I started to code even faster. All the key required to write code (at least in TypeScript / Javascript land) are very close and can be accessed with few modifiers.


I have to say that I was anticipating quite a painful switch but this was not the case at all. After a few days I was able to write at the same speed as before and after a couple of week I completely did the switch.


In my last blog post, I explored the benefits of switching from the QWERTY to Dvorak keyboard layout. The standard Dvorak layout works well for those who frequently type in English, but what about those who primarily type code? This is where the Programmer Dvorak layout shines.


The Programmer Dvorak keyboard layout is the most comfortable and efficient layout for programmers. While the traditional Dvorak layout inherits awkward symbol locations from QWERTY, Programmer Dvorak makes the symbol row more intuitive. The top row of the Programmer Dvorak keyboard layout (seen below) contains brackets and symbols with the numbers typed by holding the Shift key. This is because programmers type symbols much more frequently than numbers when programming. The numbers are also arranged so that odds are on the left and evens are on the right, as in the traditional Dvorak layout.


Like the Dvorak layout, Programmer Dvorak is designed to maximize alternating key presses. This makes typing certain combinations of symbols often used together very fluid. One such example is that of the left and right parenthesis, which you type with the left and right index fingers, respectively. Therefore, to get the most benefit out of the Programmer Dvorak layout, one should also learn and use touch typing. This will not only improve your effectiveness when using any layout but will also potentially save your fingers some pain down the road.


Roland Kaufmann invented Programmer Dvorak in the early 2000s. Kaufmann scanned thousands of lines of source code in languages such as C, Java, Lisp, and CSS, among others, to find the most commonly used constructs. In contrast to traditional Dvorak, the Programmer Dvorak layout stands out in that the symbols of those commonly used constructs are arranged along the top row. Kaufmann made that decision after gathering data from source code in the aforementioned languages. It was also informed by previous research conducted by August Dvorak (creator of the traditional Dvorak layout) on keyboard layout efficiency. The result is a keyboard layout designed specifically for programmers.


Programmer Dvorak is designed with the English language as the starting point. This is due to the fact that English is the lingua franca of programming. Consequently, this has resulted in the development of the vast majority of programming languages in English. Furthermore, there is some consensus for the standardization of code comments in English.

3a8082e126
Reply all
Reply to author
Forward
0 new messages