Github is the de facto internet repository for open source code. They've released source code data from packages hosted on this site (press release, blog post with examples).
The data is available as part of Google BigQuery (details). Example queries are here. You can run queries in the browser (requires google account)
This 3TB+ dataset comprises the largest released source of GitHub activity to date. It contains a full snapshot of the content of more than 2.8 million open source GitHub repositories including more than 145 million unique commits, over 2 billion different file paths, and the contents of the latest revision for 163 million files, all of which are searchable with regular expressions.
To compare languages, you can count and group by extension name, for example
AND sample_path LIKE '%.py' -- for python
Tip:
Don’t analyze the main [bigquery-public-data:github_repos.contents] table — at 1.5 TB, it will instantly consume your monthly free terabyte. Use instead the official [bigquery-public-data:github_repos.sample_contents] extract (~23 GB), or one of the full language tables I left at [fh-bigquery:github_extracts.contents_*].