This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
01:12 frost joined 03:36 frost left 04:58 razetime joined 07:36 razetime left 08:37 discord-raku-bot left, discord-raku-bot joined 10:34 frost joined
deadmarshal I want to convert the Perl code to Raku, but I get two extra ":"'s at the start and end of the resulting string: bpa.st/V2GA 13:07
oops, changed signature: sub mac_address(Str $str){} 13:11
Nemokosch I don't quite get what you are trying to say 13:15
anyway, pretty sure the problem is that you use `split('')` over `comb`
guifa split('') includes zero-strings on either side 13:16
m: 'abc'.split('').Int.say
camelia 5
guifa you can use .split('', :skip-empty) or, more idiomatically, just use .comb 13:17
m: 'abc'.comb.Int.say
camelia 3
deadmarshal thanks 13:23
14:05 frost left
rcmlz Hello, is there a way to shut off "dynamic type checking" in function inputs via a command line option to raku? When running the follwoing code, booth versions run equally fast? 15:07
m:
#!/usr/bin/env raku
#| plain vanilla factorial
sub fact0($n) {
return 1 if $n == 0;
return $n * fact0($n - 1);
}
#| type safe factorial
sub fact1(UInt $n --> UInt) {
return 1 if $n == 0;
return $n * fact1($n - 1);
The intention behind is that during development type safe arguments help debugging, but to get maximum performance it might be beneficial to switch of type checks. Similar to how someone can switch on/of assertations in Java by providing a command line argument. 15:09
The intention behind is that during development type safe arguments help debugging, but to get maximum performance it might be beneficial to switch of type checks. Similar to how someone can switch on/off assertations in Java by providing a command line argument. 15:10
Hello, is there a way to shut off "dynamic type checking" in function inputs via a command line option to raku? When running the following code, booth versions run equally fast? 15:11
Hello, is there a way to shut off "dynamic type checking" in function inputs via a command line option to raku? When running the following code, booth versions shall run equally fast.
The intention behind is that during development type safe arguments help debugging, but to get maximum performance it might be beneficial to switch off type checks. Similar to how someone can switch on/off assertations in Java by providing a command line argument. 15:13
guifa rcmlz: so as a user you don't have control. types are a lot more complex in Raku than they might initially seem, but between Rakudo and the VM, many of them are skipped through various forms of optimization 15:17
sub fact0($n) is actually typed (and will likely be type checked). It requires type `Any`, which is a subclass of type Mu. 15:18
(most everything is of type Any, but there are a few classes that for one reason or another are not Any)
15:21 razetime joined
rcmlz Thank you. I was under the assumption, that the difference in execution speed is due to the type checking in fact1() vs. no type checking in fact0(). Is it possible for me to easily see where fact1() is spending the extra time? 15:21
Thank you. I was under the assumption, that the difference in execution speed is due to the type checking in fact1() vs. no type checking in fact0(). Is it possible for me to easily see where fact1() is spending the extra time? 15:23
raku --profile run_time_checks.raku
gives me a huge html-Page ...
stating that ther is a factor of 3 between the two versions 15:26
stating that there is apparently a factor of 3 between the two versions 15:28
guifa so UInt isn't actually a type unto itself, rather a subset. There is definitely more type checking involved there 15:29
I don't know the exact internals, but effectively, for UInt, it will check first whether it's an Int, and then whether it's positive 15:30
if that code gets hot, all sorts of optimizations will occur at runtime, so always be wary of simple benchmarks (it took me a while to get used to that) 15:31
rcmlz I am taking a course at university in that area and the professor said that he is not aware of any language that has this oportunity to switch between statically typed and dynamically typed by simple command line option. Just wanted to validate his assumption against Raku. Thank you. 15:32
guifa if you wanted to see the calls being made, you can compile to QAST which might give you some insight for a simple case like what you have. But Raku is a weird beast in that the boundaries between compile and run time are very fuzzy, and different implementations have freedom to shift some things around from one to the other (things like BEGIN can cause runtime during compile time, and EVAL causes compile time during 15:35
runtime, and since those can be mixed and matched....).
rcmlz I used "raku --target=ast run_time_checks.raku > qast.md" but are a bit overwhelmed by the content. Thank you anyway. 15:46
gfldex <@776481947240366142> You can run your scripts with `MVM_SPESH_NODELAY=1 raku` to have optimisations run right away. 16:32
18:51 discord-raku-bot left 18:52 discord-raku-bot joined 19:37 razetime left