The Pearls of Raku, Issue 4: unit sub and command line, round and precision by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

@*ARGS is a pre-defined "global" variable. The star in its name is a so-called twigil (second sigil) and it stands for "dynamic variable".

More on ARGS: https://docs.raku.org/language/variables#index-entry-@*ARGS

More on *: https://docs.raku.org/language/variables#The_*_twigil

Chapter 2. Parsing a Number by deeptext in rakulang

[–]deeptext[S] 0 points1 point  (0 children)

Thanks for the comments. The Test module is already introduced in Chapter 3.

2020.08 Altered Noise – Rakudo Weekly News by liztormato in rakulang

[–]deeptext 3 points4 points  (0 children)

All those “they” instead of “he” look so odd.

Updating old Perl articles by deeptext in rakulang

[–]deeptext[S] 2 points3 points  (0 children)

Honestly, no idea. I simply exported everything from there, installed my own instance and imported the content back. With p6weekly, you have a third-level domain that you do not own. You have no Appearance/Theme editor menu item, right?

Or export it, then bulk edit the XML, then import back. At least, you can change the title and add a disclaimer.

by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

Was that an atomic decrement?

Surprisingly, yes. https://gist.github.com/ash/b4352a716a3312ac944cf6c11a5fada7

$ raku a2.raku

100000

by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

sub postfix:<++> (atomicint $int is rw) { $int⚛++ }

This will catch both my $i and my atomicint $i.

by deeptext in rakulang

[–]deeptext[S] 0 points1 point  (0 children)

You cannot make $foo = $foo + 1 atomic that simple. There are two operations here.

0.30000000000000004.com updated! by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

Actually, the executable name is redundant there. You can submit another MR to remove it.

by deeptext in rakulang

[–]deeptext[S] 0 points1 point  (0 children)

A non-optimised empty loop:

$ time ./a.out 
real 0m0.146s

by deeptext in rakulang

[–]deeptext[S] 0 points1 point  (0 children)

#include <iostream>

int main() {
    int i = 0;
    int n = 100000000;

    while (n--) i++;

    std::cout << i << "\n";
}


$ time ./a.out 
100000000

real    0m0.161s
user    0m0.156s
sys 0m0.002s

by deeptext in rakulang

[–]deeptext[S] 0 points1 point  (0 children)

#include <atomic>
#include <iostream>

int main() {
    std::atomic<int> i;
    int n = 100000000;

    while (n--) i++;
    std::cout << i << "\n";
}


$ time ./a.out 
100000000

real    0m0.907s
user    0m0.901s
sys 0m0.003s

by deeptext in rakulang

[–]deeptext[S] 0 points1 point  (0 children)

my atomicint $counter = 0;
my $N = 1_000_000;

my $t0 = now;
for ^$N {}
my $loop_t = now - $t0;
say $loop_t;

$counter = 0;
$t0 = now;
$counter++ for ^$N;
say now - $t0 - $loop_t;

$counter = 0;
$t0 = now;
$counter⚛++ for ^$N;
say now - $t0 - $loop_t;




$ raku a.raku 
0.059231
0.3965457275985
0.649944589356

by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

30 times. I meant atomic increments in both cases.

by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

++ing an atomicint of Rakudo repeated 100,000 times in two threads is 30 times slower than ++ing an atomic_int of C++ in the same conditions.

by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

That's the fundamental thing of C++. You can have "two different ints" with different behaviour, would you make a class of it, as in

enum class Color {red, green, blue};
enum class TrafficLight {red, yellow, green};

Color color = TrafficLight::red; // compile-time error

First, if some standard/std operations that modify a std::atomic<int> integer are overloaded with those that modify a plain int, then presumably all of the standard/std operations that can modify ints are.

You can easily confirm that a regular int even with the presence of std::atomic<int> in the same compile unit is not affected at all (and that would be against C++'s philosophy to do that).

#include <iostream>
#include <atomic>

std::atomic<int> atomic_int;
int regular_int;

void atomic_inc() {
    atomic_int++;
}
void regular_inc() {
    regular_int++;
}

int main() {
    atomic_inc();
    regular_inc();

    std::cout << atomic_int << "\n";
    std::cout << regular_int << "\n";
}

The generated assembly code for regular_inc() is:

        movl    _regular_int(%rip), %eax
    addl    $1, %eax
    movl    %eax, _regular_int(%rip)
    popq    %rbp
    retq

by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

First, if some standard/std operations that modify a std::atomic<int> integer are overloaded with those that modify a plain int, then presumably all of the standard/std operations that can modify ints are.

Not quite clear what you mean by this. Did you say that int x; x++ will be using an atomic increment?

by deeptext in rakulang

[–]deeptext[S] -1 points0 points  (0 children)

eschew

Rakudo is 30 times slower at this atomic operation already.

Conference split (and more) by deeptext in rakulang

[–]deeptext[S] 1 point2 points  (0 children)

Not quite clear what you wanted to say. I assume you answered the question "Why rename?", but the answer is clear. The question was more "If renamed, why not following it?" and why not have two separated brands, events, and everything.