Jump to content

Rosetta Code/Rank languages by number of users: Difference between revisions

m (→‎{{header|Wren}}: Minor tidy)
Line 161:
44= 25 AutoHotkey
44= 25 REXX
</pre>
 
=={{header|jq}}==
'''Works with jq, the C implementation of jq'''
 
'''Works with gojq, the Go implementation of jq'''
 
jq does not currently provide support for retrieving content from the Internet,
but is intended to interoperate with standard command-line tools,
so for this example we'll assume a command line invocation along
the lines of the following:
<pre>
curl -sS "https://rosettacode.org/w/api.php?action=query&format=json&formatversion=2&generator=categorymembers&gcmtitle=Category:Language%20users&gcmlimit=500&rawcontinue&prop=categoryinfo" |
jq -rf users.jq
</pre>
where "users.jq" contains the jq program shown below.
<syntaxhighlight lang="jq">
def rpad($len): tostring | ($len - length) as $l | . + (" " * $l);
 
def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .;
 
def cat: sub("Category:";"") | sub(" User$";"");
"As of \(now | strftime("%A %B %d, %Y %Z %H:%M") ):",
"\n\("Language" | rpad(30)) Users",
"_" * 36,
([.query.pages[] | {title, n: .categoryinfo.size}]
| sort_by(.n) | reverse | .[:10][]
| "\(.title | cat | rpad(30)) \(.n|lpad(5))" )
</syntaxhighlight>
{{output}}
<pre>
As of Tuesday June 25, 2024 EST 06:52:
 
Language Users
____________________________________
C 468
Python 344
Java 343
C++ 330
JavaScript 307
PHP 200
Perl 195
SQL 177
UNIX Shell 160
Pascal 139
</pre>
 
2,502

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.