2006-12-21

Site has Moved

I'm sorry for the inconvenience, but I've decided to migrate away from blogger.com.

My new site is jimbojw.com

Thanks in advance for your patients during this time of transition.

-- Jim

2006-10-18

Clearing the Air - More Languages that Suck

In response to criticism of a previous article on languages that suck, this new study aims to put the issue to rest - establishing definitively which programming languages suck the most, accounting for relative popularity among other factors.

Turns out (despite previous reports) that Perl does not suck the most, JavaScript does. Also, Ruby is by far the hackiest language on the planet ... keep reading to see why.

Methodology

As in the first study, all data were collected from search results retrieved via Google's Code Search. For each target language, three pieces of information were initially gathered:

Total Files
An approximation of the language's footprint in Google's database (and thus its popularity). Determined by one of the following queries: lang:<language-name>, lang:"<language-name>", or file:.*\.ext where ext is the file extension of that language's source code files.

Hacks
Measure of a languages hackiness. Determined by one of the following: lang:<language-name> hack or lang:"<language-name>" hack

Sucks
Measure of a languages suckiness. Determined by one of the following:lang:<language-name> sucks or lang:"<language-name>" sucks

When choosing between two queries, the one with the larger number of hits is kept. For example, there are approximately 4.4 million hits for lang:c, and 4.53 million hits for lang:"c". In this case, the latter number is retained.

Collected Data

Popular Languages:

LanguageTotal FilesHacksSucks
C4,530,000224,00011,300
C++847,000* 2,7003,000
C#120,0002,00050
Fortran115,00040020
Java830,00010,400500
JavaScript* 22,700600100
Lisp* 36,000600100
Perl208,00014,200400
PHP580,00014,200300
Python326,000400300
Ruby15,6002,00050
Shell80,6004,00050
Visual Basic* 29,90040050


Unpopular Languages:

Each of these languages have a footprint of less than 1,000 total files. These statistically insignificant outliers will not be considered during subsequent analysis.

LanguageTotal FilesHacksSucks
ADA100500
COBOL15000
Pascal* 6001003
SmallTalk* 4001006


* Values for starred entries were collected as follows:
  • C++ Hacks: This value is a composite of three queries each starting with lang:"c++" - little\shack (300), dirty\shack (400), and ugly\shack (2,000).
  • JavaScript: Searching for lang:"javascript" returns only 200 results, while lang:"javascript" div returns 22,700.
  • Lisp file count: Like JS, to get a reasonable count, used lang:"lisp" off instead of lang:"lisp" (only 400).
  • Pascal: lang:pascal has only 300 hits, while lang:pascal const has 300.
  • SmallTalk: lang:smalltalk has only 100 hits, while lang:smalltalk dir has 400.
  • Visual Basic: lang:basic has only 400 hits while lang:basic def has 29,900 hits.

Inferred Data

To analyze this data, the following metrics are helpful:

Hack Ratio
The number of "hack" results multiplied by 1,000 and divided by the total number of files.

Suck Ratio
The number of "sucks" results multiplied by 1,000 and divided by the total number of files.

For example, the Hack Ratio of PHP is 14,200 * 1,000 / 580,000 = 24.48.

Languages Sorted by Hack Ratio

RankLanguageHack Ratio
1Ruby128.21
2Perl68.27
3Shell49.63
4C49.45
5JavaScript26.43
6PHP24.48
7C#16.67
8Lisp16.67
9Visual Basic13.38
10Java12.53
11Fortran3.48
12C++3.19
13Python1.23


Languages Sorted by Suck Ratio

RankLanguageSuck Ratio
1JavaScript4.41
2C++3.54
3Ruby3.21
4Lisp2.78
5C2.49
6Perl1.92
7Visual Basic1.67
8Python0.92
9Shell0.62
10Java0.6
11PHP0.52
12C#0.42
13Fortran0.17


Analysis

Graphing Suck Ratio as a function of Hack Ratio gives us an estimate of the value of hackiness as a measure of suckiness in a language (click for larger image).

Clearly there is generally a positive trend between the two metrics. Languages with higher Hack Ratios tend to also have higher Suck Ratios.

This means one can expect a language with a low Hack Ratio to tend not to suck, and likewise, a language with a low Suck Ratio will probably require fewer hacks.

However, as the ratios increase, the strength of the relationship decreases. This leads to notable exceptions such as C++, which has a high Suck Ratio, but comparitively low Hack Ratio.

Conclusions

It would seem that the foregone conclusions in the previous study were premature. With a Suck Ratio of 4.41, JavaScript is over twice as sucky as Perl, which has a Suck Ratio of just 1.92.

According to these findings, Ruby is the hackiest language of all, with a Hack Ratio of 128.21. In fact, it's nearly twice as hacky as its nearest competitor, Perl (with a Hack Ratio of just 68.27).

There's clearly a need for more research in this area, as the field of "statistical inference of the relative virtues of programming languages" is still in its infancy.

dzone this article

2006-10-14

2006-10-13

Innovations - Google Code Search Autocomplete

Google's new Code Search is all the rage these days. Here I present Google Code Search Autocomplete - my contribution to this already great service.


Think of it as adding functionality similar to what Google Suggest adds to the normal Google search.

Download

To get the autocompleter, you must:
  1. Install the latest versions of Firefox and Greasemonkey (if you haven't already)
  2. Once in Firefox, navigate to the Google Code Search Autocomplete Userscript
  3. Install it as you would any userscript by clicking the "Install" button in the upper right-hand corner of the screen.
Once it's installed, head on over to Google's Code Search and give it a try.

Start typing in the search box to see the drop-down list of suggestions.

Developer Notes

This script does its dirty work by issuing an Ajax query behind the scenes for whatever you've typed so far plus the string "\w*". So if you had typed "google", the Ajax call would query for "google\w*". For readers unfamiliar with regular expressions, this basically means "google*" where * can be any number of "word" characters (A-Z, a-z and _).

The resulting page is then parsed for all instances of <b> tags with class="hl". These contain the query matches. Once collected, terms are then sorted and displayed to the user via the drop-down div below the search field.

Due to these design constraints, some of the script's behavior may seem strange at first. For example you may get only a handful of hits for "goo", but many for "google". This has to do with the number of redundant hits returned during the transparent Ajax request. The more reduntent matches there are, the fewer drop-down options there will be.

Also, since an entire page request is being made behind the scenes, the drop-down may feel slow to update. Especially if you're on a slower connection.

Summary

This article builds on concepts developed in a previous blog entry, in which I describe the process of incorporating the Scriptaculous library into Greasemonkey userscripts. Check it out if you'd like to learn more about the underlying mechanics of this script.

I hope you've found this useful or interesting. Drop me a line and let me know what you think!

digg this article

2006-10-12

Clearing the Air - Languages that Suck

New! Check out the follow-up article More Languages that Suck.
Everyone knows that programming languages suck, but which sucks the most?

I have conducted a scientific study to answer this question, and humbly present my findings below.

Methodology

All data for this report were collected from search results done through Google's Code Search, by searching for the phrase "<language> sucks" (without quotes) where <language> was one of these 10: C, C++, Java, JavaScript, Visual Basic, Python, Ruby, Perl, PHP and Lisp.

Occasionally, two similar searches would turn up different numbers of hits. For example, "C sucks" results in 35,900 hits while "c sucks" results in 49,600 hits. Where this is the case, the query with the greater number of hits is kept.

Results

The results seem to confirm conventional wisdom: Perl sucks the most, Ruby sucks least and all other languages fall somewhere in between.

It was surprising however to find that Visual Basic sucks less than JavaScript - I'd have thought it would be the other way around.

RankLanguageQueryHits
1Perlperl sucks58,900
2Cc sucks49,600
3C++c++ sucks39,900
4Javajava sucks27,900
5LispLisp sucks19,100
6JavaScriptJS sucks13,400
7Visual BasicVB sucks8,000
8PHPphp sucks3,000
9Pythonpython sucks2,000
10Rubyruby sucks500


Here's a graph of the above data (click to view larger version):


Operating Systems That Suck

Out of curiosity, I also tested for operating systems which suck. Again conventional wisdom proved correct: although Windows, Mac and Linux all suck, Windows definitely sucks the most.

RankLanguageQueryHits
1Windowswindows sucks60,000
2Macmac sucks58,200
3Linuxlinux sucks49,600


Honorable Mentions

Surprisingly, a search for "C# sucks" returns only one result. I took this to be a statisitically insignificant outlier, suggesting that either C# sucks so badly that nobody uses it, or that those who do use it dare not openly challange the .NET regime.

Also, searching for files with COBOL's file extension (.CBL) reveals about 100 hits. Unsurprisingly, the query "cobol sucks" (no quotes) also has about 100 hits. I leave it as an excersize to the reader to interpret this result.

Conclusion

All programming languages suck, some just suck more than others. Thank you.

(If you liked that, keep reading...)

digg this article, dzone this article

2006-10-08