3 ms·
Fewer bugs? And perf depends on your haystack size. If you have lots of data to search, it's not hard to witness a 10x difference: https://news.ycombinator.com
by burntsushi 1y ago
Fewer bugs?
And perf depends on your haystack size. If you have lots of data to search, it's not hard to witness a 10x difference: https://news.ycombinator.com/item?id=45629904 https://news.ycombinator.com/item?id=45629904
As for features that ripgrep has that ag doesn't:
* Much better Unicode support. (ag's is virtually non-existent.)
* Pluggable preprocessors with --pre.
* Jujutsu support.
* ripgrep can automatically search UTF-16 data.
* ripgrep has PCRE2 support. ag only has PCRE1 (which was EOL'd years ago).
* ripgrep has a `-r/--replace` flag that lets you manipulate the output. I use it a lot instead of `sed` or `awk` (for basic cases) these days.
* ripgrep is maintained.
* ripgrep has multiline search that seemingly works much better.
* ripgrep can search files bigger than 2GB. ag seemingly can't.
* ag has lots of whacky bugs.
e.g.,
$ ag -c '\w{8,} Sherlock Holmes' sixteenth.txt
9
$ rg -c '\w{8,} Sherlock Holmes' sixteenth.txt
9
$ cat sixteenth.txt | rg -c '\w{8,} Sherlock Holmes'
9
$ cat sixteenth.txt | ag -c '\w{8,} Sherlock Holmes'
1
1
1
1
1
1
1
1
1
Or:
$ printf 'foo\nbar\n' | ag 'foo\s+bar'
$ printf 'foo\nbar\n' | rg -U 'foo\s+bar'
foo
bar
Or:
$ ag '\w+ Sherlock Holmes' full.txt
ERR: Skipping full.txt: pcre_exec() can't handle files larger than 2147483647 bytes.
There's probably more. But that's what comes to mind.
- rurban 1y agoBut unicode support is still nuclear. In unicode you can write the same graphemes in many different ways. And if you go to non-unicode supported language specifics, like ue standing for ü, where the ü can be written in two different ways, with marks and directly, neither ripgrep nor ugrep will help find those substrings. Also the many Arabic subtleties, where there are not only mark combinations, but also more beautiful characters meaning the same graphemes.
- burntsushi 1y agoIdk what "still nuclear" means. And yes, ripgrep doesn't do any kind of Unicode normalization. Few tools do. But that doesn't mean what I said was wrong. ripgrep has a whole host of Unicode features that ag doesn't have.
- kccqzy 1y agoThanks! I'm giving rg a try. Right now the only issue I'm facing is that rg's -g flag is less expressive than ag's -G flag. The latter allows specifying a regular expression for the file name to search in. The rg's version only uses globs. This means it's a bit more typing for common cases and a bit less flexible.