Live data from Hacker News

Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

blog.burntsushi.net

111–120 of 198 posts

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#111
post #62

Earlier quoted context omitted.

I wrote a bash version of this: function frg { result=`rg --ignore-case --color=always --line-number --no-heading "$@" | fzf --ansi \ --color 'hl:-1:underline,hl+:-1:underline:reverse' \ --delimiter ':' \ --preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" \ --preview-window 'up,60%,border-bottom,+{2}+3/3,~3'` file="${result%%:*}" linenumber=`echo "${result}" | cut -d: -f2` if [ ! -z "…

I've never really seen PowerShell beyond minimal commands, but after seeing the parent, I definitely think it has the superior syntax of the shells. Especially for scripts.

Maybe if the "popular" shells, but http://www.nushell.sh/ is looking better and better

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#112
post #62

Earlier quoted context omitted.

I wrote a bash version of this: function frg { result=`rg --ignore-case --color=always --line-number --no-heading "$@" | fzf --ansi \ --color 'hl:-1:underline,hl+:-1:underline:reverse' \ --delimiter ':' \ --preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" \ --preview-window 'up,60%,border-bottom,+{2}+3/3,~3'` file="${result%%:*}" linenumber=`echo "${result}" | cut -d: -f2` if [ ! -z "…

I've never really seen PowerShell beyond minimal commands, but after seeing the parent, I definitely think it has the superior syntax of the shells. Especially for scripts.

A lot of people sleep on PowerShell, possibly because some of the syntax is a little clunky (and quite slow compared to some other shells, I will freely admit). That being said, I'd argue object oriented programming is a massive improvement over text oriented programming. I never want to touch awk again!

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#113
post #71

Earlier quoted context omitted.

I guess it is because after decades of use, grep has probably been fixed to handle lots of user cases that the new tools don´t handle because they haven´t found them yet.

Author of ripgrep here. Like automatic encoding detection and transparently searching UTF-16? Or simple ways for composing character classes, e.g., `[\pL&&\p{Greek}]` for all codepoints in the Greek script that are letters. Another favorite of mine is `\P{ascii}`, which will search for any codepoint that isn't in the ASCII subset. Or more sophisticated filtering features that let you automatically respect things like…

[deleted]

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#114
post #111

Earlier quoted context omitted.

I've never really seen PowerShell beyond minimal commands, but after seeing the parent, I definitely think it has the superior syntax of the shells. Especially for scripts.

Maybe if the "popular" shells, but http://www.nushell.sh/ is looking better and better

nu acknowledged powershell as one of its inspirations, yeah!!

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#117
post #30

I switched from from ripgrep to ugrep and never looked back. It's just as fast, but also comes with fuzzy matching (which is super useful), a TUI (useful for code reviews), and can also search in PDFs, archives, etc. The optional Google search syntax also very convenient. https://ugrep.com

So I was casually searching for "ugrep vs ripgrep" articles, when I stumbled upon a couple reddit posts where apparently the authors of ugrep and ripgrep seemed to have a multi-year feud on reddit, eg. https://www.reddit.com/r/programming/comments/120wqvr/ripgre... So weird. I mean, it's just about some open source tool, right? :-/

I came across ugrep recently and I immediately recognized the organization as one that I had dealt with starting about 15 years go. The author is brilliant‡, but extremely prickly (sometimes even to paying customers). The author of ripgrep, on the other hand, has always seemed like someone who just wants to get on with the business of writing software that people use.

‡ The main commercial product of the ugrep author's company at the time was the gSOAP code generator (it may still be), and that it not only works but makes a reasonably good C and C++ API from WSDL is proof that it is the product of a genius madman. It also allowed you to create both the API and WSDL from a C++-ish header, and both .NET and Java WSDL tools worked perfectly with it. We needed it to work and work it did.

At the time, the generated API was just difficult enough to use that I generated another ~1k lines of code for that project. IIRC, the generated API is sort of handle-based, which requires a slightly different approach than the strict RAII approach we were using. Generating that code was a minor adventure (generating the gSOAP code from the header-ish file, generating doxygen XML from the generated gSOAP code, then generating the wrapper C++ from the doxygen XML).

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#118
post #38

What are the reasons for grep not being replaced/improved? This topic seems a bit old by now.

grep is a general purpose tool for searching for text in all types of files, baked into the standards for UNIX. Some programmers use it to search source code. Other people use it for other types of text searches that have nothing to do with source code, they rely on it in scripts, they don't use it as part of a text-based programmer UI, they rely on it to never crash, etc. ripgrep is a specialist, opinionated tool, d…

> you can make it use mmap() at the risk of it crashing on truncated files

I was under the impression that grep removed mmap() support because it was slower than normal file i/o

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#119
post #38

What are the reasons for grep not being replaced/improved? This topic seems a bit old by now.

grep is a general purpose tool for searching for text in all types of files, baked into the standards for UNIX. Some programmers use it to search source code. Other people use it for other types of text searches that have nothing to do with source code, they rely on it in scripts, they don't use it as part of a text-based programmer UI, they rely on it to never crash, etc. ripgrep is a specialist, opinionated tool, d…

> There's not much you can add to general purpose text search to make it faster

Oh I beg to differ! The blog post goes into this. Here's a simple demonstration using ripgrep 14:

    $ ls -l full.txt
    -rw-rw-r-- 1 andrew users 13113340782 Sep 29 12:30 full.txt

    $ time rg -c --no-mmap 'Clipton' full.txt
    294

    real    1.419
    user    0.539
    sys     0.879
    maxmem  15 MB
    faults  0

    $ time LC_ALL=C grep -c 'Clipton' full.txt
    294

    real    6.911
    user    6.078
    sys     0.829
    maxmem  15 MB
    faults  0

    $ time rg -c --no-mmap 'DMZ|Clipton' full.txt
    1070

    real    1.643
    user    0.747
    sys     0.894
    maxmem  15 MB
    faults  0

    $ time LC_ALL=C grep -E -c 'DMZ|Clipton' full.txt
    1070

    real    8.317
    user    7.384
    sys     0.930
    maxmem  15 MB
    faults  0
No memory maps. No multi-threading. No filtering. No fancy regex engine features or reducing expressiveness. No locales. No UTF-8. No UTF-16. Just a simple literal and a simple alternation of literals. It's just better algorithms.

Also, you can disable ripgrep's opinions with `-uuu`. It's not designed to just be for code searching. You can use it for normal grepping too. It will even automatically revert to the standard grep line format in shell pipelines.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#120

Earlier quoted context omitted.

grep is a general purpose tool for searching for text in all types of files, baked into the standards for UNIX. Some programmers use it to search source code. Other people use it for other types of text searches that have nothing to do with source code, they rely on it in scripts, they don't use it as part of a text-based programmer UI, they rely on it to never crash, etc. ripgrep is a specialist, opinionated tool, d…

> you can make it use mmap() at the risk of it crashing on truncated files I was under the impression that grep removed mmap() support because it was slower than normal file i/o

I talked about this in the OP. Memory maps are sometimes a little faster. See:

    $ ls -l full.txt
    -rw-rw-r-- 1 andrew users 13113340782 Sep 29 12:30 full.txt

    $ time rg -c --no-mmap Clipton full.txt
    294

    real    1.337
    user    0.470
    sys     0.866
    maxmem  15 MB
    faults  0

    $ time rg -c --mmap Clipton full.txt
    294

    real    1.045
    user    0.722
    sys     0.323
    maxmem  12511 MB
    faults  0
But in recursive search, especially when used for lots of little files, they end up provoking substantial overhead that slows everything down.

And this might change depending on the platform.

Post reply on HN