🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
[Coke] m: (4...1).List.say 02:08
camelia (4 3 2 1)
Nemokosch 4..1 is an empty range 07:56
Voldenet I confirm, 4..1 is an empty range, I'd expect obvious 2**32-2 elements 08:02
grondilu Hi all. 08:44
grondilu Earlier I tried to compile rakudo/MoarVM with zig, using --moar-option='--compiler="zig cc"' 08:47
that failed, but today I tried --moar-option='--cc=zig cc' and that worked.
Voldenet is it any different though? 08:48
grondilu for some reason, --moar-option='--cc="zig cc"' (mind the double quotes) did not
Voldenet: it seems similar
the main reason I'm interested in zig is that it compiles to WASM
Voldenet it'll probably be very similar to clang –target=wasm32 08:50
grondilu does that work, though? 09:01
Voldenet not at all, apparently standard libs can't be used in that case 09:09
Voldenet amazing if wasm target works on zig cc ootb 09:14
lonewolf-dev why is raku so slow? 10:36
lonewolf-dev how can i make it faster? 10:36
a simple for loop that counts to a 100k in perl is so much faster than in raku. 10:37
lonewolf-dev how do i compile raku to the jvm? 10:38
lizmat lonewolf-dev: answering your questions in reverse order 10:45
1. by selecting the JVM as backend 10:46
lizmat 2. generally, if you are using with integers, things will go faster if you're using native integers (what perl does by default) 10:48
lizmat 3. you could help by showing what constructs are slower than you expect, and then hope an easy solution can be found 10:48
4. because it doesn't have 30+ of optimizations under its belt yet 10:49
lonewolf-dev is rakudo on jvm backend faster than moarvm? 11:11
lizmat I guess for some tasks, I wouldn't know: my focus is on MoarVM as backend 11:15
lonewolf-dev Isnt it possible to port all perl modules to raku? No need to reinvent the wheel. 11:17
lizmat it is possible, and I've done quite a few of them, but perl is no longer of interest to me 11:23
as my efforts were seen as trying to devalue perl by many (prominent) Perl community members
so my taste in doing that, has soured significantly
Nemokosch Please be aware that the "jvm backend" is not like Kotlin, Clojure, Scala and the likes, it does not actually target the JVM the way these languages do 11:24
The term itself is rather unfortunate. It's rather a backend that runs on top of the JVM 11:25
lizmat lonewolf-dev: raku.land/tags/cpan5
Nemokosch It's as if you called MoarVM the "C backend"
lizmat lonewolf-dev: raku.land/zef:lizmat/P5built-ins 11:26
Nemokosch Also, let's call things by their name, at least here: Perl is a language that only hobbyist hipsters learn in 2023. One might say that the same is true for Raku as well but if you look at both languages, I doubt there is any question which one you'd rather enjoy using 11:28
lonewolf-dev ok 11:33
tbrowder__ .ask tonyo thnks, inside that example sub will smartmatching work (don't have time to try it, gotta run for a while) 12:15
tellable6 tbrowder__, I'll pass your message to tonyo
tonyo tbrowder__: it should 12:26
tellable6 2023-05-20T12:15:40Z #raku <tbrowder__> tonyo thnks, inside that example sub will smartmatching work (don't have time to try it, gotta run for a while)
tonyo m: enum A <A1 A2 A3>; sub a (A:D $a) { say $a ~~ A2; }; a(A1); a(A2); # tbrowder__ (smartmatching)
camelia False
True
tbrowder__ tony: so cool! thnx. that's what i was trying to do but must have murfled the syntax somehow. 13:01
tbrowder__ m: enum btype <afm ff>; sub f(btype $typ) { if $typ ~~ afm { say "do afm stuff } else { say "do ff stuff"}}; f(afm); f(ff); 13:06
camelia ===SORRY!=== Error while compiling <tmp>
Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1)
at <tmp>:1
------> se { say "do ff stuff"}}; f(afm); f(ff);⏏<EOL>
expecting …
tbrowder__ crud, typo :-(
tbrowder__ m: enum btyp <afm ff>; sub f(btype $t) { if $t ~~ afm { say "do afm"} else { say "do ff"}}; f(afm); f(ff); f(bad) 13:09
camelia ===SORRY!=== Error while compiling <tmp>
Invalid typename 'btype' in parameter declaration. Did you mean
'btyp'?
at <tmp>:1
------> enum btyp <afm ff>; sub f(btype⏏ $t) { if $t ~~ afm { say "do afm"} else
tbrowder__ doing this back at home in my own REPL 13:10
tbrowder__ m: enum btyp <a b>; class f { has btyp $.t}; my $o = f.new: :t(a); 13:48
camelia ( no output )
tbrowder__ m: enum btyp <a>; class f { has btyp $.t = a; }; my $o = f.new; say $o.t 13:50
camelia a
tbrowder__ hm, that's cool, it ought to work the same at home then... 13:52
ok, can we iterate over an enum? 14:00
m: enum btyp <a b>; for btyp.kv -> $k,$v { say $k.WHAT; say $v.WHAT; last} 14:03
camelia (Str)
(Int)
tbrowder__ aha 14:05
m: enum btyp <a b>; for btyp.pairs { say $_. 14:06
camelia ===SORRY!=== Error while compiling <tmp>
Malformed postfix call
at <tmp>:1
------> num btyp <a b>; for btyp.pairs { say $_.⏏<EOL>
tbrowder__ m: enum btyp <a b> ; for btyp.pairs { say $_ ~~ a } 14:07
camelia False
False
tbrowder__ ?? 14:09
m: enum btyp <a b> ; for btyp.pairs { say $_ } 14:10
camelia a => 0
b => 1
rf Morning folks 16:51
librasteve on my machine its 0.14s (raku on MoarVM) vs. 0.02s (perl) 18:00
took me a lot longer than that to remember how to write perl 18:02
lizmat librasteve: and a bare startup for raku is probably around .11 for you, right?
librasteve 0.08s 18:03
lizmat hmmm.. and what was the code you ran? 18:04
librasteve for the startup?
time raku -e "say 0" 18:05
m: my $counter; for 0..^100000 {$counter++} say $counter; 18:07
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Strange text after block (missing semicolon or comma?) at /home/glot/main.raku:1 ------> my $counter; for 0..^100000 {$counter++}⏏ say $counter;
lizmat time raku -e ''
and with: my int $counter ? 18:08
librasteve my $counter; for 0..^100000 {$counter++} say $counter; 18:09
^^^ that's 0.14s
my int $counter; for 0..^100000 {$counter++} say $counter; 18:10
^^^ that's 0.13s
raku -e 'say 2**64 + 1' 0.12s
^^^ so not much gain at this scale for native int ... but showing raku uses BigInt vs. perl native int that is one source of slower runtime 18:12
gfldex Does the JIT acutally got enough time to kick in? 18:13
librasteve probably not
lizmat hmmm... feels like we lost an optimization somewhere 18:18
ah no the difference becomes pronounced at ^1000000 (.16 vs .21) or 10000000 (.39 vs .91) 18:20
Bronco_Creek I've hit a snag trying to install Rakudo on my new Mac w/ M2 chip.  The install command produces the error rakudo/lib/main.bash: line 30: declare: -A: invalid option 18:25
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
Any advice on fixing this?
lizmat Bronco_Creek: which version of Rakudo ?
Bronco_Creek Latest source for the star bundle 18:26
lizmat hmmm... that *should* have all of the M2 fixes
Bronco_Creek Maybe I should just try again.  Delete everything in my /rakudo and start from scratch? 18:29
lizmat nuking the install dir is usually enough :-) 18:38
Bronco_Creek Well, still got the same failure. 18:47
main.bash: line 30: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
fatal: not in a git directory
This is on a Mac Mini, if that matters. 18:48
librasteve hi Bronco_Creek - have you tried rakubrew?
(that's my goto on my M1) 18:48
Bronco_Creek No, haven't tried rakubrew. 18:49
I will give that a whirl. 18:50
Bronco_Creek Rakubrew seems to have worked.  Thanks lizmat and librasteve. 19:11
librasteve 👍 21:02
tbrowder__ .tell rf a belated 'hi' 22:20
tellable6 tbrowder__, I'll pass your message to rf
rf Hey tbrowder__ :) 22:22