Live data from Hacker News

Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

beyondgrep.com

61–70 of 101 posts

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#61

I’m stuck with rg right now because it’s the only ine which correctly handles gitignore files. Generally quite happy with it but I wish it could also use a more powerful regex engine for some less common cases. Most annoying thing is that $ does not work with windows newlines.

Have you tried sift? https://sift-tool.org/

sift addresses neither of the GP's concerns with ripgrep. It's also much much slower than ripgrep on almost anything other than simple literal scans.

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#62
post #46

A nice feature of ag is the ability to limit the search to a certain file type. E.g. to only search ruby files: ag --ruby foo . To see a list of supported types and the matching file extensions: ag --list-file-types . Just checked and rg does have something similar, but you need to specify the type as an argument to a flag: rg --type ruby foo .

You can shorten it with -t: -tc, -tphp, -truby, -tsh. Then it's actually the same amount of characters as with ag.

And has the advantage of being pluggable rather than a hard-coded list of file types (though IIRC ack has a configuration file whereas with rg you need to use an alias to set up new types for every invocation).

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#63
post #54

Any modern tools like this? sary - a suffix array library and tools http://sary.sourceforge.net/ It finds words in O(log(n)) time by using an additional index.

The problem with suffix arrays---even with a blazing fast SACA---is that they are slow. It will take a long time to generate an index for even a moderately sized code repository.

Typically, if you want an index, you build an inverted index, which maps terms (e.g., n-grams or tokens in your favorite PL) to a postings list. The postings list contains all of the documents in which that term occurs.

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#65

This chart doesn't compare speed. Until rg, I didn't grep much because I generally search through a lot of files. rg cuts through them in no time.

The `sift` [1] tool presents a performance comparison, but not against `rg`. [1] https://sift-tool.org/performance

ripgrep's introductory blog post[1] includes a perf comparison, which incorporates sift. But sift is too slow to include in several benchmarks. sift's achievement is its fast parallel directory traverser, coupled with Go's vectorized IndexByte[2] function for simple literals. In that case, it is quite fast, but as soon as you enter Go's regex engine, it's game over.

[1] - http://blog.burntsushi.net/ripgrep/

[2] - https://golang.org/pkg/bytes/#IndexByte

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#66
post #11
post #7

switched from ag to rg a few months ago and have nothing but good things to say about the experience.

I switched also recently, the thing that helped me was adding this: alias rg='rg -S' to my .bashrc so that rg had the same default case sensitivity as ag.

I do wish the persistent config file enhancement had a significant chance of becoming a reality. https://github.com/BurntSushi/ripgrep/issues/196

I understand alias'es and wrappers fine, but I like having the environment have some way to contribute. It's just my simple preference.

There's also the related #314 which makes even more sense- per project configuration. Sure would be great being able to download a project & have it already setup nicely for ripgrep! https://github.com/BurntSushi/ripgrep/issues/314

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#67

Seems everybody here has switched to rg but I haven't because it's not available in Debian repos (yet) unlike ack/ag. So, do such folks use Arch or just download a pre-built binary ? How about updating rg when a new version is out ?

The easiest way: first, install rust and cargo, either through your distribution, or thorough rustup if your distribution doesn't have it yet. Then run "cargo install -f ripgrep". It'll download the source code, build, and install to ~/.cargo/bin, which rustup adds to $PATH for you by default.

Edit: the "-f" in the "cargo install" command is for updating; without the -f, it refuses to install over an already installed version. The first time you install, you can omit the -f.

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#68

Earlier quoted context omitted.

Same here. Ripgrep works like a charm Ack requires Perl, which I am not going to install just for that purpose.

What kind of OS are you running that Perl isn't installed already?

An ideal one.

Like, platonic ideal- because it doesn't exist. That greatly ideal.

I don't know why I care, other than even the super cut down perl being a sizable % of the install size for some of the very small systems I've worked with.

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#69
post #46

Earlier quoted context omitted.

You can shorten it with -t: -tc, -tphp, -truby, -tsh. Then it's actually the same amount of characters as with ag.

And has the advantage of being pluggable rather than a hard-coded list of file types (though IIRC ack has a configuration file whereas with rg you need to use an alias to set up new types for every invocation).

ack has a configuration file, and it's extremely flexible, including the ability to check shebang lines. If you have a shell script without an extension, it's the only way to know what language it is.

Re: Feature comparison of ack, ag, git-grep, GNU grep and ripgrep

#70

Earlier quoted context omitted.

Emphasis mine- Excerpt: "Some might say that ag and ripgrep and any of the other tools I list on beyondgrep.com are competing projects, but I think that way of thinking is wrong. It’s only a competition if you see it as a competition. I’m not competing against anyone for anything: Clicks, dollars, popularity, etc. If someone uses ripgrep instead of ack, it doesn’t hurt me. It’s the difference between an abundance vs.…

What is woo-woo space?

I’d wager they’re talking about the whole “The Secret” abundance mentality thing. “Believe and you shall receive... somehow”. That sort of interesting New Age stuff. I put no credence in it myself in terms of their stronger claims, but hey, CBT reminds me of it in a lot of ways and helped cure my depression.
Post reply on HN