Is QWERTY harming language design?

by Daniel Berger

One of the rather unique features of the Fortress1 programming language is that it has builtin support for Unicode operators. For example, instead of using "==" you would use U+2261. After reading the spec, and a recent thread on ruby-core, I've been wondering something . Are language designers too limited in their decisions about syntax because of the limitations of the QWERTY2 keyboard?


Geoffrey Grosenbach
2008-05-11 22:07:42
Good luck trying to get adoption!

Only a small percentage of developers use Dvorak, which works on a standard keyboard. A language that required the purchase of a separate keyboard would be laughed out of the room.

Although, I'm typing this on an iPhone which creates a keyboard in software. An iPhone app could be a possible place to experiment with such a concept.

Bob Warwick
2008-05-11 23:27:51
Once you get past the lexical analysis stage of compilation, it doesn't really matter what syntax you initially used to denote a given token. I certainly don't see how grammars and parsers would be influenced by a larger range of input characters.

As an example let's say that I have two languages, call them A and B. In language A I write a simple equality comparison like this: x == y

In B I write the same comparison using something like: x U+2261 y

(Bear with me for a moment and assume that U+2261 is rendered as the unicode 'identical to' character, not as I've written it here)

In A my lexer would probably pass three tokens to the parser. I'm denoting these tokens by placing the type of token in all caps and the value of the token in round braces. These tokens are: SYMBOL(x) EQUALITYOP SYMBOL(y)

In B my lexer would pass the same three tokens. SYMBOL(x) EQUALITYOP SYMBOL(y)

The syntax difference isn't at all consequential to the language design. You could replace the '==' with '=' or 'equals' or '###' and your lexer would still be able to pass along the same set of tokens.

Having special purpose keyboards and maybe even character sets for programming might allow us to create code that's easier to read(1), faster to write(2), and easier to represent densely, but I don't see how it would impact language grammar.

1) One character keywords instead of multicharacter keywords. I doubt this would bring any great gains as the human eye reads words and phrases as individual units, not just sets of letters.

2) If you believe that the speed of your coding is limited to your typing speed, you're likely writing code that's repetitious.

Daren Thomas
2008-05-11 23:36:23
QWERTY? One thing language designers seem to forget, is that there are different keyboard layouts outside of america. Here in switzerland we have QWERTZ keyboards. Curly braces are a pain, since they involve the [ALT-GR] ([CTRL] + [ALT]) key.

So, keyboard layout (for me) was part of my reasoning to use python instead of ruby: Python can get by with virtually no punctuation at all. No pipes, seldom curly braces, square braces I can live with and colons are easy on my wrist. Compare to ruby and perl: special characters beserk mode!

I hear the lisp folks can live with simple parentheses?

Conclusion (sort of): The keyboard is not really the limiting factor, it is the way we think about programming languages (and programming). We don't really need more punctuation semantics overloading, we need simpler, more powerfull concepts.

Get rid of pipes and curly braces in programming languages! Stop using punctuation to indicate scope (ruby, I'm looking at you!) - local scope is what you should be aiming for anyway...

2008-05-12 00:07:45
After looking over the Fortress syntax examples I can definitely see how scientific and mathematical applications could be written more clearly with the use of symbols. The amount of information you can communicate would become denser, and at the same time potentially easier for domain experts to read. Some nice DSLs could come out of this.

I think what you need for this would be a keyboard with programmable keys, like the Optimus. The problem is that their cost is outrageous, but with Apple recently (as of Jan 2008) filing a patent for a programmable LED keyboard, they just might have the ability to push costs down due to their ability to generate demand for new hardware.

Tracy Reed
2008-05-12 00:18:12
This totally reminds me of APL...
Rick DeNatale
2008-05-12 05:53:54
Why do I have a feeling of deja-vu?

Is no one old enough to remember APL? A language from the early 1960s which used special characters, made possible by the advanced technology of replaceable type-balls on terminals based on the IBM Selectric typewriter mechanism, even before CRT terminals were common.

Here's a link to a picture of an APL keyboard.

Not that I think that this is a good idea.

Adam Lett
2008-05-12 05:59:06
This is a silly idea, not at all thought through. You don't provide a single argument explaining how exactly programmers are in any way "hampered" by QWERTY. You simply assert it. In what way would what you propose make a programmers job easier?

In my opinion Daren Thomas has it right: We need *less* punctuation and special characters, not more! And we especially don't need more keys on the keyboard.

2008-05-12 06:36:30
Have you ever used LaTeX? It's a programming language for typesetting, with a strong emphasis on getting mathematical notation right. For example, you write "2 \times 4" and get "2 × 4" instead of "2*4". If you were going to do things fully, you'd end up with the problems people have typing say, Chinese or Japanese, where the number of characters is hard to fit on one keyboard.

Decent WYSIWYG LaTeX editors are still rare (and hard to write even in principle), but it seems that if you wanted to have an environment where you could experiment with a wider notation, that would be the place to start. You could also try using Maple, the maths package. It uses character pallets, which are basically onscreen keyboards. You cold experiment and see if this is how you want to program, especially if you got ahold of a touch screen monitor so you could press those pallet buttons with your fingers.

Executable LaTeX could be interesting to develop, I'm not sure what's being done with Literate Programming nowadays.

2008-05-12 06:46:51
@Adam Lett: it's probably not an accident that all the sciences have custom notation, but then it's much easier to invent a new character with a pen than try and do the same with a computer. The keyboard is certainly lower bandwidth, though perhaps by dumbing everything down to ASCII it makes programs easier to read. Well, unless you want to read a 2D matrix. It's not like anyone could benefit from programming expressed as Venn diagrams is it? Or is it?
2008-05-12 07:09:45
I can see how this would be useful, actually. Surely others have realized that if we could use characters outside of the user's character set, we would not have to escape things (like quotes inside strings, for example)?

Something like this: [programmer-quote]Sam's cat said, "Hi!"[programmer-quote].

The idea of a "superset" of characters also applies to specifying languages in Backus-Naur format. Sometimes, the language has := in it, but that gets confusing because := is used be Backus-Naur itself to describe productions.

Daniel Berger
2008-05-12 07:15:48
@Rick, while I can appreciate the history of APL, I think it's a mistake to use that as a basis against allowing additional characters.

First, it isn't the 60's any more. It's a brave, new, Unicode world, and few outside the US seem particularly afraid of the notion. I'm not so sure why having to learn that ctrl-l (or whatever) is a lambda, for example, strikes you as a bad idea.

Second, I'm looking for a W3C standard keyboard layout of some sort. Or perhaps something the Fortress folks themselves should declare as an "official" keyboard layout for their language that we could use as a basis. Not something controlled by IBM. Mind you I think they should have done this _before_ they released the language, but that's another story.

Third, the APL layout is poor IMO. For example, why is ">" a "shift+7"? We've already got the ampersand there. I think we can do better.

2008-05-12 08:09:17
APL toyed with this idea, IIRC.
Carla Schroder
2008-05-12 11:58:52
Programmers aren't the only ones affected by the sparse QWERTY keyboard. Users have to tangle with gnarly problems like how to exactly quote some text? The command shell interprets most punctuation marks and it treats spaces in various random ways, so we have to jump through some truly silly hoops just to do simple tasks like searches on particular text strings. Is it '', or "", or \, or \\, which is escaping the escape character, or do you need [], or WTF??

Web forms are even more fun, especially the "helpful" ones that sort-of but not consistently automatically tag your entries. So they don't make a live hyperlink for you, but they will strip any tags you add (ahem O'Reilly blogs).

Is programming computers to divide large numbers with commas such a heroic feat of coding that no one can succeed at it? I just love reading long numbers with no commas.

And so on... is it any wonder so many of us dust off our old Selectrics, which by god when we type punctuation marks they stay put and don't pull any weird stunts?

Adam Lett
2008-05-12 14:46:05
@Daniel Berger:

Other than perhaps resulting in prettier source code, what exactly would be the benefits - from a programmers point of view - to having more (or maybe just different?) punctuation? What would be the benefit of having a keyboard with more keys?

Actually, I can maybe see a benefit to having more keys for anyone doing word processing and typesetting, because these are disciplines where aesthetics matter, which is maybe a reason for wanting a better choice of characters. But for programming? No.

The perfect programmers keyboard IMO is the Happy Hacker keyboard, which does away with caps lock (totally unnecessary) and the f-keys. Check it out here:

Less is more.

Jos Hirth
2008-05-12 20:37:29
Unicode is still problematic though. There are still a lot of websites/forums out there which can't deal with Unicode. Slashdot for example will happily garble any non-ASCII chars you put into a comment.

Then there is the font issue. A surprisingly large percentage of the machines out there can't even display Japanese, Chinese or Korean characters.

But it doesn't stop there. A few popular editors can't handle UTF-8 at all and many fail to support logical fonts. (A logical font is a list of physical fonts which are blended together to support more ranges.)

So, before something like this could be even considered those issues have to be sorted out beforehand.

>[...]the Happy Hacker keyboard, which does away with caps lock[...]

Caps lock is very handy though. That is if you use Enso or similar software. ;)

2008-05-12 22:13:11
I agree BIGTIME, i've been thinking for a while that we really should have moved beyond the capability of punched cards for program data by now, i think it would be easy enough to have a preparser replace any syntactic macros, and just think you could have different operators for bitwise AND versus logical AND, you would be able to have a different operator for assignment versus equality, and it doesn't end there, a nice function operator to replace the function keyword, more choice on container syntax elements, {}[](), it's a balancing act but i would really like to someone try and create a language that supports these kinds of elegant operations.

For some reason half the comments think this has something to do with the keyboard, it's not QWERTY, DVORAK, issues, The question is really why are we restricted in our code expressivness to 7bits. hell 8 would be a big step forward.

Adam Lett
2008-05-13 02:09:27
"Caps lock is very handy though"

Sometimes. You can get caps lock though by pressing [fn] + [tab] on the Happy Hacker. For the rare, rare instances where I need caps lock, I don't mind pressing this handy key combo to get it. F-keys are done in the same way: [fn] + a number key.

"For some reason half the comments think this has something to do with the keyboard"

Unsurprisingly, since the blog we're commenting on is called "Is QWERTY harming language design?".

I still would like someone to explain to me the *benefit* for a programmer of having more complex punctuation. None of the commenters who seem to think this is a good idea, have yet addressed this. Do any of you honestly believe it would be easier to write programs if the symbols we use resemble math book symbols more? Will it be faster to type them? Will it -really- be easier to read them?

2008-05-13 13:53:44
Just bind keystrokes to symbols in your editor or OS. Changing hardware is an immense task with minimal payoff. Plus, do you really want your laptop choices to get hugely narrowed? Programmers are already really picky about such things. I agree that (for instance) Ruby should accept a unicode lambda in the place of the word "lambda", but extrapolating that we all need new keyboards because of that is taking it way too far.
2008-05-14 02:44:12
That rather raises the bar for learning how to program, though, doesn't it?

When I was growing up every kid was bashing out crap basic on their home computers. Now it's all API's and libraries and you don't see that any more; I think that's definitely a step backwards. Worse yet if you can't program because you need special hardware.

2008-05-14 07:51:56
APL and Fortress not the only example of programming languages, which required non-ASCII characters. The Pascal language in its prime description used some special characters for mathematic operators, but in most implementations they were replaced with ascii combinations. So we write >= instead of ≥ in Pascal programs, and even if we use this special character, it will not be supported by any compiler. However, this problem prevents some other problems. UTF-8 is not compatible with 8-bits national encodings, which are widely used too, so using ascii-only symbols in program code make it more portable and more safe. But, I think, it is a good idea to make a compiler able to understand extended set of characters, which could make program code more readable. The only problem is input of them.

It is not difficult to modify keyboard layout and add some useful symbols. AltGr combinations may increase set of input characters in 2, and `dead key' may increase it much more, and some standard keyboard layouts must be corrected to be useful(I live in Ukraine, so I know a lot about Microsoft Ukrainian layout, which is not able to type Ukrainian), but 99% of computer users do not even know about layout editors. No additive hardware required (the only difference between QWERTY and any national or special keyboard is symbols on the top of each key). So inslall MS KLC or KLM32 and go on! And if some compiler supports extra characters, what is the reason not to add a special keyboard layout into its distributive?

Another problem is that there is no portable format of keyboard layouts. So layouts for Windows XP will not run on Windows 98 or any Unix platform.

2008-05-15 13:04:16
This keyboard *is* the programmer's keyboard. It dates back to the KSR-33 in the 1960s when the only users were programmers. The one concession to non-programmers was the Selectric-influenced placement of CAPS LOCK to the left of the A key where the CONTROL key belongs. The keypunch keyboard for data processing users was different in several ways.

Adding more keys or reusing the function keys would require the programmer to move her hands away from the home row. That destroys typing speed. I'd much rather bang out the two characters for <= than reach for a special ≥ key.

2008-05-16 06:41:36
Code is only as expressive as the human language that its written in. More than anything else, I think we use characters as shortcuts. Looking down at my keyboard, there are a number of of easily accessible characters that I hardly ever use in code.

A lot of good code, in my opinion, reads quite a bit like English (or the language that it's written in). We don't use many characters in English, so why would using more characters in code lead to more expressive code?

I will say that one of my favorite things about Ruby is allowing characters like ! and ? in method names, allowing code to read even more like English in some cases.

I'm happy that we have languages like Ruby that make *less* use of characters. Not having the code cluttered with curly braces and visibilities and return types, etc, keeps the code clean and concise.

2008-05-20 04:45:24
I agree with P.Y. that we have already done this by stringing the existing characters together. Do you think we would be better off saving one keystroke by having another set of keys for ==, ===, +=, -=, *=, /=, >>, <<, <=, >=, =>, ->, ::, ..., ||, &&, **, //, /* or any of the other combinations we use to make up for not having another set of keys?
markus hartenberger
2008-05-21 04:44:02
Fun idea but I think the adoption would be too difficult.

Because i think what is really limiting a language is the productivity.

If a "hello world" example could build a whole 3D animated movie... then this would be a productivty jump.

But just adding 100 extra chars wont have a productivitiy jump at all

Jim Power
2008-05-21 23:05:23
I don't know about you guys but I tear my hair our at least twice a week when coding on a French azerty "Clavier". The same is true for my french mac keyboard. I won't mention the short cut combinations: jedit , vim etc.
I feel an international keyborad is required that gets away from the typewriter restrictions. And Who best to start with but the coders.
2008-06-09 01:06:02
Does anyone remember the lauren hutton commercials that made menopause seem like a disease. Exposing hormone replacements was my first clue that we are being scammed by big pharma. Other than targeting fear of fat, its all targeting fear of aging. Some things are supposed to happen. I never bought the notion of "treating" menopause, but I have been sold some drugs I probably didn't need, made my own choice not to use them and I'm still here
Order Rimonabant
That was an interesting article and confirms my suspicions about these type of drugs. Nothing can take the place of good nutrition and adequate exercise. Acomplia buy Rimonabant
Hector Santos
2008-06-14 10:27:23
So we are back to APL thinking? The odd thing about languages is that more you of it, the more we want to expand it, then further creating more communications issues.
Hector Santos
2008-06-14 10:28:28
So we are back to APL thinking? The odd thing about languages is that more you know of it, the more we want to expand it thus further creating more communications issues.