Google Code Search, Krugle or Koders….

Posted by Justin on October 17, 2006
Computers, Open Source Projects, Reviews, Websites

Google recently lit up the online coding community with their Code Search, even I was surprised by this. But, what about the code search websites that where already running? To my surprise, while browsing over Slashdot, there where still developers that didn’t know that Krugle or Koders existed. They still did the tried and true normal Google search or books. While I maintain a small collection of books, they’re mainly for design, not examples: AJAX & PHP or Object Oriented PHP, etc. For those weird problems, I use a search engine. The problem comes into play with the different engines. Which one is better, which one has better results?

Examples
A simple example is to run through a search for the Mail function in PHP, since a heck of a lot of sites use it.

    Google: mail lang:php returns (filename - GPL - PHP)
    Krugle: mail (select php) returns (filename - project website - project name - license type)
    Koders: mail (select php) returns in a roundabout fashion (filename - language - line number - website - project name - license type)

For just the search functionality, Google is a little easier since you can just type your entire query out. For people that code, and can type pretty fast, this is so much easier than leaving the keyboard and grabbing the mouse. On the flip side, this can be solved on the two other websites by simply updating their search field to accept the “lang” regular expression and use it instead of the drop down box - pretty simple to do really. I honestly see the Krugle developers updating there site to allow this, but Koders might take a little longer.

Now, for the code results, each one varies as well. When you do a search they do the following:

    Google - returns the relevant line with the surrounding 1 to 2 lines around it, killing white space
    Krugle - returns the relevant line with 4 other lines, including whitespace.
    Koders - returns the relevant line with 4 other lines, killing white space

To me, Google and Krugle lag behind Koders on this. For Google, their developers should know that someone is looking for more than 2 to 3 lines of code to figure out whats happening with the function or code block they’re using. As for Krugle, I don’t know what the developers where thinking, but there is no reason to include white space - none. Both of these problems are relatively easy to fix.

When you click on the results, the fun starts happening.

    Google - returns the file, result highlighted, in plain text with a plain file list for the whole project. It also allows searches within the browser. You can use “N” or “P” for next or previous search results in the page, no browser search box needed. Google allows for you to download the entire project from their cache.

    Krugle - returns the file with color coding with a tree hierarchy file list of the project. It uses AJAX to open a tab on the page you’re looking at so you can compare multiple examples of the results. On top of this, Krugle offers a “Save File” dialog so you don’t need to copy, paste and save AND it offers the ability to add an internal note into the code after you log into the website, basically like a sticky. This note can be public or private. It also allows a “Search Selected” dialog. This allows you to highlight anything in your current results and start a new search with one click.

    Koders - returns the file, result highlighted, with line numbers with a plain file list for the whole project. It allows downloading of the file as well.

If I could ask for anything here, it would be for Krugle to add line numbers and highlighting and it would be perfect. The color coding helps a heck of a lot. This would be fairly easy to implement on the back end of both Google and Koders.

The Look, The Feel (of Cotton)
The look has a little to do with someone searching the results. Obviously someone will feel more comfortable in one search engine over another. This is one of the main reason Google is so damn popular. Their search pages aren’t cluttered with ads, links to things you’re not interested in, etc. A good example are the Google and Yahoo home pages. Want to really see something ugly, check out the MSN search page (of course, if you go to search.msn.com, you’ll be reminded of Google…).

Google is obviously just the plain old Google. Sometimes this is good. Krugle has a nice looking UI, but has ads and it can get a little confusing at first when you start getting tabs and stuff all over the place. It took me about a day to get use to it. Koders is also ad based, but tries to maintain a healthy medium between Google and Krugle.

Other Code Search Engines
There are some other code search engines that deserve to be mentioned in case you feel more comfortable with a specific site, layout or author.

O’Reilly Labs Code Search - Allows you to search through the O’Reilly book collection.

Codase - Standard source code search, pretty slow. Currently in Beta, but that was released Nov, 2005.

Planet Source Code - Starndard source code search engine. Heavily Ad supported.

Gonzui - Open Source search engine.