Live data from Hacker News

Unusual Raku Features

buttondown.com

131–140 of 166 posts

Re: Unusual Raku Features

#131

I don't understand why we want to use some language feature like Junctions, instead of using lists explicitly?

Junctions introduce a degree of non-determinism to the language. Think Prolog variables. Junctions allow you to talk about a set of solutions without having to mind how they are kept together or how the operations are distributed between members of the Junction. It's especially convenient when you search for something and that something can be a complicated series of logical expressions: you can pack them all in a single Junction and treat as a first-class object. It's a little hard to explain without giving examples, but it really has a lot of uses :)

Re: Unusual Raku Features

#133

Earlier quoted context omitted.

I’m not sure that I see the connection that you are making here. Can you elaborate? Also note that in contrast to Bash, Junction is a type. Regarding their utility, at their most useful level (in my experience), junctions provide for things like: $string ~~ “this”|”that”|”other” This is the same as writing $string eq “this” || $string eq “that” || $string eq “other” They have many other uses but that’s the most commo…

> I’m not sure that I see the connection that you are making here. Can you elaborate? Back when I had to write PowerShell scripts, I constantly found that piping an array to some command would almost always make that command to be invoked once for every item in array, instead of being invoked once and given the whole array as a single input. Sometimes it's the latter that you need, so the workaround is to make a new,…

Got it, that makes sense based on the link.

In Raku, the equivalent would be:

   my @a = [1,2],;
The connection to junctions is still not very clear to me, however. A junction doesn’t really have any correlation to a single element version of a list. As a super-position of potential values, it doesn’t have many correlaries in other languages.

For example, part of the original concept of junctions involved parallel evaluation of junction elements in an expression but that turned out to be less useful than hoped for in practice.

Re: Unusual Raku Features

#134
post #70

Earlier quoted context omitted.

Oh I’m not wealth motivated at all . My regrets are about uselessness of that time itself. E.g. I could learn ML instead and do nothing useful with it, rather than not doing nothing useful with my perl knowledge today.

This is so self-contradicting, it feels like division by zero

I could enjoy one knowledge today without having monetary interest in it ever, but instead I have another knowledge which is completely useless even for enjoyment.

Re: Unusual Raku Features

#135

Earlier quoted context omitted.

That's a fair reaction to the post if you haven't looked at any normal Raku code. If you look at any of the introductory Raku books, it seems a LOT like Python with a C-like syntax. By that I mean the syntax is more curly-brace oriented, but the ease of use and built-in data structures and OO features are all very high level stuff. I think if you know any other high level scripting language that you would find Raku p…

Sure, but the fact that weird stuff is possible means that someone, at some point, will try to use it in your codebase. This might be prevented if you have a strong code review culture, but if the lead dev in the project wants to use something unusual, chances are no one will stop them. And once you start...

If you suggest a language here where nothing weird can be done, I bet someone will reply with something weird done in that language.

Re: Unusual Raku Features

#136

Earlier quoted context omitted.

Sure, but the fact that weird stuff is possible means that someone, at some point, will try to use it in your codebase. This might be prevented if you have a strong code review culture, but if the lead dev in the project wants to use something unusual, chances are no one will stop them. And once you start...

If you suggest a language here where nothing weird can be done, I bet someone will reply with something weird done in that language.

This is true. I’ve written overly-clever, indecipherably dense code in many different languages. But some languages seem to practically encourage that kind of thing. Compare a random sampling of code from APL, Scala, Haskell, Perl, Clojure, C, and Go. You’ll probably find that average inscrutability varies widely between various language pairs.

Re: Unusual Raku Features

#137

Earlier quoted context omitted.

> I’m not sure that I see the connection that you are making here. Can you elaborate? Back when I had to write PowerShell scripts, I constantly found that piping an array to some command would almost always make that command to be invoked once for every item in array, instead of being invoked once and given the whole array as a single input. Sometimes it's the latter that you need, so the workaround is to make a new,…

Got it, that makes sense based on the link. In Raku, the equivalent would be: my @a = [1,2],; The connection to junctions is still not very clear to me, however. A junction doesn’t really have any correlation to a single element version of a list. As a super-position of potential values, it doesn’t have many correlaries in other languages. For example, part of the original concept of junctions involved parallel evalu…

An array in Powershell, when piped to a command, automatically get this command invoked for each of the array's element and the results are combined into a new output array, which can be piped further.

A junction in Raku, when given as an argument to a function, automatically applies this function to each of the junction's element and the results are combined into a new junction as a result.

I don't know, seems like a pretty clear parallel to me. And since the Powershell's behaviour is quite often undesirable, I agreed with the original commenter that perhaps the junctions could also be somewhat annoying to use instead of just working normal lists: after all, "s in ('this', 'that', 'other')" is about just as clear as "$string ~~ “this”|”that”|”other”" but doesn't require support for magical self-destructuring containers in the language.

Re: Unusual Raku Features

#139
post #44

Wow. Sign me up for leaving the industry before I ever have to maintain a Raku codebase.

Same as Perl, nobody wants to maintain it, but it's extremely fun to write. It has a lot of expression. You can see that in Raku's ability to define keyword arguments with a shorthand (e.g. :global(:$g)' as well as assuming a value of 'True', so you can just call match(/foo/, :g) to get a global regex match). Perl has tons of this stuff too, all aimed at making the language quicker and more fun to write, but less rea…

Perl reminds me of that job I had writing ANSI MUMPS.

Re: Unusual Raku Features

#140
post #25

I use Raku in production. It's the best language to deal with text because building parsers so so damn nice. I'm shocked this isn't the top language to create an LLM text pipeline.

Very late to the thread, but I was wondering if you knew of a good example of Raku calling an API over https, polling the API until it returns a specific value?
Post reply on HN