Hacker News new | ask | show | jobs
by sltkr 5090 days ago
I 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.

4 comments

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++).

I actually pasted a Clojure file from a project I'm working on into the heatmap.js page and found that my home row was yellow/red, the parentheses were green and everything else was blue. So yes, parentheses are not as used in Clojure as in Common Lisp (and again colemak is awesome for keeping things on the home row!)
Yeah, paredit would make only the left paren red...
Shouldn't shift be twice as hot as the parentheses?
No because this heat map is clearly generated "offline". That is, this is built from a source-file dataset. An "online" dataset would be the output of a key logger. Online analysis would show the number of right parentheses to be a tiny fraction of left parentheses due to auto insertion and other paredit-like operations.
Still, the OP is right - for every character that can only be types by pressing SHIFT should also increase the counter for SHIFT.
If you want to be pedantic...

"Shouldn't shift be twice as hot as the parentheses?"

For offline analysis? No. Shift should be as hot as the SUM of both types of parentheses. In practice, both parentheses will be equal in count modulo some epsilon for unmatched parenthesis in strings and comments. Therefore, shift will be close to twice as either parenthesis.

For online analysis? No. Shifted characters can come into existence without being typed. For parenthesis, autocompletion is one way. Automatic bracket matching is another. There are many more, including template expansion, copy/paste, and several paredit operations.

If you want to be pedantic...

Shift is used for many combinations besides just parentheses, such as that capital at the start of this sentence. It would likely be more than twice as much.

A lot of emotions here. Making some of us jump to keyboard without reading carefully.
Well, they could have used caps lock. Very unlikely I know.
Should the offline generate recognize ) as a combination of 0 and Shift anyway?

And furthermore, where are all the numbers, tabs and spaces?

Yes, and in fact they are ignoring Control, Space and Tab too.
One question is why the Lisp code doesn't use the letter E as much as every language? Is that just due to normalizing of parentheses?
While I do not know standard lisp, according to my memory of scheme the following list of c keywords containing the letter 'e' exist in scheme: while.

while the following do not: break, case, continue, default, double, else, enum, extern, register, return, signed, sizeof, typedef, unsigned, volatile

It probably gets used about the same amount as the other languages, it's just that the parentheses get used an insane amount and outweigh all the other characters.
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
  [...]
> 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. :)