Raku Programming Language

profoundlynerdy,
@profoundlynerdy@bitbang.social avatar

What are some underappreciated superpowers that and/or has EXCLUDING and ?

RogerBW,
@RogerBW@emacs.ch avatar
rakulang,
@rakulang@fosstodon.org avatar

@RogerBW

Solution to 1. with shortcutting:

sub uniqueoccurrences(@a) {
@a.repeated.head =:= Nil
}

https://docs.raku.org/type/Any#method_repeated

Also note that The Raku Programming Language uses the tag, to not interfere with the good people doing Raku pottery.

RogerBW,
@RogerBW@emacs.ch avatar

@rakulang Thanks, I'll tweak the tag for future posts. I tend not to use the sexier language features in favour of a portable polyglot approach (also because I find them hard to parse when I come back to the code later).

alchemistsstudio,
@alchemistsstudio@mstdn.social avatar

Yesterday I was daydreaming of spring and our gardens and these raku pottery pieces come to mind. What do these pieces remind you of?

Here's hoping my poor flower bulbs are not too confused (they started coming up in February.

A multi-coloured raku pottery vase with various shades of blues, pinks and purples.

mjgardner,
@mjgardner@social.sdf.org avatar

@Perl Per @PerlRakuFoundation's announcement yesterday,* The & Conference 2024 in Las Vegas is now accepting proposals for live in-person session talks! https://tprc.us/talks

Need ideas? That page also has previous conference schedules as well as a wiki link to request topics.

New this year: a peer-reviewed track with its own process: https://science.PerlCommunity.org

ology,
@ology@fosstodon.org avatar

@mjgardner @Perl @PerlRakuFoundation Woo! I just submitted two: {Beginning,Advanced} Algorithmic Music with Perl - Thanks for announcing! :D

samebchase,
@samebchase@fantastic.earth avatar

I want to try out https://www.morling.dev/blog/one-billion-row-challenge/ in

The baseline solution in Java clocks in just under 5 seconds, so with Raku what should be a decent timing for a closest translation of that. The optimized solutions are less than 2 seconds.

What is a good time to target?

lizmat,
@lizmat@mastodon.social avatar

@samebchase

my atomicint $i;
$path.IO.lines.race(batch => 10000).map({ ++⚛$i });

would be a better benchmark. This will at least parallelize the work (incrementing $i). But that still needs serial decoding.

How fast would this be:

my $h = open $path;
Nil while $h.read;

that would be the lower bound.

You could .list.grep(10, :k) on each Blob, and use that to decode async (10 being "\n".ord).

Is that a plan?

samebchase,
@samebchase@fantastic.earth avatar

@lizmat Let me try this out.

For comparision with single threaded wc -l i mplementation:

  1. Go takes 23 seconds.
  2. Common Lisp (SBCL) takes 70 seconds.

CL => 3x Go
Raku => 10x CL

The Nil while read thing that you've given runs in 20 seconds.

The race and atomic increment thing, I killed it after 3 mins.

VZ,
@VZ@fosstodon.org avatar

I really like , in theory, and would like to use it more, but whenever I have something to write, I still often end up with using for it.

Just the latest example: I had to write a simple text-wrangling script that needed UUID generation. With Perl, I used App::Fatpacker to embed UUID::Tiny to make the script runnable just about anywhere without any extra dependencies, but there is nothing like that for Raku AFAIK and it just didn't seem worth it to do something more complicated.

18+ mjgardner,
@mjgardner@social.sdf.org avatar

@VZ’s design all came from the question, ‘What could I build if I could basically start again from scratch? What ideas might I have? How do I build a coherent whole from this blank canvas?’

’s ongoing design is all rooted in, ‘What would I use right now in this real code I am writing today? What features would I like to have that I currently do not?’”

@leonerd (https://x.com/cpan_pevans/status/1596972022952779782)

mjgardner,
@mjgardner@social.sdf.org avatar

@VZ @leonerd IMHO is great but it’s also a classic case of Fred Brooks’ “second-system effect”: https://archive.org/details/mythicalmanmonth00broo/page/53

Greguti,

J'ai réalisé un en terre cuite et puis je l'ai cui en et puis j'ai mis des émaux dessus et puis je l'ai cui en cuisson . Le résultat est un mignon petit hippo qui est dans l'eau et dont seule la partie supérieure émerge, tête, dos, petite queue.

samebchase,
@samebchase@fantastic.earth avatar

Great post featuring while trying to explain an algorithm using which we can do mental arithmetic to generate pseudorandom numbers.

https://www.hillelwayne.com/post/randomness/

I learnt a few tricks! 👌

goldstein,

I solved this day of in , which still looks fun, until I try to actually write it and discover once again that basically every operation has some weird footguny semantics. nevertheless, I’m quite happy with the final result, which looks nice and concise.

https://github.com/GoldsteinE/aoc2023/blob/master/day13/code/main.raku

18+ goldstein,

some random examples of weird footguny semantics in Raku:

my @arr = (2, 3);<br></br>reduce &[+], 1, @arr;<br></br>

is 3 (list gets reinterpreted as a scalar). you need to use |@arr for it to work.

reduce &[(&)], ();<br></br>

(identity element for set intersection) is an empty set for some reason.

Set.new((1, 2), (3, 4)) (&) Set.new((3, 4), (5, 6))<br></br>

is an empty set (sets use comparison by identity, so all the lists are considered different).

set((1, 2), (3, 4))<br></br>

is a set of four numbers 1, 2, 3, 4, set flattens its arguments, while Set.new does not.

sequences like x...^y and (x..^y).reverse are either not actually lazy, or just really slow, not sure which one.

18+ samebchase,
@samebchase@fantastic.earth avatar

@goldstein Hmm, even in the official documentation it seems to require the | (slip) operator. https://docs.raku.org/routine/reduce

Could any experienced Rakoon let us know why this is necessary?

opoku,

I've completed "Pipe Maze" - Day 10 - Advent of Code 2023 https://adventofcode.com/2023/day/10

As I suspected, day 10 was a doozy (especially part 2). I've always had trouble with these enclosed spaces algorithms.

https://git.sr.ht/~opoku/aoc2023/tree/main/item/day10.raku

18+ jeff,
@jeff@phpc.social avatar

@opoku Nice work! This seems like the proper approach. 👍

I was getting hung up on the adjacent pipes, and decided to just upscale the map 3X then flood fill.

masukomi,
@masukomi@connectified.com avatar

I've been asked to write an article for the advent calendar this year. I have a simple tutorial idea that I think will be good for beginners, and I swear to god I spent half the effing day yesterday fighting with ORM libraries and now I'm thinking "Fuck-it. I'll just write raw SQL."

Personally, I love SQL, but it feels kinda bullshit that that's where I ended up, and it's terrible for a beginner tutorial. Never-mind the fact that dramatically complicates the amount of code I'll need.

smokemachine,

@masukomi yes, you are right, that’s the reason. I really need to find a way to fix that. But if you are not going to use Postgres (and you are going to use SQLite) you could install it with —force…

masukomi,
@masukomi@connectified.com avatar

@smokemachine a) thanks b) owing to time constraints I've gone off in another direction with what I'm working on, but I'll try that on the next personal project. Not really a fan of making a project for others when I have to tell them to force-install specific dependencies.

bocs,
@bocs@toot.wales avatar

For the first day of living in UTC+0, I actually have to be up at stupid o'clock anyway. In the interests of speed, which I usually do not care about, given the opportunity I shall start day 1 in in which the thing will take moments. I'll clean it up into because, well, one ought to. I'll then start again in because that's what I want to learn this time around.
I see a lot of exotic things, or rust, or R. Where's my perl tribesfolk?!

mjgardner,
@mjgardner@social.sdf.org avatar

@bocs I’m in the tribe but wasn’t going to participate in . Should I?

sjn,

I just submitted a talk to the and track at . Deadline for submission is tomorrow (Friday Dec 1st), and it's not too late to share! 😄

https://news.perlfoundation.org/post/fosdem2024

WGAvanDijk,
@WGAvanDijk@mastodon.social avatar

TPRF (The Perl and Raku Foundation) is organising a Raku & perl devroom at FOSDEM. Sadly, no booth for Raku & Perl. Still, plenty of interesting stands.

https://fosdem.org/2024/news/2023-11-20-accepted-stands-fosdem-2024/

CIAvash,

If you're looking for a more powerful tool(and regex) than , , …, then rak is the answer

App::Rak - 21st century grep / find / ack / ag / rg on steroids
https://raku.land/zef:lizmat/App::Rak

masukomi,
@masukomi@connectified.com avatar

Just realized it's If you're looking for a small task to help with this month maybe check out one of these:


a tiny command line widget to show your progress through the day.
https://github.com/masukomi/days_progress


a library for making pretty tables on the command line.
https://github.com/masukomi/Prettier-Table

a library for making bar charts
https://github.com/masukomi/Terminal-Graphing-BarChart

CLI time tracking (many "good first issue" issues)
https://github.com/masukomi/hey_3

masukomi,
@masukomi@connectified.com avatar

Side note re these and all of my other repos: contributions from newb coders, and coders who are just new to the language are 100% welcome.

masukomi, (edited )
@masukomi@connectified.com avatar

As I continue to use my CLI time tracking app, I find myself thankful that makes it so easy to make sentence-like command interactions.

At the same time, I'm finding that I want to support more ways to say the same thing. I.e. other sentence structures and ordering that convey the same details.

Fortunately has great built-in support for custom grammars, AND this would be nice limited-scope thing to learn how with.

UNfortunately i just haven't the time to dive into that 😿

dachary,
@dachary@dacharycarey.social avatar

@masukomi Vacation has arrived! Maybe something to fiddle with?

masukomi,
@masukomi@connectified.com avatar

@dachary to many projects! ;)

RogerBW,
@RogerBW@emacs.ch avatar
xfix,

@RogerBW In , it's not necessary to parenthesize condition in if. if $t == 0 { will work just as well.

RogerBW,
@RogerBW@emacs.ch avatar

@xfix Thanks; I tend to write Perl-style if it still works in Raku. Gradually fixing this.

RogerBW,
@RogerBW@emacs.ch avatar

people: I have a class which must be initialised before use, but that initialisation is more complex than simply setting field values. I can do this right now with my $foo = MyClass.new; $foo.init(stuff); but I find that ugly. I haven't found any examples of a new method that will do the standard object setup and then run my initialisation code on this new instance of it. Is this a thing? Pointers welcome.

lizmat,
@lizmat@mastodon.social avatar

@RogerBW

I think https://docs.raku.org/language/classtut#TWEAK is what you're looking for

alchemistsstudio,
@alchemistsstudio@mstdn.social avatar

🌎Embrace equinox with some art🌍

This ceramic globe and earth themed raku fired vase capture the essence of change, much like our seasons!

Please follow along to see more clay transformations and let me know what you think of these pieces in the comments!

Happy equinox!

A raku fired vase with the continents of earth depicted and blue water.

massa,
@massa@hachyderm.io avatar

235/01:

You are given an array of integers.

Write a script to find out if removing ONLY one integer makes it strictly increasing order.

my answer:

sub remove-one(@_@hachyderm.io) {  
 (^+@_@hachyderm.io).map({[&lt;] @_@hachyderm.io[|(^$_), |($_+1 ..^ +@_@hachyderm.io)]}).any.so  
}  
massa,
@massa@hachyderm.io avatar

@duran pra mim, esse one-liner é extremamente legível e, em português:

"existe algum índice do array que foi passado para o qual o array sem o item nesse índice tá estritamente ordenado?"

é assim rs

massa,
@massa@hachyderm.io avatar

@duran é meu arroz-com-feijão, né? então ... mas agradeço a admiração 😉

baffled,
@baffled@mstdn.ca avatar
sjn,

and are the 35mm focal length of languages. Only one of them is O(fun), though. 😁

https://www.youtube.com/watch?v=mmDWYGUM77Y

mjgardner,
@mjgardner@social.sdf.org avatar

@nichartley Other R... languages: REXX, Ring, Ruby

sjn,

@mjgardner @leonerd This was a well-thought perspective; Thanks for sharing!

Though with my post, I'm trying to illuminate another something in common between and , which I found the video above made a point of in a really nice manner.

Namely that the focus on TIMTOWTDI in these – which by some people is perceived as a detriment – in fact is one of their greatest strengths.

With this said, take another look at the video, from the 2m15s mark and onward... What do you think?

nobodyinperson,
@nobodyinperson@fosstodon.org avatar

Can we please have an alias 'but' for the 'and' binary operator in programming languages?

if outside and moving_slowly ⇒ if outside but moving_slowly
if online and not connected ⇒ if online but not connected

Such semantics made :perl: a bliss to write in some cases (if not ⇒ unless), although Perl doesn't have this 'but' alias. Probably can change itself at runtime to add this alias 😅

nobodyinperson,
@nobodyinperson@fosstodon.org avatar

@mjgardner Luckily I didn't write or publish anything serious in , let alone something that someone else would review. It was just one of my first programming languages to learn and I really liked these 'unless' and 'until' keywords because I think they make certain cases much more readable. But okay, if that's considered bad practice, oh well 🤷

mjgardner,
@mjgardner@social.sdf.org avatar

@nobodyinperson Oh yes, unless and until definitely make simple negative conditions read like English. I use them in tiny snippets sometimes: https://social.sdf.org/@mjgardner/111067530338170318

jbzfn,
@jbzfn@mastodon.social avatar

📚 A Complete Course of the Raku programming language

https://course.raku.org/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • raku
  • kavyap
  • ngwrru68w68
  • tacticalgear
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • slotface
  • everett
  • vwfavf
  • rosin
  • anitta
  • Leos
  • khanakhh
  • GTA5RPClips
  • cisconetworking
  • InstantRegret
  • ethstaker
  • osvaldo12
  • tester
  • provamag3
  • modclub
  • cubers
  • normalnudes
  • megavids
  • JUstTest
  • All magazines