I'd be curious to see the same analysis done but with alternate keyboard layouts, such as dvorak or colemak.
Most Pressed Keys and Programming Syntaxes
61–70 of 75 posts
Re: Most Pressed Keys and Programming Syntaxes
#62And I can visually see the reasoning behind Colemak being like this, now.
Re: Most Pressed Keys and Programming Syntaxes
#63Interesting how "i" is more common in some languages than others. C and C++ make sense (for(i = 0; i < n; i++)), but Ruby is a puzzler.
"nil" "if" and "elsif" EDIT: though looking at my sources, where it seems to also be popular, it mostly seems to match inside non-syntax (field, nickname, to_i, strip, index, client).
Re: Most Pressed Keys and Programming Syntaxes
#64Earlier quoted context omitted.
"nil" "if" and "elsif" EDIT: though looking at my sources, where it seems to also be popular, it mostly seems to match inside non-syntax (field, nickname, to_i, strip, index, client).
How about |i|?
Re: Most Pressed Keys and Programming Syntaxes
#65Earlier quoted context omitted.
It might be more interesting to see these with the vowels factored out.
~ $ curl -s 'http://lib.store.yahoo.net/lib/paulgraham/onlisp.lisp' | egrep -o '.' | sort | uniq -c | sort -nr 18641 3277 ) 3276 ( 2561 e 2159 a 1934 s 1903 r 1672 n 1661 t 1477 l 1380 o 1287 c 1282 d 1067 p 1064 i 1030 m [...] Without vowels: 18641 3277 ) 3276 ( 1934 s 1903 r 1672 n 1661 t 1477 l 1287 c 1282 d 1067 p 1030 m 929 f 852 b 654 , 601 g [...]
My first thought: 'unmatched paren?'
But I bet there's a smiley face on that page somewhere.
EDIT: If there is, I don't see it.
Re: Most Pressed Keys and Programming Syntaxes
#66I skimmed comments here and couldn't find anything that talks about why e is so popular? Is it because ETAOIN? Because almost no "{" "}" pressed in C/Java. Almost no ":" used in Python. "/" key is more popular than "[" "]" in Objective-C. This makes no sense. I don't believe that blog post.
I found the Objective-C one strange too. I would have thought '[' and ']' would have been two of the most pressed keys. I only really use '/' for commenting.
(Simple) Example:
PHP:
$myString = sprintf('Total: %.2f', $myFloat);
ObjC:
NSString *myString = [NSString stringWithFormat:@"Total: %.2f", myFloat];
Maybe this is the reason these characters don't score too highly in overall frequency? I have no answer for the high frequency of '/'.Re: Most Pressed Keys and Programming Syntaxes
#67Earlier quoted context omitted.
I found the Objective-C one strange too. I would have thought '[' and ']' would have been two of the most pressed keys. I only really use '/' for commenting.
I do type a lot more square brackets in ObjC than any other language, but I find that I type a lot more generally due to the increased length of many method names in ObjC (or I would do if autocomplete didn't do it for me). (Simple) Example: PHP: $myString = sprintf('Total: %.2f', $myFloat); ObjC: NSString *myString = [NSString stringWithFormat:@"Total: %.2f", myFloat]; Maybe this is the reason these characters don't…
Re: Most Pressed Keys and Programming Syntaxes
#68Earlier quoted context omitted.
~ $ curl -s 'http://lib.store.yahoo.net/lib/paulgraham/onlisp.lisp' | egrep -o '.' | sort | uniq -c | sort -nr 18641 3277 ) 3276 ( 2561 e 2159 a 1934 s 1903 r 1672 n 1661 t 1477 l 1380 o 1287 c 1282 d 1067 p 1064 i 1030 m [...] Without vowels: 18641 3277 ) 3276 ( 1934 s 1903 r 1672 n 1661 t 1477 l 1287 c 1282 d 1067 p 1030 m 929 f 852 b 654 , 601 g [...]
> 3277 ) > 3276 ( My first thought: 'unmatched paren?' But I bet there's a smiley face on that page somewhere. EDIT: If there is, I don't see it.
(let ((rpar (get-macro-character #\) )))
Escaped. :)Re: Most Pressed Keys and Programming Syntaxes
#69I skimmed comments here and couldn't find anything that talks about why e is so popular? Is it because ETAOIN? Because almost no "{" "}" pressed in C/Java. Almost no ":" used in Python. "/" key is more popular than "[" "]" in Objective-C. This makes no sense. I don't believe that blog post.
Just off the top of my head, I'd guess it's due to a lot of e's in words that, depending on the language, you'll see in almost every single method or function. Things like return, end, else, true, include, self, private, etc.
Re: Most Pressed Keys and Programming Syntaxes
#70I admit, the Lisp one at the end made me laugh. For most other languages the focus seems to be mainly on letters (typing out keywords/identifiers), so in that sense there is little evidence that one language would be easier to write than another. Additionally, I imagine that some of the code is auto-completed by an IDE, which this analysis fails to account for.
I'd love to see how Clojure compares, as it uses fewer parentheses and may even be competitive to, eg, Java in its use of parentheses. As an aside, its interesting (to me, as a Colemak user) that all of the hot alphabetic characters in all the analyzed languages are on the home row of the Colemak layout (except L, which seems to be kind of hot in C++).