Live data from Hacker News

Ask HN: How do you search large codebases before adding a feature or fixing bug?

news.ycombinator.com

11–20 of 87 posts

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#11
This skill is what differentiates really good developers from not so good developers (that may wrongly believe themselves they are good):

How good are you at reading code, finding out how smaller parts work in a larger system and understanding the context&domain is a large part in how good you are.

Not so good developers, when they are not so good at this, often start blaming the system and people who have worked on it.

Not so good developers may however be able to handle smaller systems (in particular ones written in their favorite tech stack), and this experience leads them to erroneously believe they are good.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#12
Whenever working with a new codebase I always try to find the route definitions file first. Something that maps the api interface to the functions they call. I can then reason backwards from any service by clicking into whatever I’m interested in. After that I look for where config is defined and try to understand what’s unique about this envs setup.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#13
Sourcetrail (Google) had been my primary go-to for large multi-MLOC C-code and C++ project like Mozilla Firefox recently for me. I can now insert instrumentation testpoints deep inside Firefox JavaScript JIT engine within two days from zero-knowledge, quicker there on.

- Sourcetrail (GUI/Linux/Windows, closed-net-capable, archived) - https://github.com/CoatiSoftware/Sourcetrail

- SourceInsight (repo/web-server/closed-net) https://www.sourceinsight.com/

- OpenGrok (web server plug-in/Java/closed-net) https://oracle.github.io/opengrok/

- CLion (GUI-based IDE) - By IntelliJ/JetBrains - https://www.jetbrains.com/clion/

- SourceGraph (Web-based) https://about.sourcegraph.com (thanks, gravypod)

- Codesee.io (GitHub/web-based) - https://www.codesee.io/privacy-and-security

For free as in beer, I prefer OpenGrok so I can get more than JetBrains

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#14
post #11

This skill is what differentiates really good developers from not so good developers (that may wrongly believe themselves they are good): How good are you at reading code, finding out how smaller parts work in a larger system and understanding the context&domain is a large part in how good you are. Not so good developers, when they are not so good at this, often start blaming the system and people who have worked on…

No post body was provided.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#16
I keep a directory with up-to-date clones of all relevant repos. This is separate from my usual working directory. I experimented with git workspaces, but it wasn't worth the trouble, especially since the set of repos I'm working on is not necessarily the same as the ones I keep in my search dir.

At the root level I maintain two scripts:

  clone.sh

  update.sh
clone.sh has one

  git clone --recursive .. 
line per repo. When I run low on disk space I sometimes delete larger repos. The clone script allows me to easily re-clone everything in this case.

update.sh is similar but pulls all repos.

For global search across all branches I do:

  git grep  $(git rev-list --all)
(when I forget the line I look it up in Stack Overflow [1])

This is especially useful since I work a lot with Bitbucket and to the best of my knowledge you can only search the default branches there.

When I know the branch, but want to search across all history I use git pickaxe, aka

git -S ...

All of this is not very sophisticated and takes a lot of disk space but it works pretty well for me.

[1] https://stackoverflow.com/a/15293283

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#18
post #5

IntelliJ / PyCharm / WebStorm ctrl-shift-F: search in the whole codebase, is what I use

IntelliJ is struggling noticeably navigating even my tiny 50 KLOC search engine project. I can't even imagine using its search function to get around MLOC-scale projects.

Hmm, just checked. The two projects I have open now have 510 KLOC and the other one 200 KLOC, and searching in both feels instant. (This is not including node_modules and python libraries/caches that it also searches through by default)

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#19

I work on code bases with millions of lines, so I wrote a tool called Septum to help me ( https://github.com/pyjarrett/septum/ ). This isn't to replace grep or ripgrep or silver searcher, those are all great tools you should have! Septum is neighborhood based (context-based) search, so you can find contiguous groups of lines which contain specific things, but exclude other things. It's also interactive so you can add…

This is SUUUUUUPER cool. Definitely going to try this out. Thank you for making it.

Is there an easy way to install this on non-windows systems? I'm not familiar with Ada toolchains.

Re: Ask HN: How do you search large codebases before adding a feature or fixing bug?

#20

I keep a directory with up-to-date clones of all relevant repos. This is separate from my usual working directory. I experimented with git workspaces, but it wasn't worth the trouble, especially since the set of repos I'm working on is not necessarily the same as the ones I keep in my search dir. At the root level I maintain two scripts: clone.sh update.sh clone.sh has one git clone --recursive .. line per repo. When…

git grep is amazing. I almost never need an alternative.
Post reply on HN