Google Launches Code Search
Google has launched a Code Search tool, designed to make it easier to find snippets of code. The service looks interesting. I’m working on a project with the installation APIs in .NET 2.0, and tried to find an example of using the ManagedInstallerClass (despite the fact that the documentation says that it’s for internal use only). This was my search:
lang:"c#" ManagedInstallerClass
If found two hits, one of which showed me an interesting way to use it.
I tried to find the same thing in VB, but initially couldn’t find the magic way to indicate the language. lang:VB? lang:“VB.NET”? lang:“Visual Basic”? Another variation? Fortunately, the Advanced Search link provides a combo box with a complete list of languages. “Basic” it is. No samples for ManagedInstallerClass though, alas.
There’s a good spread of languages, certainly all the ones I’m interested in, including SQL.
There are lots of flexible options for searching, including regex. Options include searching by language as I did above, specific files or directories, specific packages, and code license types.
The only thing I don’t like so far is that there doesn’t seem to be an easy way to get context information of the page where the code is coming from. Most of the code I looked at was in some kind of archive file, with no link to the Web page that might give information about the code. Often you can figure it out from the link, but not always.
Give it a try. It seems to be a nice, targeged way to find useful code. The FAQ ‘splains it all. It’s still a Google Labs project, so I assume that means it will evolve quickly.