// Internet Duct Tape

Find what you’re really looking for with Google Code Search

Years ago I had to take over maintaining scripting infrastructure for a build environment that was written in a language called Expect. Expect is a TCL package focused on dealing with interactive processes. It was also very different than anything I’d worked with before, and I kept shooting myself in the foot with every simple change I had to make.

Part of the problem was trying to maintain something without taking the time to learn the language, but what really made my blood boil was trying to search for Expect code snippets. Expect is a common word, so good luck finding a web page devoted to the language. Thankfully times have changed and Google now knows that you’re looking for information about Expect the language.

Google has a new product on the market that might fix problems like what I used to have with Expect. Google Code Search lets you search within source code. What makes it really powerful is that it supports regular expressions and it supports limiting search results to specific languages and filenames.

Syntax and Examples (more about regexp syntax)
regexp Search for a regular expresion
go{2}gle hello,\ world ^int printk
exact string Search for exact string
“compiler happy”
file:regexp Search only in files or directories matching regexp
file:\.js$ XMLHttpRequest file:include/ ioctl
file:/usr/sys/ken/slp.c “You are not expected to understand this.”
package:regexp Search packages with names matching regexp.
(A package’s name is its URL or CVS server information.)
package:perl Frodo package:linux-2.6 int\ printk
lang:regexp Search only for programs written in languages matching regexp
lang:lisp xml lang:”c++” sprintf.*%s
license:regexp Search only for files with licenses matching regexp.
license:bsd int\ printf -license:gpl quicksort

The big weakness is that the list of supported languages is rather small: Ada, ASP, Assembly, Basic, C, C++, C#, Eiffel, Erlang, Fortran, Java, JavaScript, JSP, Lex, Limbo, Lisp, Lua, Makefile, Mathematica, Matlab, Objective C, Perl, PHP, PostScript, Python, Ruby, Scheme, Shell, Smalltalk, SQL, Tcl, Troff, Yacc.

It wouldn’t have helped me out with Expect back then, and today it wouldn’t help me find any information about Hardware/Verification Description Languages (VHDL, Verilog, SystemVerilog, E). I am also surprised that Haskell isn’t included in the results.

Is it useful? Not really. People search code for tutorials, examples and algorithm implementations. Google Code Search still has a long way to go before it starts returning relevant results. So far the best use people have found for it is searching for questionable phrases in code comments or default passwords for common applications and analysing language usability by the use of the word “fuck”:

[from Supr.c.ilio.us]

Valleywag, Silicon Valley’s favorite “Guilty Pleasure” (guilty I understand but pleasure?), is already trying to abuse Google’s codesearch by searching for Naughty Words. Well, Nick, here’s how it’s really done.

We’ve all been there, it’s 3am and you’re just too plain tired to care. Or some other times, you don’t even bother with excuse for that Ugly Hack even if it’s in kernel code!

But there are some things you’ll never do. Like, publishing unfinished and unfixed code or complete guesswork and we know you always test your code first. You’ll definitely never ever publish code with known security flaws or use unsafe library calls knowing what they might lead to right? never!

And yet, despite all these precautions, in the end it all seems to hang on a hope and a prayer. Weird.

I think the major use for this service will be looking for specific bugs and code vulnerabilities.

Related Posts

Google Code Project Hosting
>> Number of uses of the word “fuck” by programming language
>> List of interesting things found in Google Code Search
>> Static code analysis using Google Code Search
>> news – Google Code Search
>> news – Google Code Search goes Live
>> news – Google crawls into source code search
>> news – Coders, start your (search) engines

5 Responses

Subscribe to comments with RSS.

  1. roy said, on October 07, 2006 at 6:43 am

    I’m currently supporting a legacy app that is responsible for publishing PDFs. Not just simple ones, but really complicated ones with lots of horrible details, and margins and columns and multiple languages, different fonts..you get the point. Typesetting on steriods.

    http://en.wikipedia.org/wiki/3b2

    The language is/was called 3B2. Google code search has nothing….and I mean nothing.

    In fact, the Internet in general doesn’t have any tutorials on it. Just a mere Yahoo! group were people ask random questions.

    So yes, Google code search still has a while to go before it becomes useful.

  2. Comments « //engtech said, on October 23, 2006 at 7:48 pm

    […] Roy agrees that Google Code Search is frickin’ useless for searching for legacy languages — which is what we REALLY need it for […]

  3. Geoff Dodd said, on February 18, 2007 at 4:43 pm

    Google code search seems to be one of those brilliant engineer ideas that get put to the 3 top men at Google, Mountain View. Perhaps they decided wrongly about this one? The level of complexity was underestimated, perhaps.

  4. […] Google Code Search – Searching open source code […]

  5. Comments « Internet Duct Tape said, on July 20, 2007 at 2:37 am

    […] agrees that Google Code Search is frickin’ useless for searching for legacy languages — which is what we REALLY need it […]


Comments are closed.