09:11 dakkar joined 14:07 hudo_ left 14:08 hudo joined, hudo_ joined
rcmlz Not all what you read e.g. about Java OO and Best Practice/Design Pattern is relevant for Raku, as Raku has advanced features like multi methods that Java has not. So you can solve a problem maybe easier using Rakus features than you would in Java. 14:51
So the standard educational task „Given a rather complex (theoretical) class hierachy with lots of inheritance and overwriting, which method gets actually called given a certain instance and certain arguments“ is maybe easier to solve 🤓 15:04
antononcube I should make for Raku something like this GoFBot. 15:07
rcmlz I recently took a course at university about OO that demonstrated various OO Concepts and Pitfalls (and proved that Java OO is not sound, if I remember right) using various Languages (mainly Java, C++, Rust) - sometimes I tried the examples/task in Raku and was often surprised that it actually worked. 15:22
If it is possible to generate high quality Raku, working code for/from a OO Design Pattern List from a on that matter Textbook - would be interesting. 15:27
Sort of for all patterns -> pattern: say „Pattern: Java Solution vs. Raku Solution“ 15:30
🤓
antononcube Well, it does not seem to be that hard. Again, testing and testers are needed. My experience is that that GoFBot produced correct code 80% of the time. 15:33
BTW, GoFBot uses UML in Mermaid-JS. 15:34
It is related to my TODO list of "UML::Translators" -- to translate UML code into C++, Java, Raku, etc. raku.land/zef:antononcube/UML::Translators 15:35
rcmlz Interesting, did not know that „Raku-Code to PlantUML/Mermaid“ exists. 15:41
16:15 Manifest0 joined
Manifest0 Hi! What's the difference between invoking a function this way function(1) or function:1 ? 16:17
in my pc: 16:18
[8] > my @a; my $t = time; for ^10000000 {@a.push($_)}; say "Took: {time - $t} seconds"
Took: 23 seconds
[8] > my @a; my $t = time; for ^10000000 {@a.push:$_}; say "Took: {time - $t} seconds"
Took: 9 seconds
that's a big difference
lizmat Manifest0: which version of Rakudo are you using? 16:20
fwiw, I don't see a difference in performance between the two syntaxes
Manifest0 Welcome to Rakudo™ v2024.12-33-ge7f9223c5.
lizmat m: my @a; my $t = time; for ^1000000 {@a.push($_)}; say "Took: {time - $t}"
camelia Took: 1
lizmat m: my @a; my $t = time; for ^1000000 {@a.push: $_}; say "Took: {time - $t}"
camelia Took: 1
lizmat fwiw, it's better to use "now" for these cases 16:21
m: my @a; my $t = now; for ^1000000 {@a.push: $_}; say "Took: {now - $t}"
camelia Took: 0.543170965
lizmat m: my @a; my $t = now; for ^1000000 {@a.push($_)}; say "Took: {now - $t}"
camelia Took: 0.510747792
lizmat m: my @a; my $t = now; for ^1000000 {@a.push($_)}; say "Took: {now - $t}"
camelia Took: 0.52691798
lizmat m: my @a; my $t = now; for ^1000000 {@a.push: $_}; say "Took: {now - $t}"
camelia Took: 0.572151738
Manifest0 let me try 16:22
m: my @a; my $t = time; for ^10000000 {@a.push($_)}; say "Took: {now - $t}"
camelia Took: Instant:46.396049891
Manifest0 m: my @a; my $t = time; for ^10000000 {@a.push:$_}; say "Took: {now - $t}"
lizmat both cases: s/time/now :-)
camelia Took: Instant:41.327424937
Manifest0 got it 16:23
m: my @a; my $t = now; for ^10000000 {@a.push:$_}; say "Took: {now - $t}"
camelia Took: 3.792938414
Manifest0 m: my @a; my $t = now; for ^10000000 {@a.push($_)}; say "Took: {now - $t}"
camelia Took: 8.27316351
Manifest0 already some difference 16:24
lizmat hmmm that's weird
are you on Intel hardware ?
Manifest0 yes
lizmat ok, then that's maybe the reason I can't repro as I'm on Apple silicon
and that doesn't have the JIT 16:25
m: my @a; my $t = now; for ^10000000 {@a.push($_)}; say "Took: {now - $t}"
camelia Took: 8.101594819
lizmat m: my @a; my $t = now; for ^10000000 {@a.push: $_}; say "Took: {now - $t}"
camelia Took: 8.216274028
lizmat I wonder whether the CPU of camelia is now being throttled, but weird it is 16:26
m: my @a; my $t = now; for ^10000000 {@a.push: $_}; say "Took: {now - $t}"
camelia Took: 8.28036817
lizmat m: my @a; my $t = now; for ^10000000 {@a.push($_)}; say "Took: {now - $t}"
camelia Took: 8.714330314
lizmat would you mind making a Rakudo issue for this? 16:27
Manifest0 sure
lizmat also: could you try locally running these tests with MVM_JIT_DISABLE=1 ? 16:28
and see if that makes the results more consistent ?
Manifest0 sure 16:29
damn, i'm not even now able to reproduce it on my machine.... But i ran several times and with parens was hitting the 23 seconds mark, while with ':' it was in the 9 secs 16:32
should i still open a github issue? I'm not able to reproduce it anymore :-( 16:37
lizmat meh
well, I guess we need to wait until we can repro 16:38
rcmlz On glot.io/snippets/h3gee35qz6 : is faster than . 16:48
16:51 MasterDuke joined
Manifest0 i can reproduce it in the REPL. I copied all the steps i've made before (errors included), and i have the same results 16:51
MasterDuke `push:$_` has different timing (and ast) than `push: $_` (note the space after the colon) 16:52
lizmat there shouldn't be any difference in the QAST produced, is there ? 16:53
Manifest0 paste.opensuse.org/pastes/44988037d045 16:54
MasterDuke lizmat: there is
lizmat weird
Manifest0 yes, that's the space! 16:56
with the space it takes the same amount of time
without the space is much faster
MasterDuke and a difference persists at --target=optimize also (somewhat obviously since we see a time difference)
but without the space it doesn't work. i.e., the $_ values aren't in the array 16:57
Manifest0 shouldn't we get a warning then? 17:00
MasterDuke i'd say yes 17:08
afk now 17:09
17:14 MasterDuke left
lizmat ok, found the reason for the discrepancy 17:36
@a.push: $_ is codegenned as @a.push($_), as one would expect
17:37 dakkar left
lizmat @a.push:$_ on the other hand is codegenned as @a.push( :$_), aka with the named argument "_" taking the value of $_ 17:37
and the named argument is silently ignored 17:38
effectively making it:
@a.push
this would have been caught sooner if we would have a way to mark method calls as "endpoints" in the sense that they don't accept any unknown named arguments 17:41
Manifest0 lizmat: nice finding! 18:21
lizmat yeah, looking at the RakuAST tree made it clear immediately
m: say Q|my @a; @a.push:$_|.AST.statements[1].expression 18:22
camelia RakuAST::ApplyPostfix.new(
operand => RakuAST::Var::Lexical.new("\@a"),
postfix => RakuAST::Call::Method.new(
name => RakuAST::Name.from-identifier("push"),
args => RakuAST::ArgList.new(
RakuAST::ColonPair::Variable.new(
lizmat the "RakuAST::ColonPair::Variable" gives that away 18:23
m: say Q|my @a; @a.push:$_|.AST.statements[1].expression.postfix
camelia RakuAST::Call::Method.new(
name => RakuAST::Name.from-identifier("push"),
args => RakuAST::ArgList.new(
RakuAST::ColonPair::Variable.new(
key => "_",
value => RakuAST::Var::Lexical.new("\$_")
)
)
)
lizmat RakuAST::ColonPair::Variable.new(␤ key => "_",␤ value => RakuAST::Var::Lexical.new("\$_")
22:34 kjp left 22:36 kjp joined 22:38 kjp left, kjp joined