🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
moon-child wrong 00:00
gfldex moon-child: this might be helpful: raw.githubusercontent.com/gfldex/b...u-test-all 00:28
AlexDaniel` > A bit trickier. What if to match a range against another range? 01:47
the course is weird :)
I don't know why it suggests to try something that in real life you're really unlikely to use
but even when not taking strings into account: 01:48
m: say 1..^3 ~~ 1..2
camelia False
AlexDaniel` okay so maybe you'd consider this right
m: say 100..-100 ~~ 1..2 01:49
camelia True
AlexDaniel` but this?
and then it goes to show a bare `unless` block 01:52
“programming in alternate reality” it should've been called
using while, using until, using repeat 01:54
sure, the most common types of loops
hungrydonkey m: say 1..2 ~~ 100..-100 02:07
camelia False
hungrydonkey m: say 100..98 ~~ 1..2 02:10
camelia False
hungrydonkey m: say 100..1 ~~ 1..2 02:11
camelia True
sortiz hungrydonkey: "Ranges always go from small to larger elements; if the start point is bigger than the end point, the range is considered empty."
hungrydonkey but how to explain `100..1 ~~ 1..2` is True and `100..98 ~~ 1..2` is False? 02:12
put 100..1, 100..98 02:13
evalable6
hungrydonkey so wired 02:14
sortiz Indeed, the second case surprises me
hungrydonkey sorry, s/wired/weird/ :) 02:16
sortiz Um, maybe generate Empty for unordered Ranges at creation time can simplify the code. 02:23
melezhik . 02:30
RaycatWhoDat Hey, all. Was wondering about the Raku ecosystem. 02:58
tony-o lizmat: i stand corrected, apparently i did this article: deathbyperl6.com/zef-ecosystem/
RaycatWhoDat Which packages are considered the ironclad, battle-tested packages? 02:59
Also, apologies if I've asked this before.
tony-o a year ago : )
what type of package RaycatWhoDat 03:22
guifa Wow, someone had a very bad day 04:19
Did y’all see this hot mess? www.reddit.com/r/rakulang/comments...ggin_slow/
tony-o he's not terribly off base regarding speed. C is also slow when compared to assembly, op is not not very precise. python3 is awfully slow and, compared to raku, is featureless - so that kind of post generally depends on the background of the person imo 04:39
samebchase- well personally speaking, I use Raku because it saves me hours of developer time, as opposed to seconds of computer time 04:40
guifa I just want to know why he’d want a Map with Int keys 04:41
isn’t that called … gasp, an Array?
samebchase- guifa: hah
tony-o only if it's not too sparse an array 04:43
if performance was a major concern i wouldn't venture too much above C so it seems like kind of a moot complaint 04:45
moon-child assembly is not generally much faster than c. (THough in some pathological cases it will be much faster)
python pretty fast with pypy or graalpython
tony-o python3 is terribly slow
guifa I think what he fails to get is that if you think a default class runs slow or does something you don’t like, you can always write a new one 04:46
notandinus so zef fails with `No candidate found for 'zef'.` 06:50
what might be causing this?
notandinus also, do i just run ./bin/rstar fectch && install again to upgrade my rakudo star distribution? 07:15
xinming SmokeMachine: I'm not sure wether it's caused by optimizer, but now, I'm busy dev'ing something, and I found a lot of headache when doing complex grep condition, so I wish to disable it and make job done first. 14:00
SmokeMachine xinming: I’ll make it possible to do `use Red <no-optimization>` when possible 14:03
notandinus ttm.sh/d1B -- it runs in 5.661s (real) on tio.run but takes 42s on mine, i'll test it on another openbsd machine soon to see if thats the issue. for some reason raku runs really slow on my machine
is `raku -e ""` taking 0.9s (real) normal? 14:04
moritz no 14:05
more like 0.35s for me, with cold caches 14:06
(but SSD)
and 0.14, 0.15s with warm caches
notandinus i see, slurp loads the whole file to memory at once right? 14:08
i'll test how much time loading that file takes
slurp for that file takes 2.7s(real) 14:10
oh wait, i'll also profile it
moritz right, slurp reads everything at once into memory 14:11
notandinus how do i interpret this call graph? ttm.sh/dX2.png 14:15
that yellow call on bottom mid is "word-search" its what searches the grid for specific words 14:16
ttm.sh/dXu.png -- red (interpreted) frames are just ~7%, and 165 GC calls were made 14:18
also, is there a good resource on reading profiler report ? 14:19
raku-bridge <ionsolo> Hey!! I have recently switched from 'mx linux' to 'popOS' and I noticed that parallel functions in raku doesn't work anymore (in mx Linux arithmetic operation over a list run on several cores now not) I'm not a systems person but I tried what I'm capable of: 1.- Repo versions are 2020.6 (doesn't work .race . hyper and promises in parallel) 2.- Same with the most recently rakudo version precompiled Anyone knows how to check if the system 14:21
is blocking rakudo from this features?
moritz the call graph is called an "icicle" graph/plot, like a buttom-up flamegraph
notandinus i see 14:29
perry Wait, that's what upside-down flamegraphs are called?
That's awesome 14:30
notandinus and i have 1244950 scalar allocations, all are green so it's not causing slowdown right?
on the other hand the boothash thing is all red: 933093
timotimo the color indicates if the allocation happened in a piece of code that has been optimized or not 14:37
notandinus ah yes, that was dumb question, more allocations will mean more work 14:38
timotimo there's nuance to that 14:39
notandinus perry: upside-down flamegraph is just flamegraph, bottom up flamegraph is icicle
perry Ah right
timotimo objects that are very quickly discarded are relatively cheap, hashes that never get anything assigned to them will also not allocate a block for its actual data
notandinus perry: wait 14:40
it's the opposite it seems: Icicle charts are flame graphs upside down.
bottom up = upside down maybe
perry ¯\_(ツ)_/¯
notandinus www.brendangregg.com/flamegraphs.html -- says this here: under Variations heading 14:41
timotimo: i see
notandinus Deoptimizations causes slow down right? 14:42
profile says it was deoptimized 179797 times in line 94
timotimo the impact can be very different depending on the situation 14:43
notandinus github.com/andinus/octans/blob/mas...ctans.raku == this is the code
timotimo frames of code can be deoptimized at any point in their execution, so an early deopt will have you run most of the code in an unoptimized state, whereas a deopt near the end will not have such a big impact necessarily 14:43
notandinus i see, and what does "Exclusive & Inclusive" time in Routines section mean? 14:45
timotimo whether subs called by the given sub are counted or not 14:46
notandinus say the thing is sub foo() { notfoo() } sub notfoo() {} 14:47
timotimo plus/minus something for self-recursion, whether directly or indirectly
notandinus then sub foos
foo's inclisive time will include time for notfoo() and exclusive time will exclude that right? 14:48
timotimo correct
SmokeMachine is there a way of having `&[&&] 14:52
is there a way of having `&[&&]` get the string "&&"?
m: say &[&&].name # something like this, but without the infix: part?
camelia infix:<&&>
xinming SmokeMachine: I don't think so, maybe Red should add some customized infix. 14:55
notandinus timotimo: thanks 14:56
SmokeMachine xinming: sorry, that wasn't for Red... but why do you think that?
xinming SmokeMachine: alright, I thought you were trying to do some funny thing for Red with && :-) 15:00
ignore me.
SmokeMachine xinming: I've tried at the beginning... and then I've gone to try to understand what was happening inside blocks... 15:03
notandinus i have a list of sorted words and want to find the words that start with say "t", what's the best way to do this? 15:10
[Coke] .grep(*.starts-with('t')) ? 15:11
timotimo if it's extremely large, binary search to find the start, otherwise just grep :)
SmokeMachine m: say <bla pla tla ble bli blo plo blu>.grep: *.starts-with: "t"
camelia (tla)
notandinus i see, it's around 235,971 words
oh wait
i could directly run .starts-with on an array?
i was looping over this file and then running .starts-with on each word 15:12
timotimo yes but that would not do what you want here
[Coke] grep will run it against each element.
notandinus i see
[Coke] grep has an implicit loop
SmokeMachine m: lines.grep: *.starts-with: "t"
camelia ( no output )
[Coke] m: lines[0].say 15:13
camelia »Wann treffen wir drei wieder zusamm?«
SmokeMachine m: words.grep: *.starts-with: "t"
camelia ( no output )
notandinus so what do i do? how would i use binary search? isn't it to search a single element?
[Coke] you need to output it
SmokeMachine m: say words.grep: *.starts-with: "t"
camelia (treffen tritt trotz tut treffen)
SmokeMachine (what language was that?) 15:14
notandinus m: .say for lines
camelia »Wann treffen wir drei wieder zusamm?«
»Um die siebente Stund‘, am Brückendamm.«
»Am Mittelpfeiler.«
»Ich lösche die Flamm.«
»Ich mit«

»Ich komme vom Norden her.«
»Und ich vom Süden.…
[Coke] notandinus: yes, you'd have to use multiple searches to find the start point and end point.
I'd do a timing with .grep; if it's fast enough, no worries, if not, then you can dig deeper into how to find the endpoints. 15:15
SmokeMachine notandinus: are those words sorted?
[Coke] SmokeMachine: nope 15:16
It's German prose.
notandinus SmokeMachine: yeah, words are from the dictionary file, sorted 15:16
i think they asked about the file i'm going to use
[Coke]: i'll test with .grep, thanks 15:17
[Coke] ... whoops, thought you mean ^^ those words! :)
SmokeMachine notandinus: if you are going to use that multiple times, that could become a Set...
m: my $words = words.Set; say $words<Fernando>; say $words<Flamm> 15:18
camelia False
False
notandinus Hmm, .grep is very fast, i just ran time raku -e '"/usr/share/dict/words".IO.lines.grep(*.starts-with("t"))
SmokeMachine oh, sorry... starts with...
notandinus SmokeMachine: i see, i dunno about set, i'll check it out 15:19
maybe my code is slow because i'm using .lines, i'll try .slurp and grepping it at once
SmokeMachine notandinus: sorry... for some reason I thought you were going to test if the word existed... and not if that started with t...
but you could use a trie... 15:20
notandinus i see, i encountered trie yesterday, i'll check it out, thanks
i'm only going to use the list once though
SmokeMachine (not suggesting this one... just an example) github.com/FCO/Trie
[Coke] if you slurp, you have a single string; you'll have to break it up on whitespace anyway to get the list. 15:21
codesections tries are the data structure everyone *wants* to find a use for (they're fun!), but that rarely is the right choice
[Coke] m: .slurp.^name.say; .lines.^name.say; 15:22
camelia No such method 'slurp' for invocant of type 'Any'. Did you mean
'Slip'?
in block <unit> at <tmp> line 1
[Coke] m: slurp.^name.say; lines.^name.say;
SmokeMachine [Coke]: why not using `words` for that?
camelia Str
Seq
guifa codesections: ha! I’m actually writing one right one for Intl::Emoji
SmokeMachine yes, or lines...
codesections :)
[Coke] words or lines as appropriate for your data set. if each line is a word, I'd expect lines to be marginally faster.
guifa (for an emoji like 🍦, the idea is to have it selectable by typing in “ice” or “cre” or “cream”, etc. Like how you get in an IME on your phone. Debating whether I should allow for substrings too, Google doesn’t seem to think it helps based on Android’s IME though so not sure I want to go that far) 15:24
notandinus ok so it takes 10s (real) to do that 15:26
is there a way to use an array with .start-with() 15:27
something like: .grep: *.start-with(@starting-points)
[Coke] you mean, enforce that elements in the array must start with?
codesections guifa: ok, that is admittedly the perfect use-case for a trie. Especially because the total number of emoji isn't *huge* (by computer standards, anyway)
[Coke] oh.
notandinus: I think : *.starts-with(any(@foo)) will work
notandinus yeah i actually have a list of characters that the words can start with
m: .say for lines 15:28
camelia »Wann treffen wir drei wieder zusamm?«
»Um die siebente Stund‘, am Brückendamm.«
»Am Mittelpfeiler.«
»Ich lösche die Flamm.«
»Ich mit«

»Ich komme vom Norden her.«
»Und ich vom Süden.…
guifa Also back when I was doing spell check engine writing
notandinus m: .grep: *.starts-with(any(<a t>))
camelia No such method 'starts-with' for invocant of type 'Any'
in block <unit> at <tmp> line 1
[Coke] you can also use regexes: : grep(/^^ @choices)
(er, but close the regex)
m: say lines..grep: *.starts-with(any(<a t>)) 15:29
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling grep() will never work with signature of the proto (Mu, |)
at <tmp>:1
------> 3say lines..7⏏5grep: *.starts-with(any(<a t>))
[Coke] m: say lines.grep: *.starts-with(any(<a t>))
camelia ()
[Coke] m: say lines.grep: *.starts-with(any(<a t W>))
camelia (Wir kriegen es unter, das Element. Wie manche liebe Christfestnacht)
guifa I’d use a trie to get the root word, and a flipped-word trie to get at the suffixes and (simplifying it) progressed until they met in the middle
notandinus m: say words.grep: *.starts-with(any(<a t w>))
camelia (treffen wir wieder am tritt aus, warten, trotz anderen weg will was am alles an wie will war was tut wir wie’s auch an all all alten aus, wütender wurde als wieder treffen wir wieder am am)
notandinus ah yeah it works
[Coke] so, starts-with with a literal is going to be fastests. junctions *should* compile to a conditional, but more complicated junctions will probably get slower; regexes may start slower than a simple junction, but a more complicated regex may perform better than a complication junction 15:32
*fastest
codesections guifa: interesting. I'd be curious to see how the performance of the trie for the root word compares to a hash. My understanding was that they typically don't come out ahead with current hardware for large dictionary sizes, but I haven't implemented it myself 15:33
notandinus [Coke]: say i only have 2 characters to check for with start-with, that would be faster than regex right? 15:34
codesections (obviously the trie will be better if your main constrain is space rather than time) 15:35
s/constrain/constraint/
SmokeMachine for doing several queries, I'd use a trie... 15:36
codesections notandinus: right now, yeah - regexes are currently slower than they should/will be
[Coke] notandinus: aye. You could also do *.grep({$_.starts-with('a') or $_.starts-with('b')}) more explicitly. 15:38
the * gives you a whatevercode block, but you can explicitly write the block if you want.
(or make a sub call, or...)
notandinus it's interesting to see it stop at a specific word for some time and then go fast again 15:41
it always stops at that specific word
guifa codesections: at least for my implementation, it was a lot easier to use a trie because it was super easy to load in a binary blob and do operations on that. 15:43
Doing that for a hashmap would mean writing my own hash algorithm for consistent results and… yeah I wasn’t in the mood for that lol
codesections guifa: ah, yeah, that makes sense. My first instinct would have been to serialize the hash to JSON or something, but that's just because I tend to reach for text-based tools by habit. Sounds like your implementation was better (unsurprisingly, since you presumably gave it some thought :D) 15:47
guifa Yeah, fast loading was imperative on Android 15:49
I guess I could have spun stuff off into other threads and all but doing that in Java is … not fun lol
codesections having not really written any, my casual impression is that doing *anything* in Java is not fun :D 15:51
I take it that this was pre-Kotlin?
guifa Yeah, this was probably about 5 years ago now 15:53
guifa hates boiler plate
Java is boilerplate with a sprinkling of code 15:54
notandinus oof, can it be that the program exits the for loop but then again enters it magically?
there is something weird going on, i'll paste the code
ok so this is the thing: paste.debian.net/hidden/ddfc8897/ 16:00
after the `say "lol false"` at line 76 it should return False and exit the sub word-search right? 16:01
but the thing is not exiting the sub and somehow reentering the for loop before it
look at the output, it should print "attrited False" after "lol false" right? 16:02
notandinus oh wait, nvm it's clear now, i made a logical error 16:15
ctilmes As of newly released alpine 3.13, rakudo now part of alpine community channel. 16:54
tellable6 2020-11-29T15:40:15Z #raku <patrickb> ctilmes: OK. I guess nasa is out then.
2020-11-29T15:40:30Z #raku <patrickb> ctilmes: Thanks for the info though!
ctilmes You can run this, e.g. docker run --rm -it --entrypoint=/bin/sh alpine -c "apk add -U rakudo && raku -v"
zef is in there too, so you can "apk add zef" to get that. 16:56
jdv79 did that take work from us or did they just pick it up? 17:28
ctilmes I did the work 17:42
I guess whether I was working for "them" or "us" is open..
I think it benefits both them and us 17:43
guifa .tell jmerelo are you just doing voiceover for your FOSDEM presentation or are you recording video of yourself talking as you’re giving it 18:11
tellable6 guifa, I'll pass your message to jmerelo
guifa lizmat: ^^ same Q
patrickb There currently is no way to access the real ARGV[0] from within a raku executable, correct? 18:27
*raku script
notandinus patrickb: ARGV[0] is the first argument right? or is it the binary name? 18:32
patrickb binary name
notandinus docs.raku.org/language/5to6-perlvar
patrickb I'm asking about the C main() argv[0] 18:33
notandinus patrickb: does $*PROGRAM-NAME do what you want?
patrickb Sadly not, that's set to the script being executed, not the actual argv0 18:34
notandinus also, $*EXECUTABLE-NAME
^ does executable name work?
patrickb hm.... might actually work...
notandinus i see, go through that page, there might be something more that i didn't spot 18:36
patrickb EXECUTABLE-NAME also doesn't do it. 18:37
looked through that page already :-(
I'd be fine with a way to do it in sh as well, but sh suffers the same problem. It has a `$0`, but that's set to the script name. 18:38
notandinus patrickb: does docs.raku.org/language/variables#i...-$*PROGRAM work? 18:39
$*PROGRAM
patrickb no, that's the script name
notandinus Contains the location (in the form of an IO::Path object) of the Raku program being executed.) 18:40
^ $*PROGRAM
patrickb: script name was $*PROGRAM-NAME
also see $*EXECUTABLE
docs.raku.org/language/variables#$*EXECUTABLE 18:41
patrickb PROGRAM and PROGRAM-NAME are both the scripts name, either as a Str or an IO::Path. EXECUTABLE is technically the raku executable that's running, but it's the full path of the executable running. I need the real argv0 as it was passed to the executable. 18:42
By now I'm pretty sure there is no way to get at that value. 18:43
notandinus i see, i might have misunderstood the problem
[Coke] m: say use nqp; say nqp::execname() 18:45
camelia 5===SORRY!5=== Error while compiling <tmp>
Could not find nqp::execname, did you forget 'use nqp;' ?
at <tmp>:1
------> 3say use nqp; say nqp::execname()7⏏5<EOL>
[Coke] m: use nqp; say nqp::execname()
camelia /home/camelia/rakudo-m-inst-1/bin/perl6-m
[Coke] based on the docs for nqp::execname, I think that might be the right thing 18:46
(and execname is used as part of $*EXECUTABLE)
[Coke] github.com/Raku/doc/issues/3782 is some easy doc maintenance if anyone wants it 19:02
[Coke] .seen codesections 19:09
tellable6 [Coke], I saw codesections 2021-01-15T15:51:48Z in #raku: <codesections> I take it that this was pre-Kotlin?
[Coke] doesn't know what Kotlin is.
codesections: any thoughts on hitting Raku's runtime for method information rather than the source? 19:10
guifa [Coke]: Kotlin is basically TypeScript but for Java 19:13
patrickb If I start a process and hand it a fake arg0 (raku can't yet do that, but I have the impl ready), what should Proc.command() return? the real program that was called, or the fake one? 19:18
moritz the real one, IMHO 19:21
tony-o agree with moritz 19:22
patrickb I tend to agree as well.
Geth doc: patrickbkr++ created pull request #3784:
Document new Proc(::Async) arg `arg0`
19:47
sortiz m: for "/proc/$*PID/cmdline".IO.slurp.split("\0") { .say }
camelia /home/camelia/rakudo-m-inst/bin/perl6-m
--setting=RESTRICTED
<tmp>
patrickb moritz, tony-o, <[Coke]>: PRs for implementation, test and roast are up. Geth kindly provided links. Review welcome :-) 19:48
patrickb I'm off for today. o/ 20:00
[Coke] patrickb++ 21:10
cog m: say %<a>.raku # %<a> was a typo. I don't know what it means 21:24
camelia {}
cog m: say %(<a>).raku
camelia Odd number of elements found where hash initializer expected:
Only saw: "a"
in block <unit> at <tmp> line 1
tobs cog: it has something to do with matching. $<a> is short of $/<a> or $/.<a>, accessing the last match variable $/. I don't know how to read %<a> properly, but it seems to have something to do with it: 21:29
m: say %<a>.raku; "X" ~~ /$<a>=./; say %<a>.raku
camelia {}
Map.new
cog tobs: Indeed, now I come to think of it, I sometimes use @<a> to state the sub match is an array. 21:45
cog On a related thought, I think it is a feature on a defined $/ for $/<a> not to bark when there is no 'a' sub match. It is a misfeature not to bark when $/ is Nil 21:49
m: Nil<a>
camelia ( no output )
cog m: say Nil<a>
camelia Nil
cog m: say Nil[0] 21:50
camelia 5===SORRY!5=== Error while compiling <tmp>
Any cannot be parameterized
at <tmp>:1
------> 3say Nil[0]7⏏5<EOL>
lucasb Hello, cog. It's my understanding that Nil has this 'propagating' effect. From the docs: "Any method call on Nil of a method that does not exist, and consequently, any subscripting operation, will succeed and return Nil." docs.raku.org/type/Nil 22:22
m: dd Nil.foo, Nil.[0] 22:23
camelia Nil
Nil
lucasb so, IOW, it's by design, whether (we) like it or not
cog I did not notice the error message on Nil[0] which means it is not an array access but a parametrisation attempt 22:27
m: say Match<a> 22:28
camelia (Any)
cog m: say Int<a> 22:29
camelia (Any)