This week Rakudo Perl 6 went Atomic! Well, in the sense of “forming a single irreducible unit or component in a larger system”.
Locking is one of the evils in multi-threaded programming: Rakudo Perl 6 now has several lock-free primitives for updating native integer variables from several threads simultaneously. They’re all described on a brand new documentation page. In short, the new operators are:
$var ⚛= $value
(akaatomic-assign($var,$value)
)my $a = ⚛$var
(akamy $a = atomic-fetch($var)
)$var⚛++
(akaatomic-fetch-inc($var)
)$var⚛--
(aka (atomic-fetch-dec($var)
)++⚛$var
(akaatomic-inc-fetch($var)
)--⚛$var
(aka (atomic-dec-fetch($var)
)$var ⚛+= $value
(akaatomic-fetch-add($var,$value)
)
So when would an “ordinary” module developer need to use these, even when they’re not writing threaded programs? Well, your module might be used in a threaded program. And any situation where a variable is incremented to produce something unique, would need this, or run the risk of two or more threads running away with the same “unique” (not!) value. Observe:
my int $a;
await do for ^10 { start { $a++ for ^1000 } }
say $a # something less than 10000, like 9628, so 372
# increments lost because of simultaneous updates
versus:
my atomicint $a;
await do for ^10 { start { $a⚛++ for ^1000 } }
say $a # always 10000, because no updates are overwritten
Apart from these, a working version of cas
(Atomic Compare and Swap) was also implemented. All thanks to the work of Jonathan Worthington, which was made possible by the kind sponsorship of Nick Logan.
AlexDaniel++ for his first release
Aleks-Daniel Jakimenko-Aleksejev has done his first Rakudo compiler release! This signals the end of an era in which Zoffix Znet did 14 consecutive Rakudo compiler releases. For which I can only give a big Thank You!
If you look at announcement for Rakudo Perl 6 2017.08, you will see quite a number of fixes and improvements this month. Let’s hope AlexDaniel will be able to do many more of these with an even larger number of new features and improvements!
Other core developments
- Samantha McVey fixed several issues with
ignoremark
and a number of edge cases when concatenating strings. - Stefan Seifert fixed an issue with native closures failing on a second run. He also made sure that Rakudo Perl 6 will exit with a value of
0
if invoked with--help
. - And some other smaller fixes and improvements.
Swiss Perl Workshop
The schedule of the Swiss Perl Workshop has been published. It contains the following Perl 6 related presentations (in chronological order):
- Three Little Words by Damian Conway.
- ”How does deoptimization help us go faster”, and other questions you were sensible enough not to ask by Jonathan Worthington.
- Everyday Perl 6 by Damian Conway.
- A Gross Of Perl 6 Weeklies by Elizabeth Mattijsen.
- Grappling with ∞ – High Precision Math in Perl 6 by Cal.
- On the Shoulders of Giants – 400 Years of Perl 6 by Damian Conway.
- From sockets to services – reactive distributed software in Perl 6 by Jonathan Worthington.
- Spiders, Gophers, Butterflies by Sue Spence.
For what it’s worth: you can still register!
TPCiA Followup
Unfortunately, the official videos of TPCiA have not arrived yet. But we do have some pictures that have been shared:
- Chris Jack (needs FaceBook login)
- Wendy van Dijk
Wendy also gave an interview. And informed me that 80 copies of Perl 6 books (Perl Fundamentals, Think Perl 6 and Perl 6 At A Glance) and 52 copies spanning 13 different Perl 5 related books were sold during TPCiA.
Blog Posts
- My Perl Conference in Amsterdam Takeaway by Philipp Gortan.
- The emperor’s new clothes by Nadim Khemir.
- Building Perl 6 Applications with
Docker
andDucky
by Alexey Melezhik. - Parsing nothing by Wenzel P. P. Peppmeyer.
- Preparations for your by Wenzel P. P. Peppmeyer.
Meanwhile on Twitter
- TPCiA Slides by Samantha McVey.
- Heavy Metal TPF by Zoffix Znet.
- Thoughtful by Stephen Hall.
- Yay! #1 by Moritz Lenz.
- Nice language by Suman.
- Docker for Perl 6 Regexes by Moritz Lenz.
Meanwhile on StackOverflow
- Is there a canonical way to print a stack trace in Perl 6? by piojo.
- Creating a Perl 6 module containing Perl 5 utility scripts in
bin/
by Christopher Bottoms. - Load functions into other namespaces by byteunit.
- Passing an
Array
ofUInt
fails, while anArray
ofInt
succeeds by byteunit. - Changes in
IO::Socket::INET
from last year and broken promises by lisprogtor. - How to exit a promise from within a promise? by lisprogtor.
- What does the colon after
List:D
mean in Perl 6? by chenyf.
Meanwhile on perl6-users
- How do I do SSL/TLS with
eMail::MIME
? by ToddAndMargo.
Ecosystem Additions
- Toaster by Zoffix Znet.
- Grammar::ErrorReporting by Moritz Lenz.
- RPG::Base by Geoff Broadwell.
- App::P6Ghq by Shoichi Kaji.
Winding down
Yours truly spent most of the past week recovering from TPCiA. And now needs to focus on slides for the Swiss Perl Workshop. Wish me strength. See you next week for more Perl 6 news!
2 thoughts on “2017.34 Going ⚛”