Why I love to use Sourcegraph for my own projects

At my current place of employment, Lyft, we use Sourcegraph which is an open source tool that allows you to search across many, many repos at once. It’s basically Google for any and all code. I also use Sourcegraph on my own projects to search across my own projects or ramp up on open source projects like Kubernetes or new SDKs I might be using in my projects.

I’ve got 3 specific reasons why I love the product so much that I use it on my own beyond work.

You can onboard or re-onboard onto codebases much faster because they make navigation so easy

Seriously. I can’t stress enough how important this point is. If you think about it, in todays world where there’s so much code, so many dependencies, so much context needed to ramp up on a codebase I can’t imagine my world without Sourcegraph. Saying that, I don’t think it’s a one size fits all. Some folks might need it, or some might work in a smaller environment in which case they might not need it. Regardless of needing it, I do fundamentally believe it is a benefit to have something that makes searching and navigating code easier.

Before Lyft, if I wanted to onboard onto some code like an open source project or my own projects that I haven’t touched in a while, with GitHub, I would search for some code across the different repos as I painfully clicked through many of many files on GitHub, and from there would use CMD+F (on Mac) to find some related function or use some of their advanced search capabilities to find code. But that advanced search capabilities is click heavy and requires me to have the context of “all the repos” I want to search in which isn’t something I have the luxury of always having.

Advanced search capabilities offered by GitHub

I also used my own IDE to search and find code but that it painful it it’s own right and having to clone every thing I ever wanted to ramp up on isn’t so nice either. I end up with a silly amount of repos on my local machine that I use (read) once.

On the other hand, with Sourcegraph all I have to do is type what I want into a search bar to get the results I want that indexes whatever context I set. Search is it’s obvious strength, and the team there does that very well.

It doesn’t get any simpler than this

Beyond searching, Sourcegraph makes it very easy to click through functions, classes, find references etc. In one line it does one thing very very well and that’s navigating through code. That one line is what you need when onboarding onto a code base with the levels of complexities and abstractions that we have nowadays. I say this from the perspective of having onboarded across many codebases both at work and in my own time.

The ability to easily and quickly navigate code is why I love to use Sourcegraph to onboard onto things and it’s truly an indispensable part of the tools I use everyday. They have other use cases as well but my main use cases have always been search and navigation.

Searching is practically painless (once you know the “main tricks”)

Unlike Google search where all I’m looking for is a particular topic with code search I’m usually looking for a particular set of repos or files that reference something. Or on the other hand, I’m searching for a particular set of repos or files that exclude a reference to something.

They have an entire doc on search query syntax which walks you through some patterns and examples docs as well. As a user it’ll take some searching to get to a particular use case you may need but the docs are usually there. In the future, hopefully a quick use cases page is in their books where users can quickly find the syntax they need for common use cases like excluding/including search terms. All in all though, searching is still, for the most part, painless.

It’s open source

This is a great thing. I’m all about democratizing things, education, code, amazing food recipes and many other things. They explain some of their philosophy within their handbook. If you’re into this kind of thing I definitely recommend you check them out, and maybe try them out while you’re there.

Going to sourcegraph.com/search will take you to their own instance and you can try it out yourself!

ps. I wrote this because I wanted to, and it has no reflection on my current place of Employment or that of Sourcegraph. 🙂

Published by Paul Young-Suk Lee

SWE @lyft. Currently working on data infrastructure

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: