Thursday, April 14, 2005

Google Source Code Search



I just wrote a JavaScript hack that would let you utilize Google to search for source-code on the Internet. The hack is called Search4Code! and it currently supports: C, C++, C#, Java, JavaScript, Visual Basic, Perl and Python.

Let me know if you would like to see a new programming language supported. You may find Search4Code! especially useful when you're trying to learn a new API method.

How to use Search4Code!
  • Simply point your browser to http://search4code.blogspot.com.
  • Type the text that you wish to search for.
  • Select the programming language you wish to search for.
  • Click on Go! to start the search.
Here's a screenshot of Firefox pointing to the above mentioned URL:



Go check it out!

How it works

Search4Code is a meta search-engine and uses Google behind the scenes. It uses the filetype search parameter of Google to restrict a search within files having the well-known file-extension of the language being searched for. The tool currently supports C, C++, C#, VB etc. and support for more languages can be easily added in the future. My idea is to see how far I can get on source-code search using Google.

There's a website called Koders who also provide source-code search, but they appear to have their own search-engine that indexes the source-code of the projects only at certain websites like SourceForge.net.

6 comments:

Alpha0 said...

Great Man.
Nice Interface.
Least cost and innovative idea.
If I have to search for code I generally check www.koders.com. I dunno exactly how does it work. Perhaps, it has index whole opensource library only.

#Alpha0

Sid said...

I like the fact that Koders.com is able to show you the code with syntax highlighing, and also let you know the other files in the same project.

Sid said...

I like the fact that Koders.com is able to show you the code with syntax highlighing, and also let you know the other files in the same project.

Sid said...

Damn! Why did it post the previous comment two times :)

rajaram said...

Why not use apis from yahoo, amazon also for this ;). USe some heauristic to blend the results and display.

I suggest buy some webspace it wil cost some 4-5k Rs. a year, so that u can host more services.

Sid said...

Yeah! I should probably try out the APIs from Yahoo! and Amazon too. This would also help work around the 10 word limit on queries in Google and probably also get more meaningful hits that Google alone might have missed.

Further, I also want to find out what the most suitable UI would be for source-code search.

Let me know if you are aware of any decent, and reasonably cheap Linux hosting providers.