Rosetta Code/Rank languages by popularity: Difference between revisions

m
→‎{{header|Wren}}: Minor tidy and rerun
m (→‎{{header|REXX}}: changed wording in the REXX section header.)
m (→‎{{header|Wren}}: Minor tidy and rerun)
(38 intermediate revisions by 11 users not shown)
Line 8:
Sort the most popular computer programming languages based in number of members in Rosetta Code categories.
 
Sample output on 0402 JulyAugust 20212022 at 0009:3150 +02:
<pre>Rank: 1 (1,383565 entries) Phix
Rank: 2 (1,377558 entries) GoWren
Rank: 3 (1,368531 entries) Julia
Rank: 4 (1,350507 entries) Raku
Rank: 5 (1,306500 entries) PerlGo
Rank: 6 (1,303466 entries) NimPerl
Rank: 7 (1,260409 entries) Python
Rank: 8 (1,251402 entries) WrenNim
Rank: 9 (1,139254 entries) CJ
Rank: 10 (1,130211 entries) KotlinC
...</pre>
 
Line 29:
* &nbsp; Filtering wrong results is optional. &nbsp; You can check against [[Special:MostLinkedCategories]] (if using web scraping)
::If you use the API, and do elect to filter, you may check your results against [[Rosetta_Code/Rank_languages_by_popularity/Full_list|this complete, accurate, sortable, wikitable listing]] of all '''{{PAGESINCAT:Programming Languages}}''' [[:Category:Programming Languages|programming languages]], updated periodically, ''typically weekly''.
* &nbsp; A complete ranked listing of all &nbsp; '''809813''' &nbsp; languages (from the REXX example) is included here &nbsp; ──► &nbsp; [[RC_POP.OUT|output from the REXX program]].
<br><br>
 
=={{header|Ada}}==
{{libheader|AWS}}
<langsyntaxhighlight lang="ada">with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
Line 123:
Counts.Reverse_Iterate (Display'Access);
end Test;
</syntaxhighlight>
</lang>
 
=={{header|ALGOL 68}}==
Line 135:
{{incorrect|ALGOL 68| <br> ---among others, Tcl (the top dog) is missing. <br>}}
 
<langsyntaxhighlight lang="algol68">PROC good page = (REF STRING page) BOOL:
IF grep in string("^HTTP/[0-9.]* 200", page, NIL, NIL) = 0
THEN TRUE
Line 258:
printf(($g(-0)". "g(-0)" - "gl$,i,stats[i]))
OD
FI</langsyntaxhighlight>
{{out|Sample output}}
<pre>
Line 274:
 
===ALGOL 68:using the API===
<langsyntaxhighlight lang="algol68">
CHAR line feed = REPR 10, carriage return = REPR 13;
STRING crlf = carriage return + line feed;
Line 431:
lasttied := tied
FI
OD</langsyntaxhighlight>
{{out|Sample output top 10}}
<pre>
Line 451:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight lang="autohotkey">MembsUrl = http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000
ValidUrl = http://rosettacode.org/wiki/Category:Programming_Languages
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Line 536:
GuiClose:
ExitApp
return</langsyntaxhighlight>
 
=={{header|AWK}}==
Line 543:
This is the third solution. The [http://rosettacode.org/mw/index.php?title=Rosetta_Code/Rank_languages_by_popularity&oldid=102962#AWK first solution] used web scraping with an external program '''ns''' for networking. The [http://rosettacode.org/mw/index.php?title=Rosetta_Code/Rank_languages_by_popularity&oldid=204081 second solution] used the Rosetta Code API instead of web scraping, but continued use of '''ns''' which for unknown reasons didn't work correctly. This solution uses native gawk networking to connect to the API at 500 items per request ("gmcontinue").
 
<langsyntaxhighlight lang="awk">function join(array, start, end, sep, result, i) {
result = array[start]
for (i = start + 1; i <= end; i++)
Line 626:
print ++i ". " language " - " G[language]
 
}</langsyntaxhighlight>
{{out|Output from 26 May 2015}}
<pre>1. Tcl - 867
Line 646:
{{works with|BBC BASIC for Windows}}
Note that language names differing only in their case are merged.
<langsyntaxhighlight lang="bbcbasic"> INSTALL @lib$+"SORTLIB"
SortUp% = FN_sortinit(0,0) : REM Ascending
SortDown% = FN_sortinit(1,0) : REM Descending
Line 735:
UNTIL H%=0
SYS "CompareString", 0, NORM_IGNORECASE, S$, -1, a$(B%), -1 TO C%
IF C% = 2 THEN = B% ELSE = -1</langsyntaxhighlight>
'''Output:'''
<pre>
Line 775:
 
=={{header|Bracmat}}==
<langsyntaxhighlight lang="bracmat"> ( get-page
= url type
. !arg:(?url.?type)
Line 865:
)
)
& ;</langsyntaxhighlight>
Output:
<pre> 1. 816 - Tcl
Line 916:
{{improve|C|This solution uses an external program '''wget''' for networking, but it could use '''Library: libcurl''' (see [[Web scraping#C]]) for example. Also this solution scrapes Special:Categories &limit 5000 which will break if the HTML style changes or the number of languages exceeds 5000. It could use the MediWiki API to get the language names and pages in a single call, in blocks of 500 until complete with no upper limit. See the Awk example. If you make an API-based version please retain the web-scrapping version in its own sub-section (following the lead of [[Rosetta_Code/Rank_languages_by_popularity#Tcl|TCL on this page]]). }}
 
Ghetto parser<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 992:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre> 563 Tcl
Line 1,012:
Usage: rank [number]<br>
Outputs the first [number] languages in the list, default to 10. Use -1 to display all the languages.
<syntaxhighlight lang="c">
<lang c>
#include <stdio.h>
#include <stdlib.h>
Line 1,160:
} while (sorted!=1);
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,176:
 
=={{header|C sharp|C#}}==
Sorting only programming languages.<br>
Note that this does not distinguish between tasks and non-task categories, so the counts can exceed the total number of tasks.<br>
<lang csharp>using System;
Note this may need to set the Security Protocol type to Tls12 - see the section Problem running the C# entry in [[Talk:Rosetta_Code/Count_examples]]
<syntaxhighlight lang="csharp">
using System;
using System.Collections;
using System.Collections.Generic;
Line 1,188 ⟶ 1,191:
static void Main(string[] args)
{
string get1get2 = new WebClient().DownloadString("http://www.rosettacode.org/w/apiindex.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=json");
string get2 = new WebClient().DownloadString( +"http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000");
);
 
ArrayList langs = new ArrayList();
Dictionary<string, int> qtdmbr = new Dictionary<string, int>();
 
string cmcontinue = "";
MatchCollection match1 = new Regex("\"title\":\"Category:(.+?)\"").Matches(get1);
MatchCollection match2 = new Regex("title=\"Category:(.+?)\">.+?</a>[^(]*\\((\\d+) members\\)").Matches(get2);
 
do
foreach (Match lang in match1) langs.Add(lang.Groups[1].Value);
{
string get1 = new WebClient().DownloadString("http://www.rosettacode.org/w/api.php?"
+"action=query&list=categorymembers"
+"&cmtitle=Category:Programming_Languages"
+"&cmlimit=500&format=json"
+cmcontinue
);
cmcontinue = "";
MatchCollection languageMatch = new Regex("\"title\":\"Category:(.+?)\"").Matches(get1);
MatchCollection cmcontinueMatch = new Regex("cmcontinue\":\"([a-z0-9A-Z|]*)\"").Matches(get1);
foreach (Match lang in languageMatch) langs.Add(lang.Groups[1].Value);
foreach (Match more in cmcontinueMatch) cmcontinue = "&cmcontinue=" + more.Groups[1].Value;
}
while( cmcontinue != "" );
 
MatchCollection match2 =
new Regex("title=\"Category:(.+?)\">.+?</a>[^(]*\\(([\\d,.]+) members\\)").Matches(get2);
 
foreach (Match match in match2)
Line 1,203 ⟶ 1,223:
if (langs.Contains(match.Groups[1].Value))
{
qtdmbr.Add(match.Groups[1].Value, Int32.Parse(match.Groups[2].Value));
.Replace(",",string.Empty)
.Replace(".",string.Empty)));
}
}
 
string[] test =
string[] test = qtdmbr.OrderByDescending(x => x.Value).Select(x => String.Format("{0,3} - {1}", x.Value, x.Key)).ToArray();
qtdmbr.OrderByDescending(x => x.Value).Select(x => String.Format("{0,4} {1}", x.Value, x.Key)).ToArray();
 
int count = 1;
Line 1,213 ⟶ 1,236:
foreach (string i in test)
{
Console.WriteLine("{0,34}.: {1}", count, i);
count++;
}
}
}
}</lang>
</syntaxhighlight>
{{out|Output (as of May 30, 2010)}}
{{out|Output (as of September 11, 2023)}}
1. 397 - Tcl
<pre>
2. 368 - Python
3. 3501: -1660 RubyPhix
4. 3332: -1653 JWren
5. 3323: -1617 CJulia
6. 3224: -1598 HaskellRaku
7. 3225: -1577 OCamlNim
8. 3026: -1548 PerlGo
7: 1537 Perl
9. 290 - Common Lisp
8: 1487 Python
10. 289 - AutoHotkey
9: 1376 J
10: 1287 C
. . .
</pre>
 
===Object-oriented solution===
<langsyntaxhighlight lang="csharp">using System;
using System.Net;
using System.Linq;
Line 1,285 ⟶ 1,312:
}
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
{{libheader|Boost}}
using g++ under Linux with <tt>g++ -lboost_thread -lboost_system -lboost_regex</tt>:
<langsyntaxhighlight lang="cpp">#include <string>
#include <boost/regex.hpp>
#include <boost/asio.hpp>
Line 1,367 ⟶ 1,394:
}
return 0 ;
}</langsyntaxhighlight>
{{out|Sample output (just the "top ten")}}
1. 367 - Tcl
Line 1,382 ⟶ 1,409:
=={{header|Caché ObjectScript}}==
 
<langsyntaxhighlight lang="cos">Class Utils.Net.RosettaCode [ Abstract ]
{
 
Line 1,461 ⟶ 1,488:
}
 
}</langsyntaxhighlight>
{{out|Example}}
<pre>
Line 1,480 ⟶ 1,507:
=={{header|D}}==
With dmd you need compile like "<tt>dmd rosetta_popularity.d -L-lphobos2 -L-lcurl</tt>".
<langsyntaxhighlight lang="d">void main() {
import std.stdio, std.algorithm, std.conv, std.array, std.regex,
std.typecons, std.net.curl;
Line 1,499 ⟶ 1,526:
foreach (i, res; pairs.array.sort!q{a > b}.release)
writefln("%3d. %3d - %s", i + 1, res[]);
}</langsyntaxhighlight>
{{out|Sample output (top twenty as of 2013-01-24)}}
<pre> 1. 717 - Tcl
Line 1,536 ⟶ 1,563:
{{libheader| System.Generics.Defaults}}
For safe run, download dlls: libeay32.dll & ssleay32.dll, then put in executable path.
<syntaxhighlight lang="delphi">
<lang Delphi>
program Rank_languages_by_popularity;
 
Line 1,673 ⟶ 1,700:
end.
 
</syntaxhighlight>
</lang>
 
{{out|Output (as of Jul 27, 2020)}}
Line 1,695 ⟶ 1,722:
 
=={{header|Erlang}}==
<syntaxhighlight lang="erlang">
<lang Erlang>
-module( rank_languages_by_popularity ).
 
Line 1,756 ⟶ 1,783:
place_count_category_write( Count, #print_fold{place=Place, place_step=Place_step} ) ->
#print_fold{place=Place + Place_step, previous_count=Count}.
</syntaxhighlight>
</lang>
{{out|Sample output (top/last ten as of 2013-05-27)}}
<pre>
Line 1,783 ⟶ 1,810:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">open System
open System.Text.RegularExpressions
Line 1,835 ⟶ 1,862:
(seq { 1 .. 20 })
(entriesWithCount |> Seq.map (fun x -> sprintf "%3d - %s" (snd x) (fst x)))
0</langsyntaxhighlight>
Showing top 20 as of 2013-04-02
<pre>
Line 1,860 ⟶ 1,887:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,974 ⟶ 2,001:
fmt.Printf("%3d. %3d - %s\n", lastIdx, lang.int, lang.string)
}
}</langsyntaxhighlight>
{{out|Output on 11 Aug 2014}}
<pre>
Line 1,992 ⟶ 2,019:
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">def html = new URL('http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000').getText([
connectTimeout:500,
readTimeout:15000,
Line 2,000 ⟶ 2,027:
count[language] = (members as int)
}
count.sort { v1, v2 -> v2.value <=> v1.value }.eachWithIndex { value, index -> println "${index + 1} $value" }</langsyntaxhighlight>
Output:
<pre>1 Tcl=766
Line 2,015 ⟶ 2,042:
===Haskell: Using the API===
 
<langsyntaxhighlight lang="haskell">{-# LANGUAGE OverloadedStrings #-}
 
import Data.Aeson
Line 2,116 ⟶ 2,143:
 
main :: IO ()
main = runQuery [] queryStr</langsyntaxhighlight>
{{out}}
(As of 2015-07-29.) Here we show only the top 30.
Line 2,154 ⟶ 2,181:
 
Scraping the languages and categories pages.
<langsyntaxhighlight lang="haskell">import Network.Browser
import Network.HTTP
import Network.URI
Line 2,188 ⟶ 2,215:
mapM_ printFmt $ zip [1..] $ sortBy (flip (comparing snd))
$ mapMaybe (toMaybe. (id &&& flip lookup catNmbs)) langs</langsyntaxhighlight>
{{out|First 20}}
<pre>*Main> mostPopLang
Line 2,213 ⟶ 2,240:
 
=={{header|HicEst}}==
<langsyntaxhighlight lang="hicest">CHARACTER cats*50000, catlist*50000, sortedCat*50000, sample*100
DIMENSION RankNr(1)
 
Line 2,245 ⟶ 2,272:
ENDDO
DLG(Text=sortedCat, Format=$CRLF)
END</langsyntaxhighlight>
<langsyntaxhighlight lang="hicest">2010-04-24 18:31
Top 10 entries (not all are languages)
1. 394 Tcl
Line 2,257 ⟶ 2,284:
8. 298 Perl
9. 288 WikiStubs
10. 281 Common Lisp</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
Line 2,263 ⟶ 2,290:
The following solution only works in Unicon.
 
<langsyntaxhighlight lang="unicon">$define RCLANGS "http://rosettacode.org/mw/api.php?format=xml&action=query&generator=categorymembers&gcmtitle=Category:Programming%20Languages&gcmlimit=500&prop=categoryinfo"
$define RCUA "User-Agent: Unicon Rosetta 0.1"
$define RCXUA "X-Unicon: http://unicon.org/"
Line 2,311 ⟶ 2,338:
close(page)
return text
end</langsyntaxhighlight>
 
Abridged output (top 26 languages as of July 30, 2016):
Line 2,347 ⟶ 2,374:
=={{header|J}}==
{{works with|J|6.02 (32 bit only)}}
'''Solution''':<langsyntaxhighlight lang="j">require 'web/gethttp xml/sax/x2j regex'
 
x2jclass 'rcPopLang'
Line 2,364 ⟶ 2,391:
formatTab =: [: ;:^:_1: [: (20 A. (<'-') , |. , [: ('.' <"1@:,.~ ":) 1 + 1 i.@,~ 1{$)&.|: sortTab f.
 
rcPopLangs =: formatTab@:process_rcPopLang_@:gethttp</langsyntaxhighlight>
'''Example''':<langsyntaxhighlight lang="j"> 10 {. rcPopLangs 'http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=2000'
1. 687 - Tcl
2. 646 - Python
Line 2,375 ⟶ 2,402:
8. 550 - D
9. 549 - Mathematica
10. 526 - Perl</langsyntaxhighlight>
'''Notes''': See some [[Talk:Sort most popular programming languages#J|notes on the J solution]].
 
=={{header|Java}}==
Tested with Java 1.7. Uses the api.
<langsyntaxhighlight lang="java">import java.net.URL;
import java.net.URLConnection;
import java.io.*;
Line 2,510 ⟶ 2,537:
} // for lPos
} // main
} // GetRCLanguages</langsyntaxhighlight>
{{out}}
Top 10 languages as at 27th August 2015
Line 2,532 ⟶ 2,559:
 
jq 1.4 cannot retrieve documents over the web and has no support for regular expressions, but is intended to work seamlessly with other command line tools, so the following solution is presented in the form of a bash script that uses curl for retrieval, and grep and sed for screen scraping.
<langsyntaxhighlight lang="sh">#!/bin/bash
 
# produce lines of the form: [ "language", n ]
Line 2,576 ⟶ 2,603:
| reverse
| ranking[]
| "\(.[0]). \(.[1]) - \(.[2])" '</langsyntaxhighlight>
{{out}}
<langsyntaxhighlight lang="sh"># First ten and last ten lines as of May 27, 2015
$ pop.sh
1. 868 - Tcl
Line 2,600 ⟶ 2,627:
386. 1 - Algae
386. 1 - 80386 Assembly
386. 1 - 68000 Assembly</langsyntaxhighlight>
 
=={{header|Julia}}==
Uses the API for the language list and page scraping for the example counts for each language.
<lang julia>using HTTP
<syntaxhighlight lang="julia">""" Rosetta code task rosettacode.org/wiki/Rosetta_Code/Rank_languages_by_popularity """
 
using Dates
try
using DataFrames
response = HTTP.request("GET", "http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000")
using HTTP
langcount = Dict{String, Int}()
using JSON3
for mat in eachmatch(r"<li><a href[^\>]+>([^\<]+)</a>[^1-9]+(\d+)[^\w]+member.?.?</li>", String(response.body))
 
if match(r"^Programming", mat.captures[1]) == nothing
""" Get listing of all tasks and draft tasks with authors and dates created, with the counts as popularity """
langcount[mat.captures[1]] = parse(Int, mat.captures[2])
function rosetta_code_language_example_counts(verbose = false)
URL = "https://rosettacode.org/w/api.php?"
LANGPARAMS = ["action" => "query", "format" => "json", "formatversion" => "2", "generator" => "categorymembers",
"gcmtitle" => "Category:Programming_Languages", "gcmlimit" => "500", "rawcontinue" => "", "prop" => "title"]
queryparams = copy(LANGPARAMS)
df = empty!(DataFrame([[""], [0]], ["ProgrammingLanguage", "ExampleCount"]))
 
while true # get all the languages listed, with curid, eg rosettacode.org/w/index.php?curid=196 for C
resp = HTTP.get(URL * join(map(p -> p[1] * (p[2] == "" ? "" : ("=" * p[2])), queryparams), "&"))
json = JSON3.read(String(resp.body))
pages = json.query.pages
reg = r"The following \d+ pages are in this category, out of ([\d\,]+) total"
for p in pages
lang = replace(p.title, "Category:" => "")
langpage = String(HTTP.get("https://rosettacode.org/w/index.php?curid=" * string(p.pageid)).body)
if !((m = match(reg, langpage)) isa Nothing)
push!(df, [lang, parse(Int, replace(m.captures[1], "," => ""))])
verbose && println("Language: $lang, count: ", m.captures[1])
end
end
!haskey(json, "query-continue") && break # break if no more pages, else continue to next pages
queryparams = vcat(LANGPARAMS, "gcmcontinue" => json["query-continue"]["categorymembers"]["gcmcontinue"])
end
 
langs = sort(collect(keys(langcount)), lt=(x, y)->langcount[x]<langcount[y], rev=true)
return sort!(df, :ExampleCount, rev = true)
for (i, lang) in enumerate(langs)
println("Language $lang can be ranked #$i at $(langcount[lang]).")
end
catch y
println("HTTP request failed: $y.")
exit()
end
</lang>{{out}
<pre>
Language Phix can be ranked #1 at 995.
Language Racket can be ranked #2 at 989.
Language Perl can be ranked #3 at 969.
Language Julia can be ranked #4 at 968.
Language C can be ranked #5 at 944.
Language Tcl can be ranked #6 at 930.
Language Zkl can be ranked #7 at 919.
Language J can be ranked #8 at 905.
Language Java can be ranked #9 at 900.
Language REXX can be ranked #10 at 892.
Language D can be ranked #11 at 874.
Language Ruby can be ranked #12 at 869.
Language Haskell can be ranked #13 at 853.
Language Scala can be ranked #14 at 792.
Language Sidef can be ranked #15 at 788.
Language PicoLisp can be ranked #16 at 775.
Language C sharp can be ranked #17 at 763.
Language Mathematica can be ranked #18 at 743.
Language C++ can be ranked #19 at 738.
Language Common Lisp can be ranked #20 at 667.
Language Ada can be ranked #21 at 656.
Language AutoHotkey can be ranked #22 at 628.
Language JavaScript can be ranked #23 at 619.
Language Lua can be ranked #24 at 618.
Language WikiStubs can be ranked #25 at 614.
...
</pre>
 
println("Top 20 Programming Languages on Rosetta Code by Number of Examples, As of: ", now())
===Julia: Using web scraping===
println(rosetta_code_language_example_counts()[begin:begin+19, :])
{{trans|Python}}
 
<lang Julia>
</syntaxhighlight>{{out}}
using HTTP, Dates
response = HTTP.request("GET", "http://rosettacode.org/wiki/Category:Programming_Languages")
languages = Set(m.captures[1] for m in eachmatch(r"title=\"Category:(.*?)\">",String(response.body)))
response = HTTP.request("GET", "http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000")
response = replace(String(response.body),"," => "")
reg = r"<li><a[^>]+>([^<]+)</a>[^(]*[\(](\d+) member[s]?[)]</li>"
ms = eachmatch(reg,response)
members = [[1,parse(Int,m.captures[2]),m.captures[1]] for m in ms]
filter!(x -> x[3] in languages, members)
sort!(members, by = x -> (-x[2],x[3]))
for i in 2:length(members)
if members[i-1][2] == members[i][2]
members[i][1] = members[i-1][1]
else
members[i][1] = i
end
end
println("Sample output on ", Dates.day(now()), " ", Dates.monthname(now()), " ", Dates.year(now()), ":\n")
for (rank,entries,name) in members[1:10]
println("Rank: ", lpad(rank,4), lpad(" ($entries entries) ",16), name)
end
</lang>
{{out}}
<pre>
Top 20 Programming Languages on Rosetta Code by Number of Examples, As of: 2022-09-05T14:59:56.316
Sample output on 22 July 2019:
20×2 DataFrame
 
Row │ ProgrammingLanguage ExampleCount
Rank: 1 (1154 entries) Go
│ String Int64
Rank: 2 (1089 entries) Perl 6
─────┼───────────────────────────────────
Rank: 3 (1070 entries) Julia
1 │ Wren 1569
Rank: 4 (1066 entries) Python
2 │ Phix 1569
Rank: 5 (1062 entries) Phix
3 │ Julia 1537
Rank: 6 (1045 entries) Kotlin
4 │ Raku 1517
Rank: 7 (1026 entries) Perl
5 │ Go 1496
Rank: 8 (991 entries) Racket
6 │ Perl 1460
Rank: 9 (952 entries) C
7 │ Python 1404
Rank: 10 (945 entries) J
8 │ Nim 1402
9 │ J 1275
10 │ C 1210
11 │ Mathematica 1178
12 │ REXX 1149
13 │ Haskell 1139
14 │ Java 1136
15 │ Kotlin 1133
16 │ C++ 1120
17 │ Ruby 1103
18 │ Racket 1089
19 │ FreeBASIC 1069
20 │ Zkl 1011
</pre>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">import java.net.URL
import java.io.*
 
Line 2,774 ⟶ 2,780:
}
}
}</langsyntaxhighlight>
{{out}}
<pre> 1, 901, Racket
Line 2,786 ⟶ 2,792:
 
=={{header|Lasso}}==
<langsyntaxhighlight Lassolang="lasso"><pre><code>[
sys_listtraits !>> 'xml_tree_trait' ? include('xml_tree.lasso')
local(lang = array)
Line 2,810 ⟶ 2,816:
'. '+#l->second + ' - ' + #l->first+'\r'
^}
]</code></pre></langsyntaxhighlight>
 
{{out}}
Line 2,830 ⟶ 2,836:
Update: Numbers above 999 get a comma (,) so we have to drop this using Filter$()
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module RankLanguages {
Const Part1$="<a href="+""""+ "/wiki/Category", Part2$="member"
Line 2,935 ⟶ 2,941:
}
RankLanguages
</syntaxhighlight>
</lang>
 
{{out}}
Line 3,065 ⟶ 3,071:
 
=={{header|Maple}}==
<langsyntaxhighlight Maplelang="maple">count_sizes := proc(arr_name,arr_pop,i,lst)
local index := i;
local language;
Line 3,095 ⟶ 3,101:
for x from i to 1 by -1 do
printf("rank %d %d examples %s\n", i-x+1, arr_pop[x], arr_name[x]):
end do:</langsyntaxhighlight>
{{Out|Output}}
<pre>#10:30 AM 10/05/2018
Line 3,116 ⟶ 3,122:
rank 685 0 examples Loglan82</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Languages = Flatten[Import["http://rosettacode.org/wiki/Category:Programming_Languages","Data"][[1,1]]];
Languages = Most@StringReplace[Languages, {" " -> "_", "+" -> "%2B"}];
b = {#, If[# === {}, 0, #[[1]]]&@( StringCases[Import["http://rosettacode.org/wiki/Category:"<>#,"Plaintext"],
"category, out of " ~~ x:NumberString ~~ " total" ->x])} &/@ Languages;
For[i = 1, i < Length@b , i++ , Print[i, ". ", #[[2]], " - ", #[[1]] ]&@ Part[Reverse@SortBy[b, Last], i]]</langsyntaxhighlight>
{{out|Output : As of 29 February 2012}}
<pre>
Line 3,137 ⟶ 3,143:
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">import std/[Algorithm, httpclient, json, re, strformat, strutils, algorithm]
 
const
LangSite = "http://www.rosettacode.org/mww/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=json"
CatSite = "http://www.rosettacode.org/mww/index.php?title=Special:Categories&limit=5000"
let regex = re"title=""Category:(.*?)"">.+?</a>.*\((.*) members\)"
 
Line 3,152 ⟶ 3,158:
proc add(langs: var seq[string]; fromJson: JsonNode) =
for entry in fromJson{"query", "categorymembers"}:
langs.addlet title = entry["title"].getStr.split("Category:")[1]
if title.startsWith("Category:"):
langs.add title[9..^1]
 
var client = newHttpClient()
Line 3,177 ⟶ 3,185:
for i, rank in ranks:
echo &"{i + 1:3} {rank.count:4} - {rank.lang}"
</syntaxhighlight>
</lang>
Output:
<pre> 1 13441626 - GoPhix
2 13291620 - PhixWren
3 13231587 - Julia
4 13031574 - Raku
5 12521533 - PerlGo
6 12241520 - PythonPerl
7 11201466 - KotlinPython
8 11091430 - CNim
9 10951348 - JavaJ
10 10661264 - WrenC
11 10641198 - REXXRuby
12 10611185 - RacketMathematica
13 10211164 - JJava
14 10121160 - ZklHaskell
15 10071155 - RubyC++
16 10011153 - C++REXX
17 9931136 - NimKotlin
18 9891131 - HaskellFreeBASIC
19 9661100 - DRacket
20 9611027 - TclJq
21 9151014 - Scala11l
22 8771012 - C sharpZkl
23 8701004 - Sidef
24 852997 - Factor
25 830987 - PicoLispD
26 792980 - LuaTcl
27 780938 - Ada
28 778926 - RustC sharp
29 761923 - MathematicaScala
30 721906 - CommonALGOL Lisp68
31 896 - Rust
32 893 - Lua
33 849 - PicoLisp
34 843 - F Sharp
35 824 - AutoHotkey
36 818 - Ring
37 793 - Delphi
38 785 - JavaScript
39 778 - Arturo
40 776 - XPL0
...</pre>
 
=={{header|Objeck}}==
<langsyntaxhighlight lang="objeck">use HTTP;
use RegEx;
use XML;
Line 3,291 ⟶ 3,309:
};
}
}</langsyntaxhighlight>
 
<pre>1. 849 - Tcl
Line 3,307 ⟶ 3,325:
=={{header|ooRexx}}==
{{trans|REXX}}
<langsyntaxhighlight lang="oorexx">/* REXX ---------------------------------------------------------------
* Create a list of Rosetta Code languages showing the number of tasks
* This program's logic is basically that of the REXX program
Line 3,639 ⟶ 3,657:
If ta<<tb Then res=-1
Else res=1
Return res</langsyntaxhighlight>
 
Output (the beginning):
Line 3,659 ⟶ 3,677:
{{libheader|OzHttpClient}}
Using web scraping. Does not filter non-language categories.
<langsyntaxhighlight lang="oz">declare
[HTTPClient] = {Module.link ['x-ozlib://mesaros/net/HTTPClient.ozf']}
[Regex] = {Module.link ['x-oz://contrib/regex']}
Line 3,698 ⟶ 3,716:
do
{System.showInfo I#". "#Count#" - "#Cat}
end</langsyntaxhighlight>
{{out}}
<pre>
Line 3,715 ⟶ 3,733:
=={{header|Perl}}==
===By using the API===
<langsyntaxhighlight lang="perl">use 5.010;
use MediaWiki::API;
 
my $api =
MediaWiki::API->new( { api_url => 'http://rosettacode.org/mww/api.php' } );
 
my @languages;
Line 3,754 ⟶ 3,772:
$_->{'categoryinfo'}{'size'};
}
</syntaxhighlight>
</lang>
{{out}}
<pre> 1. GoPhix - 11771576
2. PhixWren - 11161569
3. Perl 6Julia - 11071540
4. Julia Raku - 11031520
5. Python Go - 10801500
6. Kotlin Perl - 10531468
7. RacketPython - 10451422
8. Perl Nim - 10451403
9. CJ - 9691278
10. Zkl C - 9601213
...</pre>
 
Line 3,771 ⟶ 3,789:
The distributed version also has an output_html option.
{{libheader|Phix/libcurl}}
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>-- demo\rosetta\Rank_Languages.exw
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Rank_Languages.exw</span>
include builtins\timedate.e
<span style="color: #008080;">constant</span> <span style="color: #000000;">output_users</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">false</span><span style="color: #0000FF;">,</span>
include builtins\libcurl.e
<span style="color: #000000;">limit</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">20</span><span style="color: #0000FF;">,</span> <span style="color: #000080;font-style:italic;">-- 0 to list all</span>
 
<span style="color: #000000;">languages</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"http://rosettacode.org/wiki/Category:Programming_Languages"</span><span style="color: #0000FF;">,</span>
constant output_users = false,
<span style="color: #000000;">categories</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000"</span>
limit = 20, -- 0 to list all
refresh_cache = timedelta(days:=1), -- 0 for always
<span style="color: #008080;">include</span> <span style="color: #000000;">rosettacode_cache</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> <span style="color: #000080;font-style:italic;">-- see [[Rosetta_Code/Count_examples#Phix]]</span>
languages = "http://rosettacode.org/wiki/Category:Programming_Languages",
categories = "http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000"
<span style="color: #008080;">function</span> <span style="color: #000000;">correct_name</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">ri</span><span style="color: #0000FF;">)</span>
 
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`&quot;`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`"`</span><span style="color: #0000FF;">)</span>
function open_download(string filename, url)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`&#039;`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`'`</span><span style="color: #0000FF;">)</span>
bool refetch = true
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xE2\x80\x99"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">)</span>
if file_exists(filename) then
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC3\xB6"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
-- use existing file if <= refresh_cache (1 day) old
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%3A"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">":"</span><span style="color: #0000FF;">)</span>
sequence last_mod = get_file_date(filename) -- (0.8.1+)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%E2%80%93"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"-"</span><span style="color: #0000FF;">)</span>
atom delta = timedate_diff(last_mod,date())
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%E2%80%99"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">)</span>
refetch = (delta>refresh_cache)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%27"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">)</span>
end if
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%2B"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"+"</span><span style="color: #0000FF;">)</span>
if refetch then
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C3%A8"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">)</span>
printf(1,"Downloading %s...\n",{filename})
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C3%A9"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">)</span>
CURLcode res = curl_easy_get_file(url,"",filename) -- (no proxy)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C3%B6"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
if res!=CURLE_OK then
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C5%91"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
string error = sprintf("%d",res)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%22"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`"`</span><span style="color: #0000FF;">)</span>
if res=CURLE_COULDNT_RESOLVE_HOST then
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%2A"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"*"</span><span style="color: #0000FF;">)</span>
error &= " [CURLE_COULDNT_RESOLVE_HOST]"
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC2\xB5"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"u"</span><span style="color: #0000FF;">)</span>
end if
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC3\xA0"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"a"</span><span style="color: #0000FF;">)</span>
printf(1, "Error %s downloading file\n", error)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC3\xA6"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"a"</span><span style="color: #0000FF;">)</span>
{} = wait_key()
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC3\xA9"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">)</span>
abort(0)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC3\xB4"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
end if
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC5\x8D"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
end if
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xCE\x9C"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"u"</span><span style="color: #0000FF;">)</span>
return get_text(filename)
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xD0\x9C\xD0\x9A"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"MK"</span><span style="color: #0000FF;">)</span>
end function
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xE0\xAE\x89\xE0\xAE\xAF\xE0\xAE\xBF\xE0\xAE\xB0\xE0\xAF\x8D/"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">)</span>
 
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"APEX"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Apex"</span><span style="color: #0000FF;">)</span>
constant cat_title = "title=\"Category:"
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"uC++ "</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"UC++"</span><span style="color: #0000FF;">)</span>
 
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`CASIO BASIC`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Casio BASIC`</span><span style="color: #0000FF;">)</span>
function extract_names()
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Visual BASIC`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Visual Basic`</span><span style="color: #0000FF;">)</span>
sequence results = {} -- {rank,count,name}
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`INTERCAL`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Intercal`</span><span style="color: #0000FF;">)</span>
 
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`SETL4`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Setl4`</span><span style="color: #0000FF;">)</span>
-- 1) extract languages from eg title="Category:Phix"
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`QBASIC`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`QBasic`</span><span style="color: #0000FF;">)</span>
sequence language_names = {}
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`RED`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Red`</span><span style="color: #0000FF;">)</span>
string langs = open_download("languages.htm",languages),
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`OCTAVE`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`Octave`</span><span style="color: #0000FF;">)</span>
language_name
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`OoREXX`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`OoRexx`</span><span style="color: #0000FF;">)</span>
langs = langs[1..match("<div class=\"printfooter\">",langs)-1]
<span style="color: #008080;">return</span> <span style="color: #000000;">ri</span>
integer start = match("<h2>Subcategories</h2>",langs), k
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
while true do
k = match(cat_title,langs,start)
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">/</span><span style="color: #000000;">sets</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
if k=0 then exit end if
k += length(cat_title)
<span style="color: #008080;">constant</span> <span style="color: #000000;">cat_title</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">`title="Category:`</span>
start = find('"',langs,k)
language_name = langs[k..start-1]
<span style="color: #008080;">function</span> <span style="color: #000000;">extract_names</span><span style="color: #0000FF;">()</span>
language_names = append(language_names,language_name)
<span style="color: #004080;">sequence</span> <span style="color: #000000;">results</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span> <span style="color: #000080;font-style:italic;">-- {rank,count,name}</span>
end while
 
<span style="color: #008080;">if</span> <span style="color: #7060A8;">get_file_type</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"rc_cache"</span><span style="color: #0000FF;">)!=</span><span style="color: #004600;">FILETYPE_DIRECTORY</span> <span style="color: #008080;">then</span>
-- 2) extract results from eg title="Category:Phix">Phix</a>?? (997 members)</li>
<span style="color: #008080;">if</span> <span style="color: #008080;">not</span> <span style="color: #000000;">create_directory</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"rc_cache"</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
-- but obviously only when we have found that language in the phase above.
<span style="color: #7060A8;">crash</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"cannot create rc_cache directory"</span><span style="color: #0000FF;">)</span>
-- (note there is / ignore some wierd uncode-like stuff after the </a>...)
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
string cats = open_download("categories.htm",categories)
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
start = 1
<span style="color: #000080;font-style:italic;">-- 1) extract languages from eg title="Category:Phix"</span>
while true do
<span style="color: #004080;">sequence</span> <span style="color: #000000;">language_names</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
k = match(cat_title,cats,start)
<span style="color: #004080;">string</span> <span style="color: #000000;">langs</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">open_download</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"languages.htm"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">languages</span><span style="color: #0000FF;">),</span>
if k=0 then exit end if
<span style="color: #000000;">language_name</span>
k += length(cat_title)
<span style="color: #000000;">langs</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">langs</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">..</span><span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #008000;">`&lt;div class="printfooter"&gt;`</span><span style="color: #0000FF;">,</span><span style="color: #000000;">langs</span><span style="color: #0000FF;">)-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
start = find('"',cats,k)
<span style="color: #004080;">integer</span> <span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"&lt;h2&gt;Subcategories&lt;/h2&gt;"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">langs</span><span style="color: #0000FF;">),</span> <span style="color: #000000;">k</span>
language_name = cats[k..start-1]
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span>
start = match("</a>",cats,start)+4
<span style="color: #000000;">k</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cat_title</span><span style="color: #0000FF;">,</span><span style="color: #000000;">langs</span><span style="color: #0000FF;">,</span><span style="color: #000000;">start</span><span style="color: #0000FF;">)</span>
if output_users then
<span style="color: #008080;">if</span> <span style="color: #000000;">k</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
if length(language_name)>5
<span style="color: #000000;">k</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cat_title</span><span style="color: #0000FF;">)</span>
and language_name[-5..-1] = " User" then
<span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'"'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">langs</span><span style="color: #0000FF;">,</span><span style="color: #000000;">k</span><span style="color: #0000FF;">)</span>
language_name = language_name[1..-6]
<span style="color: #000000;">language_name</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">correct_name</span><span style="color: #0000FF;">(</span><span style="color: #000000;">langs</span><span style="color: #0000FF;">[</span><span style="color: #000000;">k</span><span style="color: #0000FF;">..</span><span style="color: #000000;">start</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">])</span>
else
<span style="color: #000000;">language_names</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">language_names</span><span style="color: #0000FF;">,</span><span style="color: #000000;">language_name</span><span style="color: #0000FF;">)</span>
language_name = ""
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
end if
end if
<span style="color: #000080;font-style:italic;">-- 2) extract results from eg title="Category:Phix"&gt;Phix&lt;/a&gt;?? (997 members)&lt;/li&gt;
if length(language_name)
-- but obviously only when we have found that language in the phase above.
and find(language_name,language_names) then
-- (note there is / ignore some wierd uncode-like stuff after the &lt;/a&gt;...)</span>
while not find(cats[start],"(<") do start += 1 end while -- (ignore)
<span style="color: #004080;">string</span> <span style="color: #000000;">cats</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">open_download</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"categories.htm"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">categories</span><span style="color: #0000FF;">)</span>
string members = cats[start..find('<',cats,start+1)]
<span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span>
members = substitute(members,",","")
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span>
sequence res = scanf(members,"(%d member%s)<")
<span style="color: #000000;">k</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cat_title</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cats</span><span style="color: #0000FF;">,</span><span style="color: #000000;">start</span><span style="color: #0000FF;">)</span>
results = append(results,{0,res[1][1],language_name})
<span style="color: #008080;">if</span> <span style="color: #000000;">k</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end if
<span style="color: #000000;">k</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cat_title</span><span style="color: #0000FF;">)</span>
end while
<span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'"'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cats</span><span style="color: #0000FF;">,</span><span style="color: #000000;">k</span><span style="color: #0000FF;">)</span>
results = sort_columns(results,{-2,3}) -- (descending 2nd column, then asc 3rd)
<span style="color: #000000;">language_name</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">correct_name</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cats</span><span style="color: #0000FF;">[</span><span style="color: #000000;">k</span><span style="color: #0000FF;">..</span><span style="color: #000000;">start</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">])</span>
 
<span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"&lt;/a&gt;"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cats</span><span style="color: #0000FF;">,</span><span style="color: #000000;">start</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">4</span>
--3) assign rank
<span style="color: #008080;">if</span> <span style="color: #000000;">output_users</span> <span style="color: #008080;">then</span>
integer count, prev = 0, rank
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">language_name</span><span style="color: #0000FF;">)></span><span style="color: #000000;">5</span>
for i=1 to length(results) do
<span style="color: #008080;">and</span> <span style="color: #000000;">language_name</span><span style="color: #0000FF;">[-</span><span style="color: #000000;">5</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">" User"</span> <span style="color: #008080;">then</span>
count = results[i][2]
<span style="color: #000000;">language_name</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">correct_name</span><span style="color: #0000FF;">(</span><span style="color: #000000;">language_name</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">6</span><span style="color: #0000FF;">])</span>
if count!=prev then rank = i end if
<span style="color: #008080;">else</span>
prev = count
<span style="color: #000000;">language_name</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span>
results[i][1] = rank
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end for
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
 
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">language_name</span><span style="color: #0000FF;">)</span>
return results
<span style="color: #008080;">and</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #000000;">language_name</span><span style="color: #0000FF;">,</span><span style="color: #000000;">language_names</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
end function
<span style="color: #008080;">while</span> <span style="color: #008080;">not</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cats</span><span style="color: #0000FF;">[</span><span style="color: #000000;">start</span><span style="color: #0000FF;">],</span><span style="color: #008000;">"(&lt;"</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span> <span style="color: #000000;">start</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">while</span> <span style="color: #000080;font-style:italic;">-- (ignore)</span>
 
<span style="color: #004080;">string</span> <span style="color: #000000;">members</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">cats</span><span style="color: #0000FF;">[</span><span style="color: #000000;">start</span><span style="color: #0000FF;">..</span><span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'&lt;'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cats</span><span style="color: #0000FF;">,</span><span style="color: #000000;">start</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)]</span>
procedure show(sequence results)
<span style="color: #000000;">members</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">members</span><span style="color: #0000FF;">,</span><span style="color: #008000;">","</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">)</span>
for i=1 to iff(limit?limit:length(results)) do
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">scanf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">members</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"(%d member%s)&lt;"</span><span style="color: #0000FF;">)</span>
printf(1,"%3d: %,d - %s\n",results[i])
<span style="color: #000000;">results</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">results</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">res</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">][</span><span style="color: #000000;">1</span><span style="color: #0000FF;">],</span><span style="color: #000000;">language_name</span><span style="color: #0000FF;">})</span>
end for
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end procedure
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
 
<span style="color: #000000;">results</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sort_columns</span><span style="color: #0000FF;">(</span><span style="color: #000000;">results</span><span style="color: #0000FF;">,{-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">})</span> <span style="color: #000080;font-style:italic;">-- (descending 2nd column, then asc 3rd)
show(extract_names())</lang>
--3) assign rank</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">prev</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">rank</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">results</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">results</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">=</span><span style="color: #000000;">prev</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">results</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"="</span>
<span style="color: #008080;">else</span>
<span style="color: #000000;">rank</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">i</span>
<span style="color: #000000;">results</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprint</span><span style="color: #0000FF;">(</span><span style="color: #000000;">rank</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">prev</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">count</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">results</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">results</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">""</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">limit</span><span style="color: #0000FF;">?</span><span style="color: #000000;">limit</span><span style="color: #0000FF;">:</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">results</span><span style="color: #0000FF;">))</span> <span style="color: #008080;">do</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%3s: %,d - %s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">results</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">show</span><span style="color: #0000FF;">(</span><span style="color: #000000;">extract_names</span><span style="color: #0000FF;">())</span>
<!--</syntaxhighlight>-->
{{out}}
As of July 31st, 2019
Line 3,903 ⟶ 3,947:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(load "@lib/http.l")
 
(for (I . X)
Line 3,916 ⟶ 3,960:
(when (format (till " " T))
(link (cons @ (ht:Pack Cat))) ) ) ) ) ) ) )
(prinl (align 3 I) ". " (car X) " - " (cdr X)) )</langsyntaxhighlight>
{{out|Output (dec15)}}
<pre> 1. 903 - Racket
Line 3,932 ⟶ 3,976:
=={{header|PowerShell}}==
{{trans|C#}}
<syntaxhighlight lang="powershell">
<lang PowerShell>
$get1 = (New-Object Net.WebClient).DownloadString("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=700&format=json")
$get2 = (New-Object Net.WebClient).DownloadString("http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000")
Line 3,960 ⟶ 4,004:
}
}| Format-Table -AutoSize
</syntaxhighlight>
</lang>
<b>Output: August 04, 2015</b>
<pre>
Line 3,998 ⟶ 4,042:
===PowerShell: Using web scraping===
{{trans|Python}}
<syntaxhighlight lang="powershell">
<lang PowerShell>
$response = (New-Object Net.WebClient).DownloadString("http://rosettacode.org/wiki/Category:Programming_Languages")
$languages = [regex]::matches($response,'title="Category:(.*?)">') | foreach {$_.Groups[1].Value}
 
$response = [Net.WebClient]::new().DownloadString("http://rosettacode.org/mww/index.php?title=Special:Categories&limit=5000")
$response = [regex]::Replace($response,'(\d+),(\d+)','$1$2')
 
Line 4,019 ⟶ 4,063:
[String]::Format("Rank: {0,2} {1,15} {2}",$rank,$entry,$_.Language)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 4,033 ⟶ 4,077:
Rank: 9 (970 entries) C
Rank: 10 (960 entries) Zkl
</pre>
 
===PowerShell: Using MediaWiki API method===
{{trans|Python}}
<syntaxhighlight lang="powershell">
$languages = @{}
$Body = @{
format = 'json'
action = 'query'
generator = 'categorymembers'
gcmtitle = 'Category:Programming Languages'
gcmlimit = '200'
gcmcontinue = ''
continue = ''
prop = 'categoryinfo'
}
$params = @{
Method = 'Get'
Uri = 'http://rosettacode.org/mw/api.php'
Body = $Body
}
while ($true) {
$response = Invoke-RestMethod @params
$response.query.pages.PSObject.Properties | ForEach-Object {
if (($_.value.PSObject.Properties.Name -Contains 'title') -and ($_.value.PSObject.Properties.Name -Contains 'categoryinfo')) {
$languages[$_.value.title.replace('Category:', '')] = $_.value.categoryinfo.size
}
}
if ($response.PSObject.Properties.Name -Contains 'continue') {
$gcmcontinue = $response.continue.gcmcontinue
$params.Body.gcmcontinue = $gcmcontinue
} else {
break
}
}
$members = $languages.GetEnumerator() | sort -Descending value
Get-Date -UFormat "Sample output on %d %B %Y at %R %Z"
$members | Select-Object -First 10 | foreach -Begin {$r, $rank, $count = 0, 0,-1} {
$r++
if ($count -ne $_.Members) {$rank = $r}
$count = $_.Value
$x = $_.Value.ToString("N0",[System.Globalization.CultureInfo]::CreateSpecificCulture('en-US'))
$entry = "($x entries)"
[String]::Format("Rank: {0,2} {1,15} {2}",$rank, $entry, $_.Name)
}
</syntaxhighlight>
{{out}}
<pre>
Sample output on 05 juillet 2022 at 19:53 +02
Rank: 1 (1,552 entries) Phix
Rank: 2 (1,545 entries) Wren
Rank: 3 (1,521 entries) Julia
Rank: 4 (1,498 entries) Go
Rank: 5 (1,497 entries) Raku
Rank: 6 (1,456 entries) Perl
Rank: 7 (1,402 entries) Nim
Rank: 8 (1,401 entries) Python
Rank: 9 (1,206 entries) C
Rank: 10 (1,180 entries) J
</pre>
 
=={{header|PureBasic}}==
===Using MediaWiki API method===
<langsyntaxhighlight lang="purebasic">Procedure handleError(value, msg.s)
If value = 0
MessageRequester("Error", msg)
Line 4,164 ⟶ 4,267:
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf</langsyntaxhighlight>
Sample output:
<pre>608 languages.
Line 4,232 ⟶ 4,335:
 
===Using web scraping method===
<langsyntaxhighlight lang="purebasic">
;Uses a web scraping method.
 
Line 4,288 ⟶ 4,391:
PrintN( Str(i + 1) + ". " + Str(Row(i)\count) + " - " + Row(i)\Name)
Next
Input()</langsyntaxhighlight>
Sample output:
<pre>1. 907 - Racket
Line 4,326 ⟶ 4,429:
Using <code>requests</code> library.
 
<langsyntaxhighlight lang="python">import requests
import re
 
Line 4,340 ⟶ 4,443:
print("{:4d} {:4d} - {}".format(cnt+1, int(members), language))
 
</syntaxhighlight>
</lang>
{{out|Output (as of Dec 21, 2020)}}
1 1306 - Go
Line 4,359 ⟶ 4,462:
 
===Python: Using MediaWiki API method===
<langsyntaxhighlight lang="python">
import requests
import operator
Line 4,395 ⟶ 4,498:
 
 
</syntaxhighlight>
</lang>
{{out|Output (as of Dec 21, 2020)}}
1 1306 - Go
Line 4,414 ⟶ 4,517:
 
=={{header|R}}==
 
{{incorrect|R|I believe you need to use <tt>continue gcmcontinue</tt> to get complete results.}}
<langsyntaxhighlight lang="rsplus">
library(rvest)
library(plyr)
library(dplyr)
options(stringsAsFactors=FALSE)
 
# getting the required table from the rosetta website
langUrl <- "http://rosettacode.org/mw/api.php?format=xml&action=query&generator=categorymembers&gcmtitle=Category:Programming%20Languages&prop=categoryinfo&gcmlimit=5000"
langUrl <- "https://rosettacode.org/wiki/Rosetta_Code/Rank_languages_by_popularity/Full_list"
langs <- html(langUrl) %>%
langs <- read_html(langUrl) %>%
html_nodes('page')
html_nodes(xpath='/html/body/div/div/div[1]/div[3]/main/div[2]/div[3]/div[1]/table') %>%
html_table() %>%
data.frame() %>%
select(c("Rank","TaskEntries","Language"))
 
 
ff <- function(xml_node) {
# changing the columns to required format
language <- xml_node %>% html_attr("title")
langs$Rank = paste("Rank: ",langs$Rank)
language <- sub("^Category:", "", language)
langs$TaskEntries = paste0("(", format(langs$TaskEntries, big.mark = ",")
npages <- xml_node %>% html_nodes('categoryinfo') %>%
," entries", ")")
html_attr("pages")
 
c(language, npages)
names(langs) <- NULL
}
 
tbl <- ldply(sapply(langs, ff), rbind)
langs[1:10,]
names(tbl) <- c("language", "n")
 
tbl %>%
</syntaxhighlight>
mutate(n=as.integer(n)) %>%
{{out|Output (as of October, 24, 2022)}}
arrange(desc(n)) %>%
head
</lang>
{{out|Output (as of March, 23, 2019)}}
<pre>
1 Rank: 1 (1,589 entries) Phix
language n
12 Rank: 1 (1,589 entries) Go 1114Wren
3 Rank: 3 (1,552 entries) Julia
2 Perl 6 1059
4 Rank: 4 (1,535 entries) Raku
3 Kotlin 1029
5 Rank: 5 (1,500 entries) Go
4 Phix 993
6 Rank: 6 (1,485 entries) Perl
5 Julia 992
7 Rank: 7 (1,422 entries) Python
6 Perl 978
8 Rank: 8 (1,402 entries) Nim
9 Rank: 9 (1,293 entries) J
10 Rank: 10 (1,213 entries) C
</pre>
 
Line 4,454 ⟶ 4,560:
{{trans|Python}}
 
<langsyntaxhighlight lang="racket">#lang racket
(require racket/hash
Line 4,496 ⟶ 4,602:
(~a (format "(~a ~a)" size entries) #:align 'right #:min-width 14)
(replacer cat))
(values size this-rank))</langsyntaxhighlight>
 
Output on September 4, 2019:
Line 4,527 ⟶ 4,633:
Note that this counts '''only''' the tasks. It does not include other non-task categories in the counts yielding more realistic, non-inflated numbers. Raku is Unicode aware and handles non-ASCII names natively. This does not attempt to 'unify' different language names that are the same behind the scenes as a result of Rosettacodes' capitalization peculiarities. (E.G. μC++, UC++ & ΜC++)
 
<syntaxhighlight lang="raku" perl6line>use HTTP::UserAgent;
use URI::Escape;
use JSON::Fast;
Line 4,534 ⟶ 4,640:
my $client = HTTP::UserAgent.new;
 
my $url = 'httphttps://rosettacode.org/mww';
 
my $tablefile = './RC_Popularity.txt';
Line 4,625 ⟶ 4,731:
sub uri-query-string (*%fields) {
join '&', %fields.map: { "{.key}={uri-escape .value}" }
}</langsyntaxhighlight>
 
{{out|Abridged output}} See [[Rosetta_Code/Rank_languages_by_popularity/Full_list|full output here]].
Line 4,776 ⟶ 4,882:
 
Scraping the languages and categories pages. Raku automatically handles Unicode names correctly.
<syntaxhighlight lang="raku" perl6line>my $languages = qx{wget -O - 'http://rosettacode.org/wiki/Category:Programming_Languages'};
my $categories = qx{wget -O - 'http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000'};
Line 4,797 ⟶ 4,903:
for @results.kv -> $i, @l {
printf "%d:\t%4d - %s\n", $i+1, |@l;
}</langsyntaxhighlight>
{{out}}
(As of 2018-10-28) Here we show only the top 10.
Line 4,813 ⟶ 4,919:
=={{header|Red}}==
proccesses only languages with more than 25 entries to keep the list short
<langsyntaxhighlight Redlang="red">Red []
 
data: read http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000
Line 4,864 ⟶ 4,970:
head? lb ;; until head reached
]
</syntaxhighlight>
</lang>
Output: (30.12.2017)
<pre>
Line 4,928 ⟶ 5,034:
This REXX version sorts the &nbsp; tied &nbsp; languages by language name.
===REXX program===
<langsyntaxhighlight lang="rexx">/*REXX program reads two files and displays a ranked list of Rosetta Code languages.*/
parse arg catFID lanFID outFID . /*obtain optional arguments from the CL*/
call init /*initialize some REXX variables. */
Line 5,039 ⟶ 5,145:
if #.j==#.jp then do; tR= pR; !tR.j= pR; end
else pR= r
end /*j*/; return</langsyntaxhighlight>
 
===all ranked 809813 languages===
The '''output''' &nbsp; for this REXX (RC_POP.REX) program is included here &nbsp; ──► &nbsp; [[RC_POP.OUT]].
 
Line 5,049 ⟶ 5,155:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project: Rosetta Code/Rank languages by popularity
Line 5,136 ⟶ 5,242:
next
return alist
</syntaxhighlight>
</lang>
Output:
<pre>
Line 5,170 ⟶ 5,276:
 
Uses the <code>RosettaCode</code> module from [[Count programming examples#Ruby]]
<langsyntaxhighlight lang="ruby">require 'rosettacode'
 
langs = []
Line 5,199 ⟶ 5,305:
langcount.sort_by {|key,val| val}.reverse[0,25].each_with_index do |(lang, count), i|
puts "#{i+1}. #{count} - #{lang.sub(/Category:/, '')}"
end</langsyntaxhighlight>
{{out|Results}}
<pre style="height: 40ex; overflow: scroll">2010-07-08 14:52:46 -0500
Line 5,231 ⟶ 5,337:
 
=={{header|Run BASIC}}==
<langsyntaxhighlight lang="runbasic">sqliteconnect #mem, ":memory:" ' make memory DB
#mem execute("CREATE TABLE stats(lang,cnt)")
a$ = httpGet$("http://rosettacode.org/wiki/Category:Programming_Languages")
Line 5,258 ⟶ 5,364:
html "<TR><TD align=right>";rank;"</td><td>";#row lang$();"</td><td align=right>";#row cnt();"</td></tr>"
WEND
html "</table>"</langsyntaxhighlight>
<table border=2>
<TR><TD align=right>1</td><td>Tcl</td><td align=right>687</td></tr>
Line 5,294 ⟶ 5,400:
===Parallel internet querying===
Entry point @ object <code>GhettoParserPar</code>
<langsyntaxhighlight lang="scala">import akka.actor.{Actor, ActorSystem, Props}
import scala.collection.immutable.TreeSet
import scala.xml.XML
Line 5,438 ⟶ 5,544:
Concurrent.logInfo("Parallel version started")
ActorSystem("Main").actorOf(Props[Concurrent.Listener])
}</langsyntaxhighlight>
 
===Sequential internet querying===
Line 5,509 ⟶ 5,615:
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "gethttp.s7i";
include "scanstri.s7i";
Line 5,566 ⟶ 5,672:
place +:= length(ranking[numList[listIdx]]);
end for;
end func;</langsyntaxhighlight>
 
List of languages as of 2014-01-15:
Line 5,605 ⟶ 5,711:
=={{header|Sidef}}==
{{trans|Perl}}
<langsyntaxhighlight lang="ruby">require('MediaWiki::API')
 
var api = %O<MediaWiki::API>.new(
Line 5,641 ⟶ 5,747:
sorted_languages.each_kv { |i, lang|
printf("%3d. %20s - %3d\n", i+1, lang{:title}, lang{:categoryinfo}{:size})
}</langsyntaxhighlight>
{{out}}
<pre>
Line 5,666 ⟶ 5,772:
=={{header|SNOBOL4}}==
{{Works with|SNOBOL4|CSNOBOL4 CVS test}}
<langsyntaxhighlight SNOBOL4lang="snobol4">-include "url.sno"
http.recl = "K,32767" ;* Read next 32767 characters
;* of very long lines.
Line 5,685 ⟶ 5,791:
read line = line fin :f(done)
get line languagepat = :f(read)
langtable<syntaxhighlight lang="text"> = langtable<syntaxhighlight lang="text"> + count :(get)
done langarray = rsort(langtable,2) :s(write)
Line 5,695 ⟶ 5,801:
url.close(.fin)
end</langsyntaxhighlight>
 
'''Abridged output (top 30 languages as of August 25, 2015):'''
Line 5,734 ⟶ 5,840:
First we build the database:
 
<langsyntaxhighlight lang="stata">copy "http://rosettacode.org/wiki/Category:Programming_Languages" lang.html, replace
import delimited lang.html, delim("@") enc("utf-8") clear
keep if ustrpos(v1,"/wiki/Category:")
Line 5,768 ⟶ 5,874:
gen rank=1
replace rank=rank[_n-1]+(count[_n]!=count[_n-1]) in 2/l
save tasks, replace</langsyntaxhighlight>
 
Now some results, as of 2017-12-03:
 
<langsyntaxhighlight lang="stata">* Total number of entries
qui sum n
di r(sum)
Line 5,802 ⟶ 5,908:
| Ruby 845 9 |
| Go 828 10 |
+-----------------------+</langsyntaxhighlight>
 
=={{header|Tcl}}==
===By web scraping===
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require http
Line 5,845 ⟶ 5,951:
lassign $entry num lang
puts [format "%d. %d - %s" [incr i] $num $lang]
}</langsyntaxhighlight>
{{out|Output on 29 July 2015 (top 20 entries only)}}
<pre>1. 887 - Tcl
Line 5,874 ⟶ 5,980:
{{libheader|tDOM}}
 
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require http
package require tdom
Line 5,983 ⟶ 6,089:
}
 
popreport $langcounts</langsyntaxhighlight>
 
{{out}}
Line 6,009 ⟶ 6,115:
 
=={{header|TUSCRIPT}}==
<langsyntaxhighlight lang="tuscript">$$ MODE TUSCRIPT
remotedata = REQUEST ("http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000")
allmembers=allnames=""
Line 6,057 ⟶ 6,163:
balt=b
ENDLOOP
ENDCOMPILE</langsyntaxhighlight>
{{out}}
<pre style='height:30ex;overflow:scroll'>
Line 6,102 ⟶ 6,208:
 
{{libheader|curl}}
<langsyntaxhighlight lang="bash">curl 'http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000' |
sed -nre 's/^<li.*title="Category:([^"(]+)".*\(([0-9]+) members\).*/\2 - \1/p' |
sort -nr | awk '{printf "%2d. %s\n",NR,$0}'</langsyntaxhighlight>
 
=={{header|VBScript}}==
Uses the API. Instead of displaying it on the command prompt, the records of the languages are saved on a text file "OutVBRC.txt" encoded with Unicode.
<langsyntaxhighlight lang="vb"> '''''''''''''''''''''''''''''''''''''''''''''
' Rosetta Code/Rank Languages by Popularity '
' VBScript Implementation '
Line 6,225 ⟶ 6,331:
Set HTML = Nothing
Set objFSO = Nothing
WScript.Quit(0)</langsyntaxhighlight>
{{Out|Some Parts of Output as of December 31, 2016}}
<pre>As of 12/31/2016 11:52:05 PM, RC has 624 languages.
Line 6,255 ⟶ 6,361:
0 Examples - WML
0 Examples - VAX Assembly</pre>
 
=={{header|Visual Basic .NET}}==
Uses Web scrapping to get the information from the Languages category page - as this now shows the number of pages in each category with the non-task pages separated, there is no need to access other pages.<br>
It may be necessary to set the Security Protocol to Tls12 at the start of the Main method in order to run this - see the "Problem running the C# entry" section on the [[Talk:Rosetta Code/Count examples]] page.
<syntaxhighlight lang="vbnet">
Imports System.Collections
Imports System.Collections.Generic
Imports System.Net
Imports System.Text.RegularExpressions
 
Module RankLanguagesByPopularity
 
Private Class LanguageStat
Public name As String
Public count As Integer
Public Sub New(name As String, count As Integer)
Me.name = name
Me.count = count
End Sub
End Class
 
Private Function CompareLanguages(x As LanguageStat, y As languageStat) As Integer
Dim result As Integer = 0
If x IsNot Nothing Or y IsNot Nothing Then
If x Is Nothing Then
result = -1
ElseIf y Is Nothing
result = 1
Else
result = - x.count.CompareTo(y.count) ' Sort descending count
If result = 0 Then
result = x.name.CompareTo(y.name) ' Sort ascending name
End If
End If
End If
Return result
End Function
 
Public Sub Main(ByVal args As String())
 
Dim languages As New List(Of LanguageStat)
Dim basePage As String = "https://rosettacode.org/wiki/Category:Programming_Languages"
Dim nextPage As String = basePage
 
Dim nextPageEx = New RegEx("<a href=""/wiki/Category:Programming_Languages([?]subcatfrom=[^""]*)""")
Dim languageStatEx = _
New Regex(">([^<]+?)</a>[^<]*<span title=""Contains *[0-9,.]* *[a-z]*, *([0-9,.]*) *page")
 
Do While nextPage <> ""
Dim wc As New WebClient()
Dim page As String = wc.DownloadString(nextPage)
 
nextPage = ""
For Each link In nextPageEx.Matches(page)
nextPage = basePage & link.Groups(1).Value
Next link
 
For Each language In languageStatEx.Matches(page)
Dim lCount As Integer = 0
Dim lName As String = language.Groups(1).Value
Dim countText As String = language.Groups(2).Value.Replace(",", "").Replace(".", "")
If Not Integer.TryParse(countText, lCount)
Console.Out.WriteLine(lName & "Invalid page count: <<" & countText & ">>")
Else
languages.Add(New LanguageStat(lName, lCount))
End If
Next language
Loop
 
languages.Sort(AddressOf CompareLanguages)
 
Dim prevCount As Integer = -1
Dim prevPosition As Integer = -1
Dim position As Integer = 0
For Each stat As LanguageStat In languages
position += 1
If stat.count <> prevCount Then
prevPosition = position
prevCount = stat.Count
End If
Console.Out.WriteLine(prevPosition.ToString.PadLeft(4) & ": " &
stat.count.ToString.PadLeft(4) & " " & stat.name)
Next stat
 
End Sub
 
End Module
</syntaxhighlight>
{{out}}
Sample output as at 11th September 2023
<pre>
1: 1652 Phix
1: 1652 Wren
3: 1614 Julia
4: 1595 Raku
5: 1576 Nim
6: 1546 Go
7: 1531 Perl
8: 1470 Python
9: 1375 J
10: 1285 C
. . .
</pre>
 
=={{header|Wren}}==
{{libheader|libcurl}}
{{libheader|Wren-pattern}}
{{libheader|Wren-fmt}}
An embedded program so we can use libcurl.
<syntaxhighlight lang="wren">/* Rosetta_Code_Rank_languages_by_popularity.wren */
 
import "./pattern" for Pattern
import "./fmt" for Fmt
 
var CURLOPT_URL = 10002
var CURLOPT_FOLLOWLOCATION = 52
var CURLOPT_WRITEFUNCTION = 20011
var CURLOPT_WRITEDATA = 10001
 
foreign class Buffer {
construct new() {} // C will allocate buffer of a suitable size
 
foreign value // returns buffer contents as a string
}
 
foreign class Curl {
construct easyInit() {}
 
foreign easySetOpt(opt, param)
 
foreign easyPerform()
 
foreign easyCleanup()
}
 
var curl = Curl.easyInit()
 
var getContent = Fn.new { |url|
var buffer = Buffer.new()
curl.easySetOpt(CURLOPT_URL, url)
curl.easySetOpt(CURLOPT_FOLLOWLOCATION, 1)
curl.easySetOpt(CURLOPT_WRITEFUNCTION, 0) // write function to be supplied by C
curl.easySetOpt(CURLOPT_WRITEDATA, buffer)
curl.easyPerform()
return buffer.value
}
 
var p1 = Pattern.new("> <a href/=\"//wiki//Category:+1^\"\" title/=\"Category:[+1^\"]\">+1^,, [+1^ ] page")
var p2 = Pattern.new("subcatfrom/=[+1^#/#mw-subcategories]\"")
 
var findLangs = Fn.new {
var url = "https://rosettacode.org/w/index.php?title=Category:Programming_Languages"
var subcatfrom = ""
var langs = []
while (true) {
var content = getContent.call(url + subcatfrom)
var matches1 = p1.findAll(content)
for (m in matches1) {
var name = m.capsText[0]
var tasks = Num.fromString(m.capsText[1].replace(",", ""))
langs.add([name, tasks])
}
var m2 = p2.find(content)
if (m2) subcatfrom = "&subcatfrom=%(m2.capsText[0])" else break
}
return langs
}
 
var langs = findLangs.call()
langs.sort { |a, b| a[1] > b[1] }
System.print("Languages with most examples as at 3 February, 2024:")
var rank = 0
var lastScore = 0
var lastRank = 0
for (i in 0...langs.count) {
var pair = langs[i]
var eq = " "
rank = i + 1
if (lastScore == pair[1]) {
eq = "="
rank = lastRank
} else {
lastScore = pair[1]
lastRank = rank
}
Fmt.print("$-3d$s $-20s $,5d", rank, eq, pair[0], pair[1])
}</syntaxhighlight>
<br>
We now embed this script in the following C program, build and run.
<syntaxhighlight lang="c">/* gcc Rosetta_Code_Rank_languages_by_popularity.c -o Rosetta_Code_Rank_languages_by_popularity -lcurl -lwren -lm */
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include "wren.h"
 
struct MemoryStruct {
char *memory;
size_t size;
};
 
/* C <=> Wren interface functions */
 
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
if(!ptr) {
/* out of memory! */
printf("not enough memory (realloc returned NULL)\n");
return 0;
}
 
mem->memory = ptr;
memcpy(&(mem->memory[mem->size]), contents, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
return realsize;
}
 
void C_bufferAllocate(WrenVM* vm) {
struct MemoryStruct *ms = (struct MemoryStruct *)wrenSetSlotNewForeign(vm, 0, 0, sizeof(struct MemoryStruct));
ms->memory = malloc(1);
ms->size = 0;
}
 
void C_bufferFinalize(void* data) {
struct MemoryStruct *ms = (struct MemoryStruct *)data;
free(ms->memory);
}
 
void C_curlAllocate(WrenVM* vm) {
CURL** pcurl = (CURL**)wrenSetSlotNewForeign(vm, 0, 0, sizeof(CURL*));
*pcurl = curl_easy_init();
}
 
void C_value(WrenVM* vm) {
struct MemoryStruct *ms = (struct MemoryStruct *)wrenGetSlotForeign(vm, 0);
wrenSetSlotString(vm, 0, ms->memory);
}
 
void C_easyPerform(WrenVM* vm) {
CURL* curl = *(CURL**)wrenGetSlotForeign(vm, 0);
curl_easy_perform(curl);
}
 
void C_easyCleanup(WrenVM* vm) {
CURL* curl = *(CURL**)wrenGetSlotForeign(vm, 0);
curl_easy_cleanup(curl);
}
 
void C_easySetOpt(WrenVM* vm) {
CURL* curl = *(CURL**)wrenGetSlotForeign(vm, 0);
CURLoption opt = (CURLoption)wrenGetSlotDouble(vm, 1);
if (opt < 10000) {
long lparam = (long)wrenGetSlotDouble(vm, 2);
curl_easy_setopt(curl, opt, lparam);
} else if (opt < 20000) {
if (opt == CURLOPT_WRITEDATA) {
struct MemoryStruct *ms = (struct MemoryStruct *)wrenGetSlotForeign(vm, 2);
curl_easy_setopt(curl, opt, (void *)ms);
} else if (opt == CURLOPT_URL) {
const char *url = wrenGetSlotString(vm, 2);
curl_easy_setopt(curl, opt, url);
}
} else if (opt < 30000) {
if (opt == CURLOPT_WRITEFUNCTION) {
curl_easy_setopt(curl, opt, &WriteMemoryCallback);
}
}
}
 
WrenForeignClassMethods bindForeignClass(WrenVM* vm, const char* module, const char* className) {
WrenForeignClassMethods methods;
methods.allocate = NULL;
methods.finalize = NULL;
if (strcmp(module, "main") == 0) {
if (strcmp(className, "Buffer") == 0) {
methods.allocate = C_bufferAllocate;
methods.finalize = C_bufferFinalize;
} else if (strcmp(className, "Curl") == 0) {
methods.allocate = C_curlAllocate;
}
}
return methods;
}
 
WrenForeignMethodFn bindForeignMethod(
WrenVM* vm,
const char* module,
const char* className,
bool isStatic,
const char* signature) {
if (strcmp(module, "main") == 0) {
if (strcmp(className, "Buffer") == 0) {
if (!isStatic && strcmp(signature, "value") == 0) return C_value;
} else if (strcmp(className, "Curl") == 0) {
if (!isStatic && strcmp(signature, "easySetOpt(_,_)") == 0) return C_easySetOpt;
if (!isStatic && strcmp(signature, "easyPerform()") == 0) return C_easyPerform;
if (!isStatic && strcmp(signature, "easyCleanup()") == 0) return C_easyCleanup;
}
}
return NULL;
}
 
static void writeFn(WrenVM* vm, const char* text) {
printf("%s", text);
}
 
void errorFn(WrenVM* vm, WrenErrorType errorType, const char* module, const int line, const char* msg) {
switch (errorType) {
case WREN_ERROR_COMPILE:
printf("[%s line %d] [Error] %s\n", module, line, msg);
break;
case WREN_ERROR_STACK_TRACE:
printf("[%s line %d] in %s\n", module, line, msg);
break;
case WREN_ERROR_RUNTIME:
printf("[Runtime Error] %s\n", msg);
break;
}
}
 
char *readFile(const char *fileName) {
FILE *f = fopen(fileName, "r");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
rewind(f);
char *script = malloc(fsize + 1);
fread(script, 1, fsize, f);
fclose(f);
script[fsize] = 0;
return script;
}
 
static void loadModuleComplete(WrenVM* vm, const char* module, WrenLoadModuleResult result) {
if( result.source) free((void*)result.source);
}
 
WrenLoadModuleResult loadModule(WrenVM* vm, const char* name) {
WrenLoadModuleResult result = {0};
if (strcmp(name, "random") != 0 && strcmp(name, "meta") != 0) {
result.onComplete = loadModuleComplete;
char fullName[strlen(name) + 6];
strcpy(fullName, name);
strcat(fullName, ".wren");
result.source = readFile(fullName);
}
return result;
}
 
int main(int argc, char **argv) {
WrenConfiguration config;
wrenInitConfiguration(&config);
config.writeFn = &writeFn;
config.errorFn = &errorFn;
config.bindForeignClassFn = &bindForeignClass;
config.bindForeignMethodFn = &bindForeignMethod;
config.loadModuleFn = &loadModule;
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "Rosetta_Code_Rank_languages_by_popularity.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
switch (result) {
case WREN_RESULT_COMPILE_ERROR:
printf("Compile Error!\n");
break;
case WREN_RESULT_RUNTIME_ERROR:
printf("Runtime Error!\n");
break;
case WREN_RESULT_SUCCESS:
break;
}
wrenFreeVM(vm);
free(script);
return 0;
}</syntaxhighlight>
 
{{out}}
Showing just the top thirty.
<pre>
Languages with most examples as at 3 February, 2024:
1 Wren 1,665
1 = Phix 1,665
3 Julia 1,638
4 Raku 1,608
5 Nim 1,576
6 Go 1,547
7 Perl 1,540
8 Python 1,497
9 J 1,413
10 Java 1,318
11 C 1,293
12 C++ 1,258
13 Ruby 1,235
14 Mathematica 1,200
15 FreeBASIC 1,185
16 Haskell 1,166
17 REXX 1,152
18 Kotlin 1,143
19 Racket 1,099
20 Jq 1,081
21 Sidef 1,051
22 11l 1,016
23 Zkl 1,011
24 Factor 1,001
25 D 990
26 ALGOL 68 986
27 Tcl 983
28 Scala 948
29 Delphi 945
30 Ada 940
30 = Rust 940
</pre>
 
=={{header|zkl}}==
Line 6,261 ⟶ 6,784:
This solution using the API as the web scraping URL is pretty slow.
I'm using JSON as format=txt has been deprecated.
<langsyntaxhighlight lang="zkl">var [const] CURL=Import("zklCurl"), YAJL=Import("zklYAJL")[0];
 
fcn getLangCounts(language){ // -->( (count,lang), ...)
Line 6,298 ⟶ 6,821:
println("Most popular Rosetta Code languages as of ",Time.Date.prettyDay());
foreach n,name in ([1..15].zip(langCounts))
{ println("%2d: %3d %s".fmt(n,name.xplode())) }</langsyntaxhighlight>
{{out}}
<pre>
9,476

edits