News for hackers. Stuff that matters.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by erezsh on Thursday November 02, 2023 @03:47AM (#38110166)
It's not clear from the README what advantages it offers over ripgrep.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by SPBS on Thursday November 02, 2023 @04:14AM (#38110391)
It's not clear from the README how even to install it, likely just an exploration of writing file searcher in Raku and not a serious attempt at replacing grep/find/ack/ag/rg.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by frou_dh on Thursday November 02, 2023 @04:39AM (#38110564)
It was introduced at a Raku Conf presentation. I remember watching it.

https://conf.raku.org/talk/174

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by imjonse on Thursday November 02, 2023 @04:56AM (#38110683)
While ripgrep is also 21st century, it's not on steroids. /s
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by kreetx on Thursday November 02, 2023 @05:01AM (#38110726)
I would go as far as to say that steroids are not a good idea most of the time anyway. :)
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by Lio on Thursday November 02, 2023 @09:55AM (#38113561)
Depends on what you use them for. I squirt them up my nose to deal with dust allergies. Steroids work great!

(...I am somewhat disappointed that I don't have a ridiculously buff nose by now but at least it matches the rest of my body).

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by pwdisswordfishc on Thursday November 02, 2023 @06:36AM (#38111503)
> /s

Thanks, I wouldn't have been able to tell otherwise.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by undebuggable on Thursday November 02, 2023 @05:11AM (#38110817)
> ripgrep

Whait what's that? I'm stuck with ag and {a..z}grep.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by cies on Thursday November 02, 2023 @06:10AM (#38111277)
BurntSushi (dev) built a grep replacement, `rg` (ripgrep), in Rust, that tends to run circles in terms of speed around grep itself and other grep replacements. The UX is also pretty nice. I install it everywhere now.

I'm curious (like others here) how `rak` is better than `rg`.

https://github.com/BurntSushi/ripgrep

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by GuB-42 on Thursday November 02, 2023 @08:20AM (#38112481)
It is "better" in the sense that it uses Raku regexes, which are incredibly powerful, and if that's not enough for you, you can even write code. "rak" is giving you a general-purpose programming language (Raku) that is optimized for text processing, with convenient shortcuts for the most common tasks.

In contrast "rg" only designed to search text files, but it does that really really fast.

I makes sense to have both.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by tialaramex on Thursday November 02, 2023 @08:38AM (#38112677)
It definitely makes sense to have this tool if you're comfortable writing Raku. I'm not sure it makes a whole lot of sense for most people to learn Raku to use this tool, and if you're not going to learn Raku I don't think there's much value add over tools like ripgrep.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by librasteve on Thursday November 02, 2023 @07:08PM (#38121706)
in a strange way I both agree and disagree with this: + I use raku a lot so it is very natural to embed raku code in a Rak CLI - I think that there a several benefits of the Rak tool that vanilla grep (or ripgrep) does not offer (eg. embedding code snippets in the expression, unicode, better regex syntax) that would probably make it worthwhile to learn the Rak examples while not having to bother with wider raku
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by burntsushi on Thursday November 02, 2023 @07:16PM (#38121787)
What Unicode support does Rak (or Raku) have that ripgrep does not?
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by lizmat on Thursday November 02, 2023 @07:52PM (#38122083)
- Support for NFG (Normalization Form Grapheme), which e.g. means that you only need to specify 'é' if you want to look for an 'é', and not have to worry about whether the text you're searching in, consists of the single codepoint 'é', or that it has the decomposed version.

- support for --ignoremark, which means you 'e' will match any accented 'e', such as éëêèęėē.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by burntsushi on Thursday November 02, 2023 @07:58PM (#38122155)
Ah yeah that's a good one! It does very likely have enormous implications for performance though. I wonder if I should add it as an opt-in feature to ripgrep. Although its support will be inherently limited in some capacity since character classes will always be limited to matching a single codepoint. (i.e., No UTS#18 Level 2 support.)

Have you found folks using these particular Unicode features in practice? I don't think anyone has request it for ripgrep.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by lizmat on Friday November 03, 2023 @05:15AM (#38126251)
> It does very likely have enormous implications for performance though.

Well, but that's only one of the reasons why rak is a lot slower. There's something else going on, but I currently don't have the mindset to investigate this deeply.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by gugod on Saturday November 04, 2023 @09:53AM (#38141001)
Both learning and the ability of tools are gradual though. For doing naive substring search all grep-alike tools works perfectly, and anyone who are willing to spend some effort and learn a bit of tool-specific features can gain a lot more more benefits.

rak is backed by the entirety of raku language and therefore is much easier for some crafting something that's less trivial to generalize in a one-liner. For most of grep-alike tools, their regex engine would be some sort of ceilings of what can be done but for rak, the ceiling is as tall as the raku programming language. That's rak's niche.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by hiAndrewQuinn on Thursday November 02, 2023 @06:18AM (#38111350)
It's phenomenal, is what it is. An extremely fast, recursive-by-default, general-purpose `grep` clone in Rust.

Alongside `fzf` and `fd` (a similar project for `find`) `rg` was what finally convinced me to put together a few shell scripts to bootstrap getting all my favorite modern command line tools on a new Ubuntu VM [1]. I'm working on an interactive playground you'll be able to SSH into to try it out yourself without even having to spin up your own, so you can see the difference with your own two eyes, no VM required.

[1]: https://github.com/hiAndrewQuinn/shell-bling-ubuntu

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by zgk7iqea on Thursday November 02, 2023 @10:54AM (#38114316)
At that point, why not use Home-Manager (nix pm) to configure your shell? Should be easier to manage
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by hiAndrewQuinn on Thursday November 02, 2023 @12:03PM (#38115513)
Actually I'm running NixOS on an old ThinkPad I have lying around here. Home Manager works great! But Ubuntu currently has the popularity network effect going for it, so.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by bberrry on Thursday November 02, 2023 @06:43AM (#38111560)
If you grep GB+ sized files, you'll love it.

At my previous job I often ended up searching raw log files sized around 5-8GB. Regular grep would grind away for 50-60 seconds, while ripgrep returned the same results in 250ms.

I was shocked the first time I used it and have sung it's praises since.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by tialaramex on Thursday November 02, 2023 @08:36AM (#38112647)
If you can afford it (these products tend to be expensive if they're doing it, and resource hungry if you're doing it, and sometimes both) and you've got logs in files, look at having the logs live in dedicated software.

I have used (at different places) Graylog and Splunk, New Relic is also popular.

Not that ripgrep isn't awesome, but you could have dedicated indexing and a UI that can be shown to non-technical or at least semi-technical people to review logs whereas "Just use ripgrep" really isn't accessible for most users.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by bberrry on Friday November 03, 2023 @03:31PM (#38133883)
Yeah we had ELK for the common logs. This file was a special case that we didn't want indexed and widely accessible because it contained sensitive data. I only occasionally needed to do some digging, so I was fine resorting to ripgrep.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by undebuggable on Saturday November 04, 2023 @04:27AM (#38139116)
> If you grep GB+ sized files, you'll love it.

TBH more frequently I have "argument list too long" problem, than "one 5GB file" problem.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by pawelduda on Thursday November 02, 2023 @06:59AM (#38111687)
ripgrep is blazing fast grep
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by twic on Thursday November 02, 2023 @08:09AM (#38112376)
To me, the two big things about ripgrep are (1) it's much more oriented towards the use case of searching a directory hierarchy full of code, eg by default it's recursive and respects .gitignore, it has a --type flag which knows various kinds of source files (eg --type c will only look at .c and .h files), etc, and (2) it's fast - uses all the lastest and greatest algorithms, and makes heavy use of parallelism. It's also just generally good and sensible.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by mkl on Thursday November 02, 2023 @06:14AM (#38111316)
The README seems to make it clear that increased finger exercise is an advantage (steroids are used for increasing muscle mass, after all).

Instead of just typing

  rg '\bfoo\b'
you get to type

  rak '/ << foo >> /'
and instead of just typing

  rg -B2 -A2 foo
or

  rg -C2 foo
you get to type

  rak foo --before=2 --after=2
(over double the characters!) and instead of just typing

  rg 'foo.*bar|bar.*foo'
you get to type

  rak '{.contains("foo") && .contains("bar")}'
which has double the characters and also has the advantage of writing each pattern only once.

Okay, I haven't actually tried it (and the README doesn't say how to), and rak does have a bunch of features and capabilities ripgrep doesn't have, but those first examples are not very inspiring after the big initial claim.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by sshine on Thursday November 02, 2023 @06:17AM (#38111345)

  rg -B2 -A2 foo
can be written as

  rg -C2 foo
although this does not underline your point as much.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by mkl on Thursday November 02, 2023 @06:19AM (#38111356)
Yep, edited that in as you were commenting.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by nerdponx on Thursday November 02, 2023 @07:14AM (#38111796)
Perhaps for further emphasis:

  grep -R -C2 foo .
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by darrenf on Thursday November 02, 2023 @06:46AM (#38111576)
The examples are all undeniably verbose, but the source shows that many short options are also supported, specifically to copy those you would expect if migrating from the alternatives: https://github.com/lizmat/App-Rak/blob/main/lib/App/Rak.raku...

So

    rak -C2 foo
will do what you expect.

[Edited to add] Also, the `\b...\b` form is shorter with rak - as the README also states where it documents this pattern form:

> §string

> If the pattern starts with §, then it indicates that the string should occur as a word (with word-boundaris on both ends) in the item. Basically a shortcut to specifying string --type=words. Any --smartcase, --smartmark, --ignorecase or --ignoremark arguments will be honoured.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by mkl on Thursday November 02, 2023 @06:56AM (#38111663)
Yes, I'm mainly complaining at the choice of examples, which don't seem to back up the claim of being "rg on steroids" at all.

Typing § is not very easy on most keyboards, and is actually impossible on some keyboard-OS combinations (including mine): https://en.wikipedia.org/wiki/Section_sign#Keyboard_entry

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by 2colours on Thursday November 02, 2023 @08:38AM (#38112673)
Some diversity doesn't hurt, though. On my keyboard, it's actually easier to type than the backslash for starters.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by switch007 on Thursday November 02, 2023 @07:11AM (#38111764)
> §string

> If the pattern starts with §,

Is it April 1st already?!

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by ta8645 on Thursday November 02, 2023 @09:41AM (#38113386)
Raku embraces Unicode in a big way, and probably influenced this decision.

I wonder if keyboards in the future will settle on a way to provide access to more characters, than is currently common.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by throwawaaarrgh on Thursday November 02, 2023 @11:02AM (#38114463)
Fwiw, § is ASCII code 167, the "Section symbol". Long been used as a record separator and section marker.

I agree the keyboard thing is really annoying. Maybe the West should investigate the efforts China has put into different typing systems.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by burntsushi on Thursday November 02, 2023 @11:10AM (#38114594)
That's not correct. ASCII has only 128 codepoints and its maximum value is 127 or 0x7F. Code 167 is not part of ASCII. You're probably thinking of ISO 8859-1.

U+00A7 (codepoint 167) is also the Unicode codepoint for §. Its use on this very web page is via Unicode and the UTF-8 encoding as the bytes \xC2\xA7.

(This is meant as a narrow correction. It doesn't really change the broader point that § is not exactly easy to type on most keyboards. Whether its ASCII or not.)

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by throwawaaarrgh on Thursday November 02, 2023 @11:22AM (#38114777)
Sorry, you're right. I guess I meant 8859-1 as opposed to Windows codepages or Unicode-exclusive. My Western bias is showing as I don't know if there are old locales that wouldn't have it that would affect any international users, but I assume not?
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by lizmat on Monday November 06, 2023 @06:24AM (#38161151)
FWIW, on some MacBook Pro keyboards, the § is right next to 1:

https://keyshorts.com/blogs/blog/37615873-how-to-identify-ma...

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by IshKebab on Thursday November 02, 2023 @11:47AM (#38115192)
Come on, you can make an equally sarcastic argument about how difficult to remember and error prone regexes/short options are.

Do the "contains" example with 5 terms.

Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by mkl on Thursday November 02, 2023 @05:26PM (#38120391)
> Do the "contains" example with 5 terms.

  rg foo1 | rg foo2 | rg foo3 | rg foo4 | rg foo5
vs

  rak '{.contains("foo1") && .contains("foo2") && .contains("foo3") && .contains("foo4") && .contains("foo5")}'
My point is that despite their claim of superiority, their examples do not show any. Maybe there's a more efficient rak way to do that chain of .contains? Why not demonstrate that?
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by hwayne on Thursday November 02, 2023 @05:52PM (#38120758)
I haven't tried this in Rak proper, but based on my understanding of the README you can do something like the following:

    rak '{so one ["foo1", "foo2", "foo3"].map(-> \x{$_.contains(x)})}'
That's a bit though; it'll match lines that contain exactly one of "foo1", "foo2", "foo3", but not zero or 2+.
Re:App: Rak – 21st century grep / find / ack / ag / rg on st... by lizmat on Monday November 06, 2023 @06:28AM (#38161177)
$ rak '{.contains: "foo1" & "foo2" & "foo3" & "foo4" &"foo5"}'

This actually shows one of the secret powers of the Raku Programming Language: Junctions https://docs.raku.org/type/Junction

Alternately one could express this as:

$ rak '{.contains: <foo1 foo2 foo3 foo4 foo5>.all}'

Or using whatever currying: https://docs.raku.org/type/Whatever

$ rak '*.contains: <foo1 foo2 foo3 foo4 foo5>.all'