Remix.run Logo
vessenes 14 hours ago

rg is a first for me in that it's a CLI tool that an LLM taught me about -- it's a go-to tool for Claude and codex, and since I got most of my bash skills pre-dotcom-one-boom I'm historically just a grep user.

Anyway I'm trying to retrain the fingers these days, rg is super cool.

sshine 14 hours ago | parent | next [-]

I switched to `ack` in 2017 because it handles recursive searches better.

I didn't bother switching to `ag` when it came around because of having to retrain.

But eventually I did switch to `rg` because it just has so many conveniences.

I even switched to `fd` recently instead of `find` because it's easier and less typing for common use-cases.

I've been using the terminal since 1997, so I'm happy I can still learn new things and use improved commands.

ahartmetz 13 hours ago | parent | next [-]

In my case, I am still using ag because rg doesn't seem to be better enough to switch. What's the big deal with rg vs ag?

I had a similar thing with bash vs zsh before I learned about oh-my-zsh. Nushell also seems attractive these days... the good stuff from PowerShell in a POSIX-like shell.

burntsushi 13 hours ago | parent [-]

ripgrep is a lot faster (which you might only notice on larger haystacks), has many fewer bugs and is maintained.

ahartmetz 11 hours ago | parent [-]

ag is plenty fast (gigabytes in a fraction of a second) for me - I'd switch in a heartbeat if that wasn't so. Any bugs, hm, I guess I just haven't run into them. Thanks for the reply though! I realize who replied here ;)

burntsushi 10 hours ago | parent [-]

Look at ag's issue tracker. There are some very critical bugs. You might be impacted by them and not even know it.

As for perf, it's not hard to witness a 10x improvement that you'll actually feel. On my checkout of the Linux kernel:

    $ (time rg -wi '\w+(PM_RESUME|LINK_REQ)') | wc -l

    real    0.114
    user    0.547
    sys     0.543
    maxmem  29 MB
    faults  0
    444

    $ (time ag -wi '\w+(PM_RESUME|LINK_REQ)') | wc -l

    real    0.949
    user    6.618
    sys     0.805
    maxmem  65 MB
    faults  0
    444
Or even basic queries can have a pretty big difference. In my checkout of the Chromium repository:

    $ (time rg Openbox) | wc -l

    real    0.296
    user    1.349
    sys     1.950
    maxmem  71 MB
    faults  0
    11

    $ (time ag Openbox) | wc -l

    real    1.528
    user    1.849
    sys     8.285
    maxmem  29 MB
    faults  0
    11
Or even more basic. You might search a file that is "too big" for ag:

    $ time ag '^\w{42}$' full.txt
    ERR: Skipping full.txt: pcre_exec() can't handle files larger than 2147483647 bytes.
EliMdoza 6 hours ago | parent [-]

been using both for many years now, have never ran into issues or even been able to tell any difference in speed, let alone 10x

what I notice unfortunatly, is that I often miss search results with rg becuase I forget I need to pass the additional -i flag. this has shaped my perception of rg - extra focus on performance, sub-optimal ux

burntsushi 5 hours ago | parent [-]

Whether smart case is enabled by default (as ag does) could easily go either way. Notably,.I think having it disabled by default is a better UX. But ripgrep does have a --smart-case flag, which you can add to an alias or a ripgrep config file. It also works more consistently than ag's smart case feature, which has bugs.

See my other comments about perf difference. And ag has several very critical bugs. And it's unmaintained.

> or even been able to tell any difference in speed

If you only search small amounts of data, then even a naive and very slow grep is likely just fine from a perf perspective.

dotancohen 14 hours ago | parent | prev [-]

Sell me on fd. I occasionally use find, mostly with the -name or -iname flags.

rkomorn 14 hours ago | parent | next [-]

It feels nearly instant by comparison to find. That's been enough for me.

lawn 13 hours ago | parent | prev [-]

You don't have to type -name for the 1000th time.

dotancohen 7 hours ago | parent [-]

Thanks.

For other people, on Ubuntu install the `fd-find` package. The executable is named `fdfind` (no dash).

dotancohen 14 hours ago | parent | prev [-]

Through I use rg to initiate searches, my muscle memory keeps using grep after pipes.

WJW 12 hours ago | parent | next [-]

Huh I hadn't even realized I did that. I think grep has the "filter in pipe" spot in my head while rg has the "search recursively in all files" spot.

burntsushi 12 hours ago | parent [-]

I did it too, even after I initially released ripgrep. At this point, I've mostly re-trained my muscle memory to use `rg` in pipelines. (Particularly because I was careful to make sure `rg` worked just like `grep` does in pipelines.)

I also find that combining `-o/--only-matching` and `-r/--replace` has replaced many of my uses of `sed` and `awk`.

kstrauser 12 hours ago | parent | prev [-]

Heh, I realized the same for myself the other day. I’ve been deliberately making myself go back and change it to rg to try to replace the muscle memory.