Talk:Rosetta Code/Rank languages by popularity

From Rosetta Code

Incorrect examples

ALL examples, except Python "Working Solution" are not working. Please fix. --Guga360 03:49, 29 July 2009 (UTC)

How, exactly, are all other solutions "not working"? Please elaborate. --glennj 10:12, 2 August 2009 (UTC)
Attempting the Python "Working Solution", I'm getting this error using python 2.5.2 --glennj 10:14, 2 August 2009 (UTC)
 $ python rosetta_popular.py
Traceback (most recent call last):
  File "rosetta_popular.py", line 18, in <module>
    for n, i in enumerate(sorted(result,key=lambda x: x[1],reverse=True),start=1):
TypeError: 'start' is an invalid keyword argument for this function
You need Python 2.6. "Not working" examples are only grabbing 500 categories, programming languages like Tcl or Visual Basic don't get in top 10. --Guga360 16:48, 2 August 2009 (UTC)
Actually, the Python implementation isn't correct, either. It omits, for example, AutoHotkey and LotusScript. Compare it with the Perl output. —Underscore 16:16, 30 October 2009 (UTC)

ALGOL 68

I tested ALGOL 68 (I'm using release algol68g-mk16.win32), but it did not worked. Do I need a library? --Guga360 22:19, 18 April 2009 (UTC)

PS: I'm currently on Windows, i'll try to restart in Ubuntu later.

Error:

39 http content (reply, "www.rosettacode.org", "http://www.rosettacode.org/w /index.php?title=Special:Categories&limit=500", 0); 1 a68g16.exe: error: 1: tag "httpcontent" has not been declared properly (detected in c onditional-clause starting at "IF" in line 37).

I think it's really a library. But i never programmed in ALGOL, what should i do?

Guga360 08:24, 19 April 2009

Hi Guya360,

This ALGOL 68 implementation is an interpretor, and it would require the library being linked into the a68g.exe binary. Hence the .exe you have definitely does not have "http content" linked in.

I ran it on Fedora9 OK. I just checked a68g-manual.pdf and it says:

Mark 8, July 2005

  1. Adds procedure http content for fetching web page contents (UNIX)
  2. Adds procedure tcp request for sending requests via TCP (UNIX)
  3. Adds procedure grep in string for matching regular expressions in a string (UNIX)

The key point being the (UNIX) at the end of the line. I am guessing that the tcp library for windows was enough different from the tcp library for Linux/Unix that the "http content" routine remains both un-ported and broken.

Now I have not tried Algol68g on Ubuntu. I hack around on Fedora. So you MAY be able to use the pre-compiled algol68g RPM for ubuntu (Does Ubuntu support RPMs?)

BUT the algol68g source tar ball will definitely work on ubuntu. (Maybe not on a 64bit Ubuntu as the libraries have moved to /lib64 - if so let me know and I'll sort/hack you up a 64bit update)

The compile should be as easy as installing gcc and configure (and if you need them then install postgres or curses or ... ) then:

tar -xvf /tmp/download/algol68g-mk16.tgz
./configure --threads
make 
# as root
make install
# as user
a68g Sort_most_popular_programming_languages.a68

BTW: you are the first person to feed back on running the ALGOL 68 rosettacode code snippets... I am rather impressed. ThanX - (blush)

Is this snippet the first ALGOL 68 that you have tried?

NevilleDNZ 08:40, 19 April 2009 (UTC)

Yes, it's my first try.
I just found that example intersting because it does not use [[1]].
I compiled algol68g right now. (./configure && make && sudo make install)
It compiled perfectly.
But i runned that example, and nothing happened. It's just "loading".
Any suggestions? --Guga360 16:08, 19 April 2009 (UTC)

I am guessing that you program is running, just really slow, give it 2 minutes to run. Basically the routine re split used to parse the HTML is really slow. re split's performance is the order of O2.

I just recoded the ALGOL 68 version to use a linked list, it is a huge improvement:

[nevilled@november rosettacode]$ time  a68g Sort_most_popular_programming_languages_slow.a68 
1. 233 - Python
2. 222 - Ada
3. 204 - C
4. 203 - OCaml
5. 201 - Perl
6. 193 - Haskell
7. 182 - Java
8. 179 - D
9. 178 - ALGOL 68
10. 160 - Ruby

real	0m47.950s
user	0m44.363s
sys	0m0.080s

[nevilled@november rosettacode]$ time  a68g Sort_most_popular_programming_languages.a68 
1. 233 - Python
2. 222 - Ada
3. 204 - C
4. 203 - OCaml
5. 201 - Perl
6. 193 - Haskell
7. 182 - Java
8. 179 - D
9. 178 - ALGOL 68
10. 160 - Ruby

real	0m11.504s
user	0m3.228s
sys	0m0.068s

Sort_most_popular_programming_languages_slow - the original - would have been issuing thousands of calls to malloc.

re: [[2]] I should/could use this link. I hacked out a solution, c.f. the actual code for the re ignore values.

# hack: needs to be manually maintained #
  STRING re ignore ="Programming Tasks|WikiStubs|Maintenance/OmitCategoriesCreated|"+

Yes... it is a hack. I'll try to stitch this in shortly.

NevilleDNZ 20:04, 19 April 2009 (UTC)


Note: ALGOL 68 for Ubuntu now available

NevilleDNZ 09:19, 17 October 2009 (UTC)

Problem description insufficient?

I updated the Ruby solution today when I noticed there were more than 500 categories. Popular (top 10%) languages like Visual Basic .NET and Vedit macro language are left off most lists. --glennj 20:02, 15 June 2009 (UTC)

I found a better way to do this task.
"http://www.rosettacode.org/w/api.php?action=query&prop=categoryinfo&titles=Category:Python%7CCategory:Tcl%7C...", property "pages" should return category members. --Guga360 21:31, 15 June 2009 (UTC)
I completely missed the Perl/Python solutions: first filter on the Programming_Languages category, not all categories. --glennj
Actually, this does not solve the problem. We're still reading Special:Categories, if there is a language starting with Z, probably it will not get in the list. --Guga360 01:30, 16 June 2009 (UTC)

Ruby example question

I'm trying to run the Ruby example on Ruby 1.8.6 and it says that the "each_slice" method isn't defined. Is that part of 1.8.7? --Mwn3d 19:29, 26 June 2009 (UTC)

I don't know, probably it's for Ruby 1.9, but you can try replace <lang ruby>langs.each_slice(50) do</lang> with <lang ruby>langs[0..50].each do</lang> --Guga360 22:54, 26 June 2009 (UTC)
It's 1.8.7. I'll mark the example. The indexing solution didn't work, but I used a computer that has 1.8.7 and it works. Thanks for the suggestion, though. --Mwn3d 23:18, 26 June 2009 (UTC)
glennj 18:43, 27 June 2009 (UTC) -- Here's what the 1.8.7 docs say about Enumerable#each_slice
Iterates the given block for each slice of <n> elements
It could be implemented like<lang ruby>def each_slice(ary, n)
 (ary.length/n + 1).times {|i| yield ary[i*n,n]}

end</lang>

Redundant task?

I actually asked that on this page on Jan 26, however it was replaced without comment by Guga360. Therefore I'll ask again:

Isn't this task basically a combination of HTTP Request, Regular expression matching and Sorting Using a Custom Comparator? --Ce 11:55, 1 November 2009 (UTC)

Not Redundant — Don't be ridiculous. You might as well argue (by reduction to fundamentals) that it's a combination of basic operations and TCP socket handling. Which it is, but that's missing the whole point. This is a composite task that is focussed on the end goal rather than the specific technique used to achieve it, which is absolutely allowed in the RC rules. –Donal Fellows 13:32, 1 November 2009 (UTC)
BTW, I don't know why Guga360 replaced what you wrote. It seems rather rude to me to do so. –Donal Fellows 13:37, 1 November 2009 (UTC)