Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
beyondgrep.com
beyondgrep.com
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. scarcity view of the world. I choose abundance. I think most of us who work in open source do, too."
I never thought I would see the confluence of the "woo-woo" space abundance mindset and a blog post about an open source command-line utility. I must say I am intrigued.
If this explanatory medium doesn't substantiate the reasonability of a mindset of abundance in the minds of programmers, I don't know what ever will.
Not much woo woo involved.
Abundance vs. scarcity has nothing to do with “Believe and you shall receive... somehow”.
Scarcity thinking means that you fear giving people credit, and letting others have success. You fear that praising others makes you seem weak. You think that if someone uses a different open source project than yours, that you or your project suffers. You might not even be aware of the thinking. You might just feel it reflexively.
Abundance thinking says that there is more than enough praise to go around. It says that your success doesn't hurt me in mine (unless in some tangible way it does). It says that you can use ag and I can use ack and Susan can use ripgrep and it's all good.
In this specific case, abundance says that I, as the creator of ack, don't need to own the "market". In fact, the creation of other tools only helps ack. It gives the ack team ideas for things we can implement in ack. Who am I to think that I'm the only one with good ideas?
It gives our users a wider choice of tools. I put my work out there publicly to help people. Why would I not want them to have a variety to choose from?
That's abundance vs. scarcity.
I've added a link to your feature comparison table to my REAMDE[1]. Thanks again for putting it together!
[1] - https://github.com/BurntSushi/ripgrep#feature-comparison
[1] https://github.com/BurntSushi/ripgrep#why-should-i-use-ripgr...
It's a fair criticism but I don't think it is designed to be misleading.
We're also working on a GNU grep vs. POSIX grep vs. BSD grep phrasebook.
For example, the table could show the blank cell in a different color if it is a default feature, or if it an unsupported feature.
Alternatively, the cell could contain a message such as "(default)".
Right now we're keeping all the data in a JSON file that we massage into a chart. Massaging it into a true feature comparison chart, along with a rosetta stone, should be a simple matter of programming. Same thing with the GNU/POSIX/BSD rosetta stone we're working on.
https://github.com/beyondgrep/website/blob/dev/comparison.js...
tail -F output.log | ag --passthrough '.*PLUGH.*' grep '^|.*PLUGH.*'Or you could just use --passthrough. It's easy to remember, easy to type, it autocompletes, it doesn't interfere with your criteria.
tail -F output.log | grep --line-buffered TEXT | some-util-with-outputAren't those the same thing? Shouldn't they be grouped for better comparison?
Most annoying thing is that $ does not work with windows newlines.
Thank you, have been trying to motivate myself to switch to ack/ag for a while. This seems like it might be what I needed.
As for search, I'm on Windows and I like to use FileLocator Pro.
The only serious feature you might miss is lookahead/lookbehind in regexes - that's missing by design since if you want guaranteed linear time search you can't have those.
I really like the discussion that lead to the decision of never including a pager:
1. GNU grep - GPLv3+
2. ack - Artistic License v2.0
3. ag (aka silver searcher) - Apache License 2.0
4. git-grep - GPlv2+/LGPLv2.1+
5. rg - MIT license
So with maybe the exception of rg, all are gpl compatible, that's great news.
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.
For me, raw speed is not as important as a rich feature set to support my code spelunking.
All in all, it'd still be nice to have a more comprehensive performance comparison page, which gets regularly updated. Bonus points if it shows how speed changes over time, similar to http://speed.pypy.org (the code for that is available, by the way).
Wishful thinking, I know, but hey, who knows... :-)
However, those are from 2016, and so it's hard to tell what might have changed in the meanwhile.
I re-ran them :-) https://github.com/BurntSushi/ripgrep/tree/master/benchsuite...
TL;DR ripgrep has gotten faster in important areas since the initial set of benchmarks (the proper comparison there would be https://github.com/BurntSushi/ripgrep/tree/master/benchsuite...). The key reasons why are because it grew a parallel directory traverser, and its line counting got vectorized courtesy of the bytecount[1] crate. ucg has gotten a little faster in some cases, but the general conclusion of "ripgrep is the fastest" is still correct.
I would be curious to see ack get into the test suite, however. Even if it is much slower, I'd like to see the results.
And I'd be very curious to hear your reasoning for the different results in the subtitles_ru test cases -- why is rg returning radically different numbers of lines as compared to the other tools?
Thanks!
You'll need to add it to the benchsuite script (which should be very easy to do, just peruse the source to see other examples), but for me, ack is too slow to benchmark this way. In theory, I'd be fine adding it to the same benchmarks as pt/sift are in, since they are also generally too slow to benchmark, but are at least fast enough in some of them to tolerate it. But ack has different characteristics. While pt/sift have a very high ceiling (like ack), they also have a very low floor in some cases. ack on the other hand has a reasonably high floor compared to the others, even in the simplest searches. This makes all benchmarks on ack take a long time.
I did a couple ad hoc benchmarks on the same machine:
ripgrep ack
linux_alternates 0.113s 9.750s
linux_alternates_casei 0.133s 19.955s
linux_literal 0.103s 7.220s
linux_literal_casei 0.122s 8.025s
linux_no_literal 0.356s 18.881s
linux_re_literal_suffix 0.104s 6.778s
linux_unicode_greek 0.194s 8.537s (ack reports no results)
linux_unicode_word 0.111s 7.299s
linux_word 0.108s 6.763s
subtitles_en_alternate 0.247s 9.829s
subtitles_en_alternate_casei 0.247s 43.091s
subtitles_ru_alternate 0.978s 28.134s
subtitles_ru_alternate_casei 0.978s 107.314s (ack reports incorrect)
subtitles_ru_surrounding_words 0.245s 6.633s (ack reports no results)
The subtitles benchmarks are perhaps unfair because I think ack is more focused on directory tree search where as ripgrep claims to be good at both. I included a few anyway to show the difference though. In general, the benchmark just isn't that interesting, and it makes the benchmark run take a lot longer than it would otherwise (because each command is executed several times).> And I'd be very curious to hear your reasoning for the different results in the subtitles_ru test cases -- why is rg returning radically different numbers of lines as compared to the other tools?
Because ripgrep correctly supports Unicode, and does it by default because it can generally handle all Unicode features without a corresponding performance loss. GNU grep handles Unicode in general as well (assuming your system's locale settings are up to snuff), but it can pay a huge price for it some cases, although admittedly, I'd consider such cases to be somewhat infrequent in common usage. It's explained in my blog post: http://blog.burntsushi.net/ripgrep/#single-file-benchmarks --- The subtitles_no_literal is particularly interesting, because it shows what happens when you ask GNU grep to do the correct thing. ;-)
Note that both ag and ucg have the opportunity to support Unicode correctly, but they don't twiddle the right flags in their use of PCRE (and PCRE2, respectively). AFAIK, neither expose a flag to twiddle these things. From scanning the ack man page, I don't see any option there either, although I'm sure Perl regexes probably have that option too.
I feel kinda sad that the only thing I can do in response is to go install ripgrep and use that instead of the alternatives.
Do you have a Patreon page? Or anything similar?
And no, I don't mix money with my free time side projects. Personal choice. Instead, just donate to a charity. My personal favorites are Rails Girls and Wikipedia. The Internet Archive is another good one!
We think that there's something weird about his Perl installation that is making it so slow, but we haven't been able to figure it out.
Here's the ticket: https://github.com/beyondgrep/ack3/issues/42
If you have any insight, we'd love to have it. We've been stumped, as you'll see if you read through the issue history.
Anyway, my Perl installation is the standard one on Archlinux. I will try on other systems.
Don't know how you'd pull it off in the current tabular format, but would be great to include some of the UX side of things: For example, I use rg almost exclusively because it has an easy-to remember syntax (`rg search-string` is a recursive search), attractively colored and well-organized output, and seems much faster compared to other tools in my use cases.
https://github.com/ggreer/the_silver_searcher/issues/385
its been over 4 years... its had its chance.
But you know there's a -r for recursive, right? And unless you are using some historic relic of grep that is not GNU or BSD and doesn't understand the --include option you can just do:
grep -rin "needle" --include "*.foo" .
find . -iname '.*' -prune -o -iname '*.foo' -exec grep needle {} +
I don't want to have to learn 10 different command syntaxes for walking directory trees, so find works well. The "+" terminator of find's exec is similar to xargs, but preserves the flexibility of find's exec.Modern file searchers, of which `ag` is one among others, accepts `--filenametype` argument and skips the `.git` subdirectory if it exists (by default, can be toggled), so `ag --python needle` will recursively search for needle in the the current working tree in all files whos filenames end in `.py`.
Yes, you could write a function to do the same in `find`, but then you're just being stubborn. (Which is fine; my .bashrc is littered with aliases and functions of me being stubborn, but if I have to copy my .bashrc file around, I might as well install my preferred searcher to the target system if available.)
Use --include and --exclude-dirs to do what you describe. (The latter is a good idea to set in your GREP_OPTIONS, unless you actually search .git directories.)
(I don't think there's any such plan for the various BSD greps, so if you use those exclusively you're probably fine.)
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.
Out of curiosity, what sort of searches do you do that smartcase is desirable? A meaningful number of people seem to prefer it, but I find that most of the time I want to be able to search for variables etc. case sensitively.
I'm generally a big fan of smartcase. Most of the time I don't care about case and it's easier to type it that way, and when I care, it's often mixed or upper case, so smartcase Does What I Mean. And for the few times when I explicitly search for all-lowercase, it's easy enough to turn it off (M-c, -s, :set nosmartcase etc.).
alias rg='rg -S'
to my .bashrc so that rg had the same default case sensitivity as ag.
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
As the ticket says (I think), tt's going to happen. It's just a lot of tedious work.
Your implementation of the gitignore algorithm is crazy impressive to me.
Ripgrep works like a charm
Ack requires Perl, which I am not going to install just for that purpose.
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.
sary - a suffix array library and tools http://sary.sourceforge.net/
It finds words in O(log(n)) time by using an additional index.
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.
> Limit directory search depth
These could be the same item, the former is a special case of the latter.