Live data from Hacker News

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

beyondgrep.com

71–80 of 101 posts

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

#71
post #19

Earlier quoted context omitted.

I've got the reverse feeling recently, as ag does smartcase searching by default and rg doesn't...

`alias rg='rg -S'` in your `.bashrc` will fix that for you. 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.

We were talking about defaults and feelings here, I'm aware that it's easy enough to fix (and to be fair, I now often use ripgrep with the inverse alias)…

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.).

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

#72
post #49
post #40

Here to plug using `--passthru`/`--passthrough`: it will print all lines, but highlight matches. I often do things like this to watch an output log, but highlight all entries with the string PLUGH in them: tail -F output.log | ag --passthrough '.*PLUGH.*'

The equivalent in grep is '--line-buffered'.

That's an orthogonal feature, it writes output after each line as opposed to every 4096 bytes, when the output is a pipe instead of a terminal. Useful when the other end of the pipe still goes to the terminal and you want to see it immediately. If `some-util-with-output` echoes stdin then without the option the following would not show you the latest grepped lines until the 4096 buffer fills.

  tail -F output.log | grep --line-buffered TEXT | some-util-with-output

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

#73
post #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 installe…

Note that if you install Rust through Debian, it likely won't be new enough to compile the latest version of ripgrep. I believe Debian packages Rust 1.14, and the last version of ripgrep to work on Rust 1.14 was 0.5.2. So, `cargo install --vers 0.5.2 ripgrep` might be what you want on Debian.

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

#74
post #66
post #11

Earlier quoted context omitted.

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…

> I do wish the persistent config file enhancement had a significant chance of becoming a reality.

As the ticket says (I think), tt's going to happen. It's just a lot of tedious work.

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

#75

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 ?

rg has been in OpenBSD packages since 6.1

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

#76

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

Unfortunately that page does not say when the comparison was made, and which version of each tool was tested. Also, which "grep" is that? I assume GNU grep? There are others, though...

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... :-)

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

#77

The chart was created by Andy Lester, the creator of ack, who thinks that more open source projects should point to their "competing" projects because it's not really a competition: http://blog.petdance.com/2018/01/02/the-best-open-source-pro...

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.…

I don't read that as a name-it-claim-it spell. I read it as an accuracy claim. That the competition is a self-fulfilling prophecy. I don't know what's "woo-woo" about that.

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

#78
post #44
post #40

Here to plug using `--passthru`/`--passthrough`: it will print all lines, but highlight matches. I often do things like this to watch an output log, but highlight all entries with the string PLUGH in them: tail -F output.log | ag --passthrough '.*PLUGH.*'

You can achieve that in almost any of these tools (including old-school grep) by matching against something with zero width, like this: grep '^|.*PLUGH.*'

You could do that.

Or you could just use --passthrough. It's easy to remember, easy to type, it autocompletes, it doesn't interfere with your criteria.

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

#79
post #70

Earlier quoted context omitted.

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.

Your view on the world shapes how you perceive the world (yes I've learned that in the tautology club) and as your reality is only what perceive, your view on reality shapes how you see it.

Not much woo woo involved.

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

#80

Earlier quoted context omitted.

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

Unfortunately that page does not say when the comparison was made, and which version of each tool was tested. Also, which "grep" is that? I assume GNU grep? There are others, though... 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 availab…

There is more detail available in the benchmark runs at https://github.com/BurntSushi/ripgrep/tree/master/benchsuite...

However, those are from 2016, and so it's hard to tell what might have changed in the meanwhile.

Post reply on HN