The Raku Programming Language
-
@Gąska said in The Raku Programming Language:
And you wonder why Perl 5 folks want to forget about its existence.
Which I had done, until this this thread. Thanks, @pie_flavor.
-
@pie_flavor said in The Raku Programming Language:
For the life of me I cannot goddamn figure out under what circumstances you would ever
do thisget within a hundred miles of Raku.FTFSanity
-
@topspin said in The Raku Programming Language:
You study crazy (human) languages, apparently you design them too.
Could be worse; could be Logjam.
-
@dfdub said in The Raku Programming Language:
There's no way to implement this insane behavior in a sane way.
That's the correct response to all things Perl.
-
@dfdub said in The Raku Programming Language:
@Gąska said in The Raku Programming Language:
@pie_flavor said in The Raku Programming Language:
「a9」++
gives「b0」
.Wait what? Does it mean
"image9"++
gives"imagf0"
? That's way more retarded than I initially thought.It's your fault for not adding enough leading zeroes! Obviously, you should have written
"image09"
if you wanted to support more than 9 images.Or as @Watson just noted above, use a
-
. Yea for consistency.
-
@Carnage said in The Raku Programming Language:
What the fuck, the language.
Are its authors regulars here?
-
@pie_flavor said in The Raku Programming Language:
@pie_flavor said in The Raku Programming Language:
»
Mind you, this works on all the operators.
!« @list-of-bools
,@list-of-ints»++
,@l1 »+» @l2
.Does the last one do an inner “product“, outer product, or element-wise?
I.e. (I have no idea how the syntax works, just go with what I obviously mean) if you got[2,3] »+» [5, 7]
does it produce either of the following:
17
[[7, 9], [8, 10]]
[7, 10]For bonus points, see if you can guess what the difference is between
»+»
,«+«
,«+»
, and»+«
.I’m completely fucking lost. They probably produce either of the outputs above, with one being redundant.
-
@pie_flavor said in The Raku Programming Language:
For the life of me I cannot goddamn figure out under what circumstances you would ever do this.
It builds the method implementation list for a method call. For a largely static language like C++ that's a trivial thing, but if Raku allows class hierarchy modification or reclassing an object then determining the MRO is something that it's useful to have direct language support for. But having it as an operator is utter lunacy; operators should be for things that user code is likely to actually use…
-
@Gąska said in The Raku Programming Language:
Strongly disagree. It doesn't do what people expect. People expect it to not compile because it's fucking dumb to have
++
for a string.No, that’s what programmers expect, who are a subset of people, distinguished from the rest mainly by a certain mindset.
If you ask the average computer user what file comes after
image1.txt
, there’s a good chance they’ll replyimage2.txt
because there’s a number in it, and “next” to most people then automatically means, “increment the number by 1”.What it does is make a very very specific use case that's already very easy even easier, but in a way that makes the code undecipherable.
All code is undecipherable unless you know how to read it. This just goes against what you know from other languages, and so is likely to cause you problems. To someone used to Raku, I doubt it will.
Literally all you gain is being able to write:
$s++;
instead of
$i++; $s = "image$i.txt";
Is this tiny benefit really worth the s?
What if you don’t have the variable to begin with, like if the name results from the user picking a file? You then need to disassemble the filename yourself, figuring out where the number is, getting that out, incrementing it, and then putting it back together with the new value. (Which must be what’s going on behind the scenes in Raku, of course.)
-
@Gąska said in The Raku Programming Language:
@pie_flavor said in The Raku Programming Language:
「a9」++
gives「b0」
.Wait what? Does it mean
"image9"++
gives"imagf0"
? That's way more retarded than I initially thought.That is stupid, and I would guess programmer-oriented again, yes. I think it sees
e9
as a hex number and so increments it tof0
. I wonder what"imagf0"++
produces.imagf1
, probably. So keep going, and atimagf9
, do we then getimagf10
next?
-
@Gurth This reminds me of
man date
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers.
-
@Gurth said in The Raku Programming Language:
@Gąska said in The Raku Programming Language:
Strongly disagree. It doesn't do what people expect. People expect it to not compile because it's fucking dumb to have
++
for a string.No, that’s what programmers expect, who are a subset of people, distinguished from the rest mainly by a certain mindset.
Maybe you'd have a point, before we discovered with the help of @pie_flavor that
"image9.txt"++
is"imagf0.txt"
. I dare you find even one non-programmer for whom it'd make sense.What it does is make a very very specific use case that's already very easy even easier, but in a way that makes the code undecipherable.
All code is undecipherable unless you know how to read it. This just goes against what you know from other languages, and so is likely to cause you problems. To someone used to Raku, I doubt it will.
There's this thing called cognitive load. There's only so much knowledge you can keep in your recent memory, and the more you need for a task at hand, the more tiring it becomes. There's a reason why many veteran C++ programmers with over a decade of on-the-job C++ experience still hate C++. And it's related to C++ language spec spanning 900 pages, excluding standard library.
Literally all you gain is being able to write:
$s++;
instead of
$i++; $s = "image$i.txt";
Is this tiny benefit really worth the s?
What if you don’t have the variable to begin with, like if the name results from the user picking a file?
Then you don't know what the result of
++
will be because you don't even know where the number is located in the filename, or even if there is a number at all. And you better fucking not call++
on it if you don't know what the result will be.
-
@Gurth said in The Raku Programming Language:
I think it sees
e9
as a hex number and so increments it tof0
.@Watson showed that
z
gets incremented toaa
. It has nothing to do wtih hex numbers and everything to do with Raku being fucking retarded.
-
@Carnage said in The Raku Programming Language:
Raku seems to have taken all the worst bits of perl, dialled it up to 11 and slathered
LSDAPL all over it.
-
-
-
@Mason_Wheeler found it already by googling "APL language".
The Address programming language (Russian: Адресный язык программирования Ukrainian: Адресна мова програмування) is one of the world's first high-level programming languages.[1] It was created in 1955 by Kateryna Yushchenko.[2] In particular, the Address programming language made possible indirect addressing and addresses of the highest rank – analogous to pointers.
Edit: oh wait.
-
@Gąska Not that one. Wow! There's another programming language that goes by the same initials?
I'm talking about the one that actually makes the joke work, in the context of all the wacky Unicode symbols.
-
@Mason_Wheeler I think адресный язык программирования is sufficiently Unicode
-
-
Regex time! This one's less stupid than the others, but still weird enough to be interesting.
Since Perl made regexes barely functional, every other language under the sun has implemented some regex basically identical to Perl's. Raku takes this as a sign that it should implement regexes the way nobody has ever implemented them before, or would want to. In standard style, you define them/regex-thing/
,regex $varname { regex-thing }
, orrx⦕ regex thing ⦖
, the latter being the 'use any delimiters you want' style. The latter is also how you enable other options with adverbs, for example if you were to sayrx:s﹃regex thing﹄
, then whitespace would be significant. That's right, whitespace is no longer significant. They are no longer like a collection of single character matchers, but instead like a set of parsing steps.Following in time-honored Perl tradition, there are several syntax for destructively and non-destructively matching regexes against
$_
, and regex match results are stored in$/
. A quoted phrase matches as a literal, as does an unquoted series of non-metacharacters. Unless the quoted phrase has braces, in which case the thing in the braces is evaled; e.g./ "1 + 1 = {1+1}" /;
matches"1 + 1 = 2"
. It's got all the standard character classes, and escapes like\n
, with a brand new escape too:\c[CYRILLIC CAPITAL LETTER LJE]
. Just stick the full Unicode name there to insert it. Come to think of it, that's actually far more readable than the traditional option.In addition to the newest Perl 5 matchers like 'word boundary', it includes some new utility ones too, like 'within word', which matches anything not outside of word boundaries. You can also match against Unicode properties, for example
/ <:Script<Latin>> /
or/ <:Block(「Basic Latin」)> /
. With, of course, short forms too, for example/ <:Lu> /
for uppercase letter, and union, difference, and negation operators, for example/ <:S-:Sc> /
for all symbols that are not currency symbols. Then you've got the traditional square bracketed character matchers, except just to be Different™ instead of-
the range operator is..
, and negation is done with-[ chars ]
instead of[^ chars ]
. Syntax for arbitrary quantifiers has changed, too; instead of{M,N}
it's** {M..N}
, or** M..N
for short if M and N are literals, rather than complex interpolated expressions.%
matches delimiters, e.g./ a+ % ',' /
matchesa
,a,a
,a,a,a
, etc., and %% will match a trailing delimiter too.|
has been changed to||
, for no reason at all, with|
now matching the most specific option instead of the first option. You can also interpolate arrays in, to act like|
, i.e./ @array-name /
.&&
does what you'd expect given||
.^^
matches the start of a line like^
matches the start of a string, and the same goes for$$
, and«
and»
match the start and end of a word.Halfway through!
-
@pie_flavor Lookarounds changed syntax for no reason; they are now
<!>
and<?>
. These things are pretty fuckin' slow because for the first time an implementation other than .NET is supporting variable-length lookaround, i.e. no arbitrary limitations. In order to preserve any semblance of performance, you have to use:
in the appropriate spot in your regex to say that once it's passed this point, it can't go back any further. Grouping's unchanged, but in replacement strings,$0
can be written$/[0]
. Mostly because replacement strings are global, and that's really a variable named $0, and a list named $/. But for non-capturing-yet-grouping behavior, you use[]
. Hang on, aren't those the things used for character list matchers? Well, yes! How can you make sure it's not interpreted as one of those? I've got no clue, because the docs don't say.As for $0 itself, well, Raku abandons simple notions like 'capture indices are left to right' and revamps it to be more confusing. If you use
||
, then each side will share the same index, so in/ [ (\w) || (\d) ] (\s) /
, the\s
will be named$1
, not$2
, and if you've got/ ( (\w) (\w) ) /
, then$0
is an array of two elements. Unlike in Perl, you can't use the captures within the regex; in order to be able to, you have to, and I am not joking in the least, put a line of code in the regex. To match two identical digits, you say/(\d) {} :my $c = $0; ($c)/
. (The{}
forces the captures to be available in code scope; in reality, any code could go in that block.) Even though()
remains unchanged, instead of going with the traditional named capture syntax(?<name> expression)
, it is different for no reason:$<name> = expression
. Instead of\K
to disregard captures before that point, you surround the capture area with<( )>
.Substitution is done with the time-honored syntax
s/expression/replacement/
, except instead of always operating on$_
you can force it on a variable with$s ~~ s/thing/otherthing/
. Remember when I said that~~
was the more-or-less-equality operator? That's the last thing you'd expect to have side effects, no? Fun! But, of course, being Raku, you can also change those delimiters to anything you can think of, ands🎶paula🎶brillant🎶
just gets the point across so much more, no? And of course there is alternate syntax for balanced groups, so you can writes⧼true || false⧽ = 'file not found'
, which doesn't allow you to operate on anything other than$_
anymore. To make it non-destructive for~~
, you can useS
instead ofs
, and instead of suffixing withg
ori
, you use them as adverbs,"banana" ~~ s:g/na/nanana/
.Regexes can be interpolated; you can use variables or code-blocks, and they can be interpreted as strings or regexes. Half the fun here is in adverbs.
:i
makes the whole thing case insensitive.:m
, in a rare beacon of usefulness, matches the accented forms of an unaccented letter.:P5
throws the whole thing out the window and uses PCRE.:ii
is not only case insensitive in matching but attempts to replicate the case in replacements, and:mm
, in a rare beacon of total uselessness, does the same for accents. There's a few more, but one final note:~
is a regex character used to balance left and right delimiters, and with it, Raku regexes are finally capable of parsing HTML properly.
-
@Gąska said in The Raku Programming Language:
So what I'd expected to happen, and not all that terrible. Yes, it's very verbose, yes, you won't use it in 99.99% of cases, but the reason people pick C++ over other languages is exactly because you can do that 0.01% that you cannot do in other languages.
You can still use escaping to type any string literal on simpler languages, so that is still ridiculous
-
@sockpuppet7 but you can't have escape sequences and literal quotes/newlines/backslashes at once. Semi-arbitrary delimiters allow you to have all the benefits of literal strings without the downside of not being able to write that one specific character sequence.
-
Time until someone writes a Perl Compatible regular expression library for Raku 3... 2... 1...
-
@marczellm said in The Raku Programming Language:
Time until someone writes a Perl Compatible regular expression library for Raku 3... 2... 1...
You must have missed it in the text-wall.
@pie_flavor said in The Raku Programming Language:
:P5
throws the whole thing out the window and uses PCRE.
-
@pie_flavor said in The Raku Programming Language:
@pie_flavor Lookarounds changed syntax for no reason; they are now
<!>
and<?>
. These things are pretty fuckin' slowEven less powerful regex libraries usually are. Doesn't the man page say something like "grep uses a fast algorithm that sometimes takes exponential time"?
Also I think there was a BLubar thread about regex DDOSing.because for the first time an implementation other than .NET is supporting variable-length lookaround, i.e. no arbitrary limitations. In order to preserve any semblance of performance, you have to use
:
in the appropriate spot in your regex to say that once it's passed this point, it can't go back any further.Is that like Prolog's cut?
-
@topspin I have no idea, I've never used Prolog. The r is short for ratchet.
-
@pie_flavor
I actually like the new regular expression syntax you're describing. It sounds like they tried to learn from the problems with the old syntax. Insignificant whitespace improves readability and some of the backwards-incompatible changes you're criticizing seem to be designed to make backslash escapes for special characters mostly unnecessary. Looks like a step in the right direction.
-
@dfdub Did you miss this line
/(\d) {} :my $c = $0; ($c)/
?
-
@topspin I haven't read that far yet. That's why I replied to the first post.
Edit: Now that I've read everything, I can say that it went downhill after the reasonable changes to the basic syntax.
-
Dang. I remember messing around with this back when they were calling it parrot. I was feeding it bytecode and looking to port something else to it. Didn't work out, but I'm glad that these guys persisted and made something more perl than perl.
-
@pie_flavor said in The Raku Programming Language:
Cool
is the superclass of any typeCould have been worse.
They could have called it .
-
@pie_flavor said in The Raku Programming Language:
regex
-
@Mason_Wheeler said in The Raku Programming Language:
@pie_flavor said in The Raku Programming Language:
regex
Right, you'd definitely want a more robust system for proper parsing. Like a grammar language.
Good thing Raku has those built directly into the language, à la ANTLR.grammar G { rule TOP { <function-define> } rule function-define { 'sub' <identifier> { say "func " ~ $<identifier>.made; make $<identifier>.made; } '(' <parameter> ')' '{' '}' { say "end " ~ $/.made; } } token identifier { \w+ { make ~$/; } } token parameter { \w+ { say "param " ~ $/; } } } G.parse('sub f ( a ) { }'); # OUTPUT: «func fparam aend f»
The compiler itself is dogfooded with this.
-
@Gurth said in The Raku Programming Language:
So keep going, and at
imagf9
, do we then getimagf10
next?That would be surprising given known behaviour. Expect
imagg0
instead. Because who wanted that?
-
@Rhywden said in The Raku Programming Language:
@Gąska It being Perl explains its potential for its code being undistinguishable from line noise.
I wonder how many of the younger members of the audience have ever seen the results of line noise.
-
@dfdub said in The Raku Programming Language:
Insignificant whitespace improves readability
The extended syntax of PCRE is good like that too, and supports comments. For a complicated RE, that's invaluable. Mind you, I've found that the best approach with an RE is generally to make it strictly as simple as possible; the more complexity you put in there, the more fragile things get.
-
@dkf said in The Raku Programming Language:
The extended syntax of PCRE is good like that too, and supports comments.
Do you have a link to documentation of the syntax you mean?
If you're working in a language with good string interpolation capabilities, you can and should also use that to make regular expressions more readable.
-
@dkf said in The Raku Programming Language:
@Gurth said in The Raku Programming Language:
So keep going, and at
imagf9
, do we then getimagf10
next?That would be surprising given known behaviour. Expect
imagg0
instead. Because who wanted that?Who knows, you might get
imag100
because raisins.
-
@Steve_The_Cynic said in The Raku Programming Language:
@Rhywden said in The Raku Programming Language:
@Gąska It being Perl explains its potential for its code being undistinguishable from line noise.
I wonder how many of the younger members of the audience have ever seen the results of line noise.
-
@pie_flavor said in The Raku Programming Language:
You must have missed it in the text-wall.
Yes. Initiating countdown until someone also misses that flag and writes another PCRE library for Raku.
@pie_flavor said in The Raku Programming Language:
Right, you'd definitely want a more robust system for proper parsing. Like a grammar language.
Good thing Raku has those built directly into the language, à la ANTLR.That actually looks useful. Does it have parser combinators?
-
@dfdub said in The Raku Programming Language:
Do you have a link to documentation of the syntax you mean?
The PCRE2_EXTENDED option, denoted in regexes by a '
/x
modifier.If you're working in a language with good string interpolation capabilities, you can and should also use that to make regular expressions more readable.
PCRE has subroutines!
https://www.pcre.org/current/doc/html/pcre2pattern.html (see "Defining capture groups for use by reference only ")
-
@Steve_The_Cynic said in The Raku Programming Language:
@Rhywden said in The Raku Programming Language:
@Gąska It being Perl explains its potential for its code being undistinguishable from line noise.
I wonder how many of the younger members of the audience have ever seen the results of line noise.
Other than incredibly long PCREs embedded in other languages, I've never seen any Perl myself.
-
@dfdub said in The Raku Programming Language:
Do you have a link to documentation of the syntax you mean?
The flag and the syntax. Example:
(?x) # Turn on this mode of RE matching (PCRE_EXTENDED) ABC # A prefix ( D .? )* # A repeated non-trivial bit in the middle EF # A suffix
This is a flag that I like to put internally precisely because it so strongly affects the interpretation of the rest of the RE.
-
@Gąska said in The Raku Programming Language:
@Steve_The_Cynic said in The Raku Programming Language:
@Rhywden said in The Raku Programming Language:
@Gąska It being Perl explains its potential for its code being undistinguishable from line noise.
I wonder how many of the younger members of the audience have ever seen the results of line noise.
Other than incredibly long PCREs embedded in other languages, I've never seen any Perl myself.
To try and remedy that, you should give making a non-trivial webpage with http://www.lunpacms.org/ or something simiular perly. Keep a large container of alcohol nearby.
-
@Carnage said in The Raku Programming Language:
@Gąska said in The Raku Programming Language:
@Steve_The_Cynic said in The Raku Programming Language:
@Rhywden said in The Raku Programming Language:
@Gąska It being Perl explains its potential for its code being undistinguishable from line noise.
I wonder how many of the younger members of the audience have ever seen the results of line noise.
Other than incredibly long PCREs embedded in other languages, I've never seen any Perl myself.
To try and remedy that
-
@Watson said in The Raku Programming Language:
The PCRE2_EXTENDED option, denoted in regexes by a '/x modifier.
Thanks. And holy cow, that page is unreadable unless you know what to grep for.
-
-
@topspin said in The Raku Programming Language:
@Steve_The_Cynic said in The Raku Programming Language:
@Rhywden said in The Raku Programming Language:
@Gąska It being Perl explains its potential for its code being undistinguishable from line noise.
I wonder how many of the younger members of the audience have ever seen the results of line noise.
Fair dooze, but I was thinking of actual line noise, like you'd see with a 300 baud modem talking over a noisy phone line. (Worse still, a 300 baud modem using an acoustic coupler.)
Or maybe I'm showing my age again.