Live data from Hacker News

Unusual Raku Features

buttondown.com

121–130 of 166 posts

Re: Unusual Raku Features

#121

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

PowerShell does something similar with their pipelines, see e.g. the answer [0] and the question it answers. Something similar happens in Bash: $x refers not to the string $x, but to the list of the strings that you get by splitting the original string by IFS. And yes, this feature is annoying and arguably is a mis-feature: containers shall not explode when you touch them. [0] https://stackoverflow.com/a/56977142

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 common one that I tend to see in practice.

Re: Unusual Raku Features

#122

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

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...

Re: Unusual Raku Features

#123

Earlier quoted context omitted.

I dream of a day where one can post a Raku article on HNN and not encounter a comments section full of digressions into discussing Perl. There is some sense to it by means of comparison, but the constant conflation of the two becomes tiresome. But in that spirit, let's compare: The =()= "operator" is really a combination of Perl syntax[^1] that achieves the goal of converting list context to scalar context. This isn'…

> digressions into discussing Perl Changing the name to Raku doesn't obliterate Perl 6's history as Larry Wall's successor to Perl 5. I don't know why you would expect people to pretend that they're unrelated. They aren't.

> Changing the name to Raku doesn't obliterate Perl 6's history as Larry Wall's successor to Perl 5.

Further than that, the name change only happened after it already had at least one official release under the "Perl 6" name.

Re: Unusual Raku Features

#125
post #123

Earlier quoted context omitted.

> digressions into discussing Perl Changing the name to Raku doesn't obliterate Perl 6's history as Larry Wall's successor to Perl 5. I don't know why you would expect people to pretend that they're unrelated. They aren't.

> Changing the name to Raku doesn't obliterate Perl 6's history as Larry Wall's successor to Perl 5. Further than that, the name change only happened after it already had at least one official release under the "Perl 6" name.

It was just as annoying to constantly be pulled into discussions about Perl 5 in threads about Perl 6 back then too.

Re: Unusual Raku Features

#126

Earlier quoted context omitted.

> I imagine this could be understood as making use of a monad. Right? Can you clarify what do you mean? Do expect the concept of "monad" to help explaining Raku grammars?

Yes. Compare it to the List monad or Parsec.

- There is a natural from-to conversion of Functional Parsers (FP) monad (as in Parsec) to Extended Backus-Naur Form (EBNF).

- Similarly, EBNF can be applied to Raku grammars.

- Hence, the representation of Raku grammars into FP monad is doable, at least for certain large enough set of Raku grammars.

  - See the package "FunctionalParsers".

Re: Unusual Raku Features

#127

Earlier quoted context omitted.

PowerShell does something similar with their pipelines, see e.g. the answer [0] and the question it answers. Something similar happens in Bash: $x refers not to the string $x, but to the list of the strings that you get by splitting the original string by IFS. And yes, this feature is annoying and arguably is a mis-feature: containers shall not explode when you touch them. [0] https://stackoverflow.com/a/56977142

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, single-element array with the original array as its only element, and pipe this into the command.

Re: Unusual Raku Features

#128

Earlier quoted context omitted.

very cohesive, [7] > (1,3,9...*)[4,5] (81 243) [8] > (1,3,9...*)[(1..3)] (3 9 27) and nestable [0] > (1,2,4...*)[(1,2,4...*)[1,2,3]]

These are all very clever, but what's the use case? I'm not saying there isn't one, I just don't know what it is! Not to speak of the dead, but Perl was utilitarian: it was built to solve problems. From my point of view, these are solutions to problems I've never had.

If you can read Lisp (Scheme) syntax, I think SICP [0] has the clearest demonstration of the utility of lazy streams. The problem it presents (calculating pi) is, admittedly, rather academic; but the concept of having values that evolve over "time" as first-class entities that you can abstract over is practically useful. I think that all of reactive programming (React, Angular, etc) is closely related to this idea (perhaps even originates from it), although the implementation and applications differ.

It's a long and effortful read, but the payoff is worth the effort.

[0] https://mitp-content-server.mit.edu/books/content/sectbyfn/b...

EDIT: I think the Perl article posted in a sibling comment uses essentially the same example (but for calculating e instead of pi), although I only skimmed it.

Re: Unusual Raku Features

#129
post #61

Earlier quoted context omitted.

its not that reading perl is hard, the _intent_ of the operations of often hard/unclear. Yes its nice to write dense fancy code, however, something very boring to write like PHP is a lot of "loop over this bucket and do something with the fish in the bucket, afterwards, take the bucket and throw it into the bucket pile" that mirrors a 'human follows these steps' type.

In the intent department, I have had more troubles with AbstractClassFactorySingletonDispatcher type Java code, add to that dependency injection magic/madness. I'd rather maintain Perl any day than 30 classes of Java code just to build a string.

Good job those aren't the only two options!

Re: Unusual Raku Features

#130
post #45
post #8

Earlier quoted context omitted.

> It is absolutely mindbending to me that all of this language development has happened on top of Perl, of all things. Why "of all things?" The Perl philosophy of TIMTOWTDI, and Wall's interest in human-language constructs and the ways that they could influence programming-language constructs, seem to make its successor an obvious home for experiments like this.

It has the same whimsy and DWIM of perl, look at Promise having a status of 'kept' or 'broken' which is more fun than 'fulfilled' or 'rejected'. Brings to mind Perl 5's use of bless, calling the filter function 'grep' and local/global variables created with 'my' and 'our'.

Don't forget `tainted` (https://perldoc.perl.org/perlsec#Laundering-and-Detecting-Ta...)!
Post reply on HN