Live data from Hacker News

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

news.ycombinator.com

41–50 of 87 posts

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

#41
post #21

Earlier quoted context omitted.

Seen != Built. You don't always have to optimize for the right answer right away. Just asking someone who's worked with/on the codebase will often give you a jump start.

If someone worked on JIRA/Task we can find, otherwise, how do we even know about who has seen the codebase?

You ask your coworkers, "have you seen this before?"

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

#42
post #33

Earlier quoted context omitted.

It really has no issue as long as you have enough RAM and disabled swap. I recently got a fairly decent gaming laptop that I'm supposed to develop on and the 16 GB RAM is constantly full and it's swapping all the time, browser keeps suspending my background tabs, really pain in the ass.

You really do not want to disable swap on Linux. The operating system does not handle out of memory situations well at all if you do. At any rate, I've got 32 GB of ram and I'm operating off an NVMe-drive, I really don't see what the problem is.

Possibly dumb question, have you adjusted the maximum memory heap size that the JVM can allocate for running IntelliJ?

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

#43
I wrote several scripts that temporarily add call tracing to the source code. The scripts take a few days to write but I've used them on many projects. Note there are code parsing libraries that can help you.

For example:

def foo(args):

   trace_func("foo", args)

   # rest of the function

(NOTE There is call tracing logic built into some languages but it doesn't always work for some complex code bases; try it before you write your own.)

If the code creates html elements, my script adds attributes to the html element to link back the source code location so I can look at the html and figure out where the elements were created. If the html is built using templates, then I add html comments to the template so I can tell where they are used in the final page.

Then I test the app and look at the traces to figure how it works.

At first I trace everything but once I get to know the code I add the tracing to the areas that matter. I don't check in this code.

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

#44
post #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…

Quoted post unavailable.

I think the gist of your comment is reasonable, but it reads as kind of adversarial. Something like:

> Being able to navigate a large, complicated code base is a really important skill, and I think one of the important marks of a senior engineer. A big part of it is also just having the grit to dive in and understand a messy system without having things neatly laid out for you.

Says ~mostly the same thing, but without the condescension.

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

#45

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…

There is also a company called SourceGraph which parses the AST of the various languages and lets you get CLion-like features with regex search. https://about.sourcegraph.com/

Thanks, shimmed that link in the parent.

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

#46
post #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.

This is Windows/Linux only (I didn't have a Mac at the time). You can use Alire (https://alire.ada.dev) will install your toolchain as well as build an executable.

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

#47
post #14

Earlier quoted context omitted.

Quoted post unavailable.

Maybe your comment is off topic? We are talking about searching. You are talking about good vs not good developers and understanding code. Searching != understanding.

You can't search without a recognizer and you can't recognize without some kind of understanding.

As OP says, one of the skills/talents that differentiates good vs not good developers is the ability to rapidly "grok" enough of a large codebase to figure out "where to tap". ( https://quoteinvestigator.com/2017/03/06/tap/ )

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

#48
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.

Do you have indexing turned off for your project or has indexing not completed? Indexing speeds up your searches.

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

#49

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…

Looks pretty awesome! Will definitely give a try! Wish to hear why did you choose to use Ada?

I normally work in C++, but I've also written in lots of other languages.

I wrote an article for these folks which includes some of the rationale here: https://blog.adacore.com/ada-crate-of-the-year-interactive-c...

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

#50
First thing I do is cleaning up the code base. I'm deleting unused code, fix class and method visibility according to usage, do the occasional rename if naming is inconsistent, check error handling and logging for inconsistencies, write the occasional unit test... This gives me a broad overview over the code base, improves my chances to find anything by text search and enables me to better assess the impact of changes.
Post reply on HN