Programming Language Popularity - Part Thirteen

:: programming, c, clojure, common lisp, elixir, haskell, julia, lisp, ocaml, prolog, racket, ruby, rust, scheme

I occasionally compile some statistics on programming language popularity by running a bunch of Google searches to rank programming languages according to the number of results. I wouldn’t read too much into these stats, but they are not without value.

This time, I’ve included the code I use (written in Racket) and the raw data.

I made the following Google searches and summed the results:

"implemented in <lang>"
"written in <lang>"
"developed in <lang>"
"programmed in <lang>"

The table (Emacs org-mode) is divided into sections based on percentage increases of more than 50% from one language to the next.

|------+-----------------+------------+-------+-------|
| Rank | Language        | # Search   | Prev. |  Rank |
|      |                 | Results    |  Rank | Delta |
|------+-----------------+------------+-------+-------|
|    1 | C               | 61,524,000 |     1 |       |
|    2 | R               | 46,576,000 |     2 |       |
|------+-----------------+------------+-------+-------|
|    3 | Java            |  8,236,000 |     3 |       |
|    4 | Python          |  7,659,000 |     4 |       |
|------+-----------------+------------+-------+-------|
|    5 | C++             |  4,151,000 |     5 |       |
|------+-----------------+------------+-------+-------|
|    6 | C#              |  2,029,000 |     6 |       |
|    7 | JavaScript      |  1,907,000 |     7 |       |
|    8 | Go              |  1,898,400 |     9 |    +1 |
|    9 | Lisp Family (1) |  1,751,460 |    10 |    +1 |
|   10 | Fortran         |  1,498,400 |     8 |    -2 |
|   11 | Ruby            |  1,150,500 |    11 |       |
|   12 | Rust            |    907,440 |    17 |    +5 |
|   13 | Scala           |    839,600 |    15 |    +2 |
|   14 | Perl            |    801,200 |    12 |    -2 |
|   15 | Scheme          |    784,400 |    14 |    -1 |
|------+-----------------+------------+-------+-------|
|   16 | Pony            |    499,924 |    30 |   +14 |
|   17 | Forth           |    483,330 |    26 |    +9 |
|   18 | Lisp            |    417,200 |    18 |       |
|   19 | Prolog          |    376,500 |    16 |    -3 |
|   20 | Haskell         |    313,000 |    13 |    -7 |
|   21 | Lua             |    297,200 |    20 |    -1 |
|   22 | Julia           |    268,900 |    25 |    +3 |
|   23 | Common Lisp     |    241,100 |    22 |    -1 |
|   24 | Racket          |    235,110 |    29 |    +5 |
|------+-----------------+------------+-------+-------|
|   25 | COBOL           |    137,900 |    21 |    -4 |
|   26 | Smalltalk       |    126,780 |    24 |    -2 |
|   27 | Erlang          |    125,270 |    19 |    -8 |
|   28 | OCaml           |    103,340 |    23 |    -5 |
|   29 | Clojure         |     73,650 |    27 |    -2 |
|   30 | Elixir          |     54,691 |    28 |    -2 |
|------+-----------------+------------+-------+-------|

(1) combines Lisp, Common Lisp, Scheme, Clojure, Racket

Source

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#lang racket
;; Copyright (C) 2015-2020 by Brian J. Adkins

;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:

;; The above copyright notice and this permission notice shall be included in
;; all copies or substantial portions of the Software.

;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
;; THE SOFTWARE.

(require net/http-client)
(require net/uri-codec)

(define search-engine-host "www.google.com")

;; The list of programming languages for which we'll gather usage statistics.
(define languages '("c" "c#" "c++" "clojure" "cobol" "common lisp" "elixir" "erlang"
                    "forth" "fortran" "go" "haskell" "java" "javascript" "julia" "lisp"
                    "lua" "ocaml" "perl" "pony" "prolog" "python" "r" "racket" "ruby" "rust"
                    "scala" "scheme" "smalltalk"))

;; Four distinct phrases we'll search for
(define phrases '("written in" "programmed in" "developed in" "implemented in"))

;; To avoid being blocked, we'll pause for a random number of seconds in the range [ 30 , 90 ]
(define (random-sleep)
  (sleep (+ 30 (random 61))))

;; We'll send User-Agent and Accept headers
(define request-headers
  ;; (list (string-append "User-Agent:"
  ;;                      " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0)"
  ;;                      " Gecko/20100101 Firefox/34.0")
  ;;       "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"))
  (list (string-append "User-Agent:"
                       " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:35.0)"
                       " Gecko/20100101 Firefox/35.0")
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        "Referer: https://www.google.com"))

;; Form the path for the query
(define (form-search-path language phrase)
  (format "/search?q=~a" (uri-encode (format "\"~a ~a\"" phrase language))))

;; Indicate whether the HTTP GET request was successful
(define (success-status? status)
  (regexp-match #px"200 OK$" status))

;; Parse a string of the form 543,987 into an integer
(define (parse-num-results str)
  (string->number (string-replace str "," "")))

;; Perform all queries for a given language. Return (list <lang> num-results)
(define (query-lang language)
  ;; Create a set of search paths for the language and search phrases
  (define paths (map (λ (phrase) (form-search-path language phrase)) phrases))

  ;; Parse the search results page
  (define (parse-results-page io-port path)
    (let ([result (regexp-match
                   #px"<div id=\"result-stats\">.*?([0-9,]+) results.*?</div>"
                   (port->string io-port))])
      (if result
          (let ([n (parse-num-results (cadr result))])
            (printf "Path=~a Num=~a\n" path n)
            n)
          (raise "Failed to parse num results"))))

  ;; Peform a single query for one path, e.g. /search?q="written in racket" and
  ;; return the number of search results.
  (define (one-query path)
    (random-sleep)

    ;; Make the HTTP GET request
    (define-values (status headers io-port)
      (http-sendrecv search-engine-host path #:ssl? #t #:headers request-headers))

    (if (success-status? status)
        (parse-results-page io-port path)
        (begin
          (displayln (port->string io-port))
          (raise "Failed to receive 200 OK"))))

  ;; Recursively query each path in the list and accumulate the sum of the number of results.
  (define (sum-queries paths sum)
    (cond [(null? paths) (list language sum)]
          [else (sum-queries (cdr paths)
                             (+ sum (one-query (car paths))))]))

  (sum-queries paths 0))

(module+ main
  ;; For each language in our list, run the entire set of queries and
  ;; return the number of search results.
  (for ([lang languages])
    (displayln (query-lang lang))
    (flush-output)))

Raw Data

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Path=/search?q=%22written%20in%20c%22 Num=23400000
Path=/search?q=%22programmed%20in%20c%22 Num=324000
Path=/search?q=%22developed%20in%20c%22 Num=21900000
Path=/search?q=%22implemented%20in%20c%22 Num=15900000
(c 61524000)
Path=/search?q=%22written%20in%20c%23%22 Num=712000
Path=/search?q=%22programmed%20in%20c%23%22 Num=161000
Path=/search?q=%22developed%20in%20c%23%22 Num=567000
Path=/search?q=%22implemented%20in%20c%23%22 Num=589000
(c# 2029000)
Path=/search?q=%22written%20in%20c%2B%2B%22 Num=2720000
Path=/search?q=%22programmed%20in%20c%2B%2B%22 Num=108000
Path=/search?q=%22developed%20in%20c%2B%2B%22 Num=461000
Path=/search?q=%22implemented%20in%20c%2B%2B%22 Num=862000
(c++ 4151000)
Path=/search?q=%22written%20in%20clojure%22 Num=38900
Path=/search?q=%22programmed%20in%20clojure%22 Num=3950
Path=/search?q=%22developed%20in%20clojure%22 Num=16800
Path=/search?q=%22implemented%20in%20clojure%22 Num=14000
(clojure 73650)
Path=/search?q=%22written%20in%20cobol%22 Num=78300
Path=/search?q=%22programmed%20in%20cobol%22 Num=16000
Path=/search?q=%22developed%20in%20cobol%22 Num=22900
Path=/search?q=%22implemented%20in%20cobol%22 Num=20700
(cobol 137900)
Path=/search?q=%22written%20in%20common%20lisp%22 Num=134000
Path=/search?q=%22programmed%20in%20common%20lisp%22 Num=14800
Path=/search?q=%22developed%20in%20common%20lisp%22 Num=58200
Path=/search?q=%22implemented%20in%20common%20lisp%22 Num=34100
(common lisp 241100)
Path=/search?q=%22written%20in%20elixir%22 Num=29400
Path=/search?q=%22programmed%20in%20elixir%22 Num=531
Path=/search?q=%22developed%20in%20elixir%22 Num=16800
Path=/search?q=%22implemented%20in%20elixir%22 Num=7960
(elixir 54691)
Path=/search?q=%22written%20in%20erlang%22 Num=59100
Path=/search?q=%22programmed%20in%20erlang%22 Num=7670
Path=/search?q=%22developed%20in%20erlang%22 Num=33800
Path=/search?q=%22implemented%20in%20erlang%22 Num=24700
(erlang 125270)
Path=/search?q=%22written%20in%20forth%22 Num=416000
Path=/search?q=%22programmed%20in%20forth%22 Num=8730
Path=/search?q=%22developed%20in%20forth%22 Num=18200
Path=/search?q=%22implemented%20in%20forth%22 Num=40400
(forth 483330)
Path=/search?q=%22written%20in%20fortran%22 Num=562000
Path=/search?q=%22programmed%20in%20fortran%22 Num=47400
Path=/search?q=%22developed%20in%20fortran%22 Num=399000
Path=/search?q=%22implemented%20in%20fortran%22 Num=490000
(fortran 1498400)
Path=/search?q=%22written%20in%20go%22 Num=1090000
Path=/search?q=%22programmed%20in%20go%22 Num=68400
Path=/search?q=%22developed%20in%20go%22 Num=561000
Path=/search?q=%22implemented%20in%20go%22 Num=179000
(go 1898400)
Path=/search?q=%22written%20in%20haskell%22 Num=143000
Path=/search?q=%22programmed%20in%20haskell%22 Num=19600
Path=/search?q=%22developed%20in%20haskell%22 Num=93000
Path=/search?q=%22implemented%20in%20haskell%22 Num=57400
(haskell 313000)
Path=/search?q=%22written%20in%20java%22 Num=5160000
Path=/search?q=%22programmed%20in%20java%22 Num=136000
Path=/search?q=%22developed%20in%20java%22 Num=1070000
Path=/search?q=%22implemented%20in%20java%22 Num=1870000
(java 8236000)
Path=/search?q=%22written%20in%20javascript%22 Num=921000
Path=/search?q=%22programmed%20in%20javascript%22 Num=154000
Path=/search?q=%22developed%20in%20javascript%22 Num=546000
Path=/search?q=%22implemented%20in%20javascript%22 Num=286000
(javascript 1907000)
Path=/search?q=%22written%20in%20julia%22 Num=94300
Path=/search?q=%22programmed%20in%20julia%22 Num=17700
Path=/search?q=%22developed%20in%20julia%22 Num=127000
Path=/search?q=%22implemented%20in%20julia%22 Num=29900
(julia 268900)
Path=/search?q=%22written%20in%20lisp%22 Num=170000
Path=/search?q=%22programmed%20in%20lisp%22 Num=29800
Path=/search?q=%22developed%20in%20lisp%22 Num=85400
Path=/search?q=%22implemented%20in%20lisp%22 Num=132000
(lisp 417200)
Path=/search?q=%22written%20in%20lua%22 Num=166000
Path=/search?q=%22programmed%20in%20lua%22 Num=27000
Path=/search?q=%22developed%20in%20lua%22 Num=69700
Path=/search?q=%22implemented%20in%20lua%22 Num=34500
(lua 297200)
Path=/search?q=%22written%20in%20ocaml%22 Num=47400
Path=/search?q=%22programmed%20in%20ocaml%22 Num=7640
Path=/search?q=%22developed%20in%20ocaml%22 Num=25100
Path=/search?q=%22implemented%20in%20ocaml%22 Num=23200
(ocaml 103340)
Path=/search?q=%22written%20in%20perl%22 Num=326000
Path=/search?q=%22programmed%20in%20perl%22 Num=41200
Path=/search?q=%22developed%20in%20perl%22 Num=164000
Path=/search?q=%22implemented%20in%20perl%22 Num=270000
(perl 801200)
Path=/search?q=%22written%20in%20pony%22 Num=491000
Path=/search?q=%22programmed%20in%20pony%22 Num=4
Path=/search?q=%22developed%20in%20pony%22 Num=7070
Path=/search?q=%22implemented%20in%20pony%22 Num=1850
(pony 499924)
Path=/search?q=%22written%20in%20prolog%22 Num=123000
Path=/search?q=%22programmed%20in%20prolog%22 Num=21000
Path=/search?q=%22developed%20in%20prolog%22 Num=93500
Path=/search?q=%22implemented%20in%20prolog%22 Num=139000
(prolog 376500)
Path=/search?q=%22written%20in%20python%22 Num=5130000
Path=/search?q=%22programmed%20in%20python%22 Num=95000
Path=/search?q=%22developed%20in%20python%22 Num=1440000
Path=/search?q=%22implemented%20in%20python%22 Num=994000
(python 7659000)
Path=/search?q=%22written%20in%20r%22 Num=14800000
Path=/search?q=%22programmed%20in%20r%22 Num=276000
Path=/search?q=%22developed%20in%20r%22 Num=17800000
Path=/search?q=%22implemented%20in%20r%22 Num=13700000
(r 46576000)
Path=/search?q=%22written%20in%20racket%22 Num=215000
Path=/search?q=%22programmed%20in%20racket%22 Num=1660
Path=/search?q=%22developed%20in%20racket%22 Num=3850
Path=/search?q=%22implemented%20in%20racket%22 Num=14600
(racket 235110)
Path=/search?q=%22written%20in%20ruby%22 Num=949000
Path=/search?q=%22programmed%20in%20ruby%22 Num=44700
Path=/search?q=%22developed%20in%20ruby%22 Num=65600
Path=/search?q=%22implemented%20in%20ruby%22 Num=91200
(ruby 1150500)
Path=/search?q=%22written%20in%20rust%22 Num=777000
Path=/search?q=%22programmed%20in%20rust%22 Num=4040
Path=/search?q=%22developed%20in%20rust%22 Num=47600
Path=/search?q=%22implemented%20in%20rust%22 Num=78800
(rust 907440)
Path=/search?q=%22written%20in%20scala%22 Num=606000
Path=/search?q=%22programmed%20in%20scala%22 Num=22700
Path=/search?q=%22developed%20in%20scala%22 Num=39900
Path=/search?q=%22implemented%20in%20scala%22 Num=171000
(scala 839600)
Path=/search?q=%22written%20in%20scheme%22 Num=255000
Path=/search?q=%22programmed%20in%20scheme%22 Num=24400
Path=/search?q=%22developed%20in%20scheme%22 Num=289000
Path=/search?q=%22implemented%20in%20scheme%22 Num=216000
(scheme 784400)
Path=/search?q=%22written%20in%20smalltalk%22 Num=42900
Path=/search?q=%22programmed%20in%20smalltalk%22 Num=8480
Path=/search?q=%22developed%20in%20smalltalk%22 Num=39200
Path=/search?q=%22implemented%20in%20smalltalk%22 Num=36200
(smalltalk 126780)