Live data from Hacker News

Most Pressed Keys and Programming Syntaxes

mahdiyusuf.com

71–80 of 99 posts

Re: Most Pressed Keys and Programming Syntaxes

#71

Just to drive the point home, Clojure's core.clj is 6,500+ lines of Lisp, funny enough, parens do not dominate - http://twitpic.com/6hwt28/full .

Well, there is a very good reason for this: Clojure tries to reduce the number of parentheses by substituting other characters, namely square brackets []. For example:

    ; Common Lisp
    (defun add (x y) (+ x y))
    ; Scheme
    (define (add x y) (+ x y))
    ; Clojure
    (defn add [x y] (+ x y))
Also, Clojure eliminates some parentheses that are used in other Lisps:

    ; Common Lisp and Scheme
    (cond ((> x 0) 1)
          ((= x 0) 0)
          (t -1))
    ; Clojure
    (cond (> x 0) 1
          (= x 0) 0
          :else -1)

Re: Most Pressed Keys and Programming Syntaxes

#73
post #53

Earlier quoted context omitted.

I'm curious, why do you have a large N key?

Ergonomic style split keyboard, I'm guessing? http://www.compkeyboard.com/uploadpic/Microsoft%20Natural%20...

Yeah, that's the one. I use this for my office keyboard and a Logitech G510 at home.

Re: Most Pressed Keys and Programming Syntaxes

#75

Earlier quoted context omitted.

The "-" key isn't even lukewarm which seems odd to me given what little I know about lisp.

I thought that to, until I saw the note saying Paul Graham wrote it. Arc is noticeably terse, and avoids the use of - key wherever possible.

Ah! That explains it; thanks!

Re: Most Pressed Keys and Programming Syntaxes

#76
post #17

Earlier quoted context omitted.

But then you lose the impact of the entire set of reserved words. At the point of ignoring the entire alphabet, you're looking at developer preferences for spacing and operators. Might be a nice sidebar to the existing heat maps.

What would a programming language look like if it was optimized so its reserved keywords used mostly home row letters (and, in Unix tradition, preferably alternated left/right hands) and operators without shifting? This would be tough, since the home row only has one vowel: a .

I was wondering the same thing and noticed that the vowels almost always feature in the top 10 and DVORAK has them all in one hand. yay..Infact, in a very casual observation, i think only 'r' seems to be the letter out of DVORAK layout.. I looked across languages though. Guess this makes me a DVORAK evangelist.:-) And to complete that image i will add this DVzine link.http://www.dvzine.org/

Re: Most Pressed Keys and Programming Syntaxes

#77
post #44

Whitespace hasn’t been taken into consideration (tabs and spaces) which would have been a cool thing to see. I think if that was included this would be a lot more useful. Is there a reason it wasn't?

Different editors take different amounts of effort to insert whitespace.

Still without whitespaces, i have to look at the python heatmap a little differently..

Re: Most Pressed Keys and Programming Syntaxes

#79
Here's one for Smalltalk. It's based on my .changes file - about 200K LOC, with all the lines containing '----' and $! removed. What's left is, I think, stuff that actually got typed into a browser.

You can definitely see $:, but otherwise it looks pretty much like English.

Re: Most Pressed Keys and Programming Syntaxes

#80
post #5

it'd be interesting to see these heatmaps in some sort of normalized way. for example, 'e' is the most common letter in english, so its the most commonly used letter in these programming languages. it'd be very interesting to see, for example, this heatmap with the intensities divided by each letter's frequency of use in the English language, or across a large set of data including a lot of different programming lang…

Just did it for 28000 C files. Here's the results: a 0.772163 b 1.2679 c 1.78209 d 1.1195 e 0.881398 f 1.47252 g 0.924242 h 0.358954 i 1.06756 j 0.835313 k 1.41458 l 0.981729 m 1.08955 n 0.9156 o 0.73849 p 1.74468 q 4.2497 r 1.21577 s 1.05023 t 1.03627 u 1.2967 v 1.77662 w 0.396003 x 13.7292 y 0.47566 z 3.78748 The numbers are (relative frequency in C) / (relative frequency in English). So "b" is slightly more common…

What would be interesting here would be a difference analysis or regression giving the preference for any given key in a given language. E.g.: '|' is highly predictive of shell, '$' of perl, '()' for lisp. Might be fun to do in R.
Post reply on HN