12 ms·
App::Rak – 21st century grep / find / ack / ag / rg on steroids
- fastball 3y agoThis is my first time hearing about Raku (the language this tool is apparently written in), and after a quick look at the website[1], I am not sure why I would want to use Raku vs any other language in particular. According to the guide[2]: > Raku is a high-level, general-purpose, gradually typed language. Raku is multi-paradigmatic. It supports Procedural, Object Oriented, and Functional programming. That really doesn't tell me enough. Anyone else have any idea why I might want to use Raku vs one of the many other langs to which those adjectives can be applied? [1] https://docs.raku.org/ https://docs.raku.org/ [2] https://raku.guide/#_what_is_raku https://raku.guide/#_what_is_raku
- adr1an 3y agoRegEx probably, since raku is perl 6 afaik.
- dartos 3y agoYeah it’s basically a language purpose made for matching text
- gmueckl 3y agoIt has evolved to be much, much more. It is a somewhat pragmatic, powerful, malleable multi-paradigm language that can be (has been) applied to many use cases beyond text processing. I am only vaguely familiar with the language, but I'm often impressed by examples of it's power and expressiveness.
- PhilipRoman 3y agoRaku is a Perl descendant so it's goals are the same as Perl's (for the most part). From what I've seen it is supposed to be a terse language for rapid prototyping, it has syntax support for a lot of common idioms (and of course since it came from Perl you can expect some of the best pattern matching support in the world). For me the performance is a dealbreaker, but otherwise it looks pretty good.
- melezhik 3y agoThe are lot of tasks that don’t require performance, so if you are not going to write embedded / real-time system - you should be fine
- nsrahmad 3y agoI really like this post about Raku: "Raku : A Language for Gremlins" https://buttondown.email/hillelwayne/archive/raku-a-language-for-gremlins/ https://buttondown.email/hillelwayne/archive/raku-a-language...
- kristopolous 3y agoraku is perl 6, it's just called "raku" now. Given that, it's 23 years old and done by Larry Wall so it's not exactly yet another fly-by-night hype language, just something that is not in the top 50.
- lloeki 3y ago> raku is perl 6 It used to be, but not anymore. It has grown to be its own thing with some happenstance parenthood through being born from an early attempt at Perl 6, and thus is now only being slightly more related to Perl than e.g Ruby is. Ok I'm pushing it but you get the idea: taking a biological analogy, it has mutated away far enough that it is now considered to be its own strain. And if that helps clear some doubts, Perl 7 is on the table (if there ever needs to be a Perl 7): At some point in the future, the PSC may decide that the set of features, taken together, represent a big enough step forward to justify a new baseline for Perl. If that happens, then the version will be bumped to 7.0. https://blogs.perl.org/users/psc/2022/05/what-happened-to-perl-7.html https://blogs.perl.org/users/psc/2022/05/what-happened-to-pe... So Raku cannot be Perl 6!
- kristopolous 3y agoWell right, "perl 6" quickly became a bad name for the project - they should have switched to something like "raku" maybe 20 years ago. Given that, nobody got the memo, so calling it "perl 6" is still a very fast way to orient people as to what it's a neighbor of.
- msla 3y agoThe big thing Raku offers is grammars as a built-in language feature: https://docs.raku.org/language/grammar_tutorial https://docs.raku.org/language/grammar_tutorial > Regular expressions (Regexes) work well for finding patterns in strings. However, for some tasks, like finding multiple patterns at once, or combining patterns, or testing for patterns that may surround strings regular expressions, alone, are not enough. > When working with HTML, you could define a grammar to recognize HTML tags, both the opening and closing elements, and the text in between. You could then organize these elements into data structures, such as arrays or hashes.
- zokier 3y agoTo me the first adjectives that come to mind for Raku are quirky and clever. I feel it can be extremely expressive at times, with really good happy path. It is at the same time anti-blub but also steers away from academic ivory towers, instead it is very much hacker/power-user oriented. (disclaimer: I don't actually know Raku that well, but it is very high on my list of languages to learn)
- melezhik 3y agoBecause it provides one with a lot of flexibility out of the box while not forcing you into a specific programming style and without any additional overhead or costs … OOP, functional programming, strong/dynamic typing, declarative /imperative - you’ve got it, we got you covered
- erezsh 3y agoIt's not clear from the README what advantages it offers over ripgrep.
- SPBS 3y agoIt'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.
- frou_dh 3y agoIt was introduced at a Raku Conf presentation. I remember watching it. https://conf.raku.org/talk/174 https://conf.raku.org/talk/174 https://dev.to/lizmat/its-time-to-rak-part-1-30ji https://dev.to/lizmat/its-time-to-rak-part-1-30ji
- imjonse 3y agoWhile ripgrep is also 21st century, it's not on steroids. /s
- kreetx 3y agoI would go as far as to say that steroids are not a good idea most of the time anyway. :)
- Lio 3y agoDepends 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).
- pwdisswordfishc 3y ago> /s Thanks, I wouldn't have been able to tell otherwise.
- undebuggable 3y ago
- ChoHag 3y ago[dead]
- tannhaeuser 3y agoWe're still busy excising the 90's replacement for awk ...
- dmos62 3y agoPretty good replacement it turned out to be!
- Yizahi 3y agoThere is problem with nice modern Linux tools - they are not available on the generic servers and embedded boxes with you will likely use, or in the image someone else has given you etc. Therefore it is pointless (sorry for the strong term) to learn them, because they simply won't be available for when they are most needed. And learning new tools is not a free process, there are costs, mental and time.
- burntsushi 3y agoI think you need to caveat the word "pointless" heavily. If 95% of the commands I type are in my local dev environment where I can install a variety of tools, then I don't see how it's pointless to learn different tools for the common case. Otherwise, you're just needlessly limiting yourself to a constrained set of tooling with zero opportunity for any kind of progress or improvement. Even though I'm the author of ripgrep, believe it or not, I still use grep in those 5% of cases without any kind of fuss.
- topaz0 3y agoThis is probably a good default position for a random new tool that floats across hacker news, but there are plenty of situations where the benefits of having a tool (even if only in your local environment) outweigh the effort of learning it and getting it.
- kstrauser 3y agoI reject that heartily. I spend 90% of my shell time on my own machine, and I want it to be comfortable. Here “at home” I use nice editors, and Fish shell, and ripgrep/fzf/etc., because they make my daily life more pleasant and productive. Some remote servers are minimal to the point that they only have Bourne shell and plain vi available, and when I’m working on them, that’s what I use. But darned if I want to handcuff myself to the greatest common denominator in my daily work. I promise, you can learn both grep and ripgrep at the same time.
- librasteve 3y agoand Rak too ;-)
- deleted 3y ago[deleted]
- burntsushi 3y agoAuthor of ripgrep here. Very cool! It looks like Rak has a lot of nice features. I will say that getting this thing built took some digging. Could you please add install/build instructions to the README? As it is, I had to go sleuthing through your CI setup to figure it out. On Archlinux, here's what I did: $ yay -S rakudo-bin $ export PATH="/usr/share/perl6/site/bin:$PATH" $ git clone https://github.com/lizmat/App-Rak $ cd App-Rak $ zef install . $ export PATH="$HOME/.raku/bin:$PATH" I realize features and an expressive language is your main goal, but I wanted to see what it looked like from a perf perspective: $ git remote -v origin git@github.com:rust-lang/rust (fetch) origin git@github.com:rust-lang/rust (push) $ git rev-parse HEAD 699f4a637ef382ea0716c72f60d0c1c4cd79df41 $ time rg accelerated --files-with-matches compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs src/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp src/llvm-project/llvm/docs/PDB/HashTable.rst real 0.126 user 0.544 sys 0.850 maxmem 22 MB faults 0 $ time rak accelerated --files-with-matches compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs src/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp src/llvm-project/llvm/docs/PDB/HashTable.rst real 17.005 user 2:07.88 sys 8.866 maxmem 1565 MB faults 0 I'm not totally clear on what kind of filtering `rak` does by default, so I also ran a search on a single plain text file: $ cd /dev/shm $ curl -LO https://burntsushi.net/stuff/opensubtitles/2018/en/sixteenth.txt.gz $ gunzip sixteenth.txt.gz $ time rg 'Sherlock Holmes' sixteenth.txt -c 426 real 0.068 user 0.047 sys 0.020 maxmem 778 MB faults 0 $ time rg 'Sherlock Holmes' sixteenth.txt -c --no-mmap 426 real 0.089 user 0.026 sys 0.063 maxmem 14 MB faults 0 $ time rak 'Sherlock Holmes' sixteenth.txt --count-only 426 matches in 1 file real 48.236 user 48.010 sys 0.334 maxmem 215 MB faults 0 $ time grep 'Sherlock Holmes' sixteenth.txt -c 426 real 0.297 user 0.233 sys 0.063 maxmem 14 MB faults 0
- jedisct1 3y agoYou forgot ugrep.
- larodi 3y agodefinitely not going to install cursed Raku for this single search lib. perhaps if they had a distributed binary in some byte-code format, but they don't. because forked-Perl-guys were busy figuring how to use all the Unicode and outpace APL in complexity, while others were figuring how to target reasonably large distribution medium (think wasm, .net, and jre if u want). besides, ripgrep IS much more state of the art than anything else out there. very fast and can fallback to pcre2 for weird lookahead and utf8 (if i remember correctly, sorry). we have to admit that BurntSushi made incredibly good job at it. ACTUALLY what I need most of the times is qgrep which can grep regexes in 100k files in less than second. is re2 + index essentially and none of its cousins can do similar searches reasonably fast. the only downside - it indexes per-line, so if you wanna grep some fancy multiline-SQL you have to do second pass over the files that match on more general basis not sure why codeql could not get up to speed with SQL, but I've several times considered actually using multi-passes with tree-sitter in order to dig some SQL neatly hidden in multiline concatenated Java strings. why? well, the usual "order of things" in many large projects is after all nothing more than respectful mess of entangled enterprise-level orchestration (code) piled years after years. i guess this' why someone at google had to write qgrep to dig the monorepo.
- frou_dh 3y agoI thought Raku can/could run on the JVM, but presumably the number of people actually doing so is very low so maybe it's fallen into disrepair.
- _v7gu 3y agoAPL is one of the least complex languages I know (simplest being Lisp); there isn’t much syntax to learn and the language doesn’t really have implicit footguns. You just string together function applications and modify some of those functions with adverbs
- larodi 3y agoI meant this -> https://en.wikipedia.org/wiki/Digital_encoding_of_APL_symbols https://en.wikipedia.org/wiki/Digital_encoding_of_APL_symbol..., not the language construct. Let me give an allegory - perhaps not exact, but you'll get my point. Much of the mathematics (either discreet, differential, computation geometry, etc) is actually not so difficult to understand when told right... but incidentally, there were some folks back in the day who decided to write it using the whole greek alphabet and then some cryptic symbols in it (like these https://cloford.com/resources/charcodes/utf-8_mathematical.htm https://cloford.com/resources/charcodes/utf-8_mathematical.h...). By doing so they effectively formed some weird cryptic cult of the Mathematicians, which eventually repelled many people away from the discipline, and still do. Later one, some perhaps not so smart people, figured how to express stuff as 'sum', 'product' in for-loops and suddenly the whole world was writing programs while decrying math as complex. even though... programs are logic are math, right?
- pie_flavor 3y agoSince the rest of the comments are about the language, I guess mine may as well be too. I was wondering why, in your coding style, you always use $y.ACCEPTS($x) instead of $x ~~ $y?
- lizmat 3y agoI assume this is directed at the author of rak, so I'll answer. $x ~~ $y is basically syntactic sugar for $y.ACCEPTS($x). Using ~~ involves an additional subroutine call, so there's a short-term efficiency issue (as in programs running more than a second or so the extra call will have been inlined). But personally, I like the verbosity of $y.ACCEPTS($x) as it reads better for me, having been burnt by ~~ semantics in Perl, which was symmetrical.