Live data from Hacker News

Raku: A language for gremlins

buttondown.email

51–60 of 257 posts

Re: Raku: A language for gremlins

#51

My favorite feature of Raku: Integer division and decimal literals both return `Rat`, a rational fraction type. Even though everyone knows floats suck, nobody is actually moving away from them except Raku. If you want a float literal you specifically have to use scientific notation.

There are older languages just waiting for the people who dislike IEEE 754 floats to notice them too, like Common Lisp and Scheme. They have a numeric tower which includes both rational and complex rational numbers:

    > (+ 5/3 4/5)
    37/15
    > (expt #C(0 1) 2)
    -1
    > (expt #C(3/2 1/2) 2)
    #C(2 3/2)
And of course they all support arbitrary precision numbers as well:

    > (complex (fact 10) (fact 20))
    #C(3628800 2432902008176640000)
    > (/ (complex (fact 10) (fact 20)) 29)
    #C(3628800/29 2432902008176640000/29)
Composition is a wonderful thing.

Re: Raku: A language for gremlins

#52

Earlier quoted context omitted.

FTA: "The regex syntax isn't backwards compatible with Perl 5. For thirty years languages followed the PCRE "standard" and Perl 6 just… threw it all away." so it looks like the author has at least passing familiarity.

Which also gives away some gaps in the author's knowledge. Perl wasn't following the PCRE standard. It was the PCRE standard. Everything else was following it. Usually with some piece missing--far more implementations should have the /x modifier. The Perl 6 design process didn't throw it away after 30 years. It threw it away with less than 10 years. There was already widespread knowledge that Perl had gone beyond "re…

Technically Perl 5 is parsable using Perl 5 regexes: https://www.youtube.com/watch?v=e1T7WbKox6s

But it is also true that Raku’s grammars were designed from the start to write real parsers in, whereas Perl 5’s regexes sort of gradually got that way.

Re: Raku: A language for gremlins

#53

Raku is interesting as a language indeed. I can't get over some of the idioms, they just don't map nicely in my head. The same reason AppleScript struck me as weird, it trys to use natural language on one hand (e.g. `my`, `say`, `sub`, `gather`) with some oddities like `@` being used for (assuming?) scoped iterations or declaring modules[0] and some other from-an-outsider byzantine syntax decisions. For instance, I c…

I actually feel the same about bash

Re: Raku: A language for gremlins

#54
post #30

Let's face it, the Perl 5/PCRE regex syntax is atrocious. The only reason it exists is that (? was a syntax error in earlier regex syntaxes, so it could be redefined to mean anything. Raku is an attempt to design a sane regular expression language from first principles, now that we know what we want them to be able to express. The alternative is being stuck with (?:this|(?>or that)) for the next 30 years.

>Let's face it, the Perl 5/PCRE regex syntax is atrocious.

Agreed, but god-damn is it useful.

Re: Raku: A language for gremlins

#56
> Raku has no qualms about using Unicode operators. You check set membership with ∈. There's also ∉, ∋, and ∌.

Something to note is that there are ASCII equivalents[0] for every cool Unicode operator found in Raku. For example, the equivalents for ∈, ∉, ∋, ∌ are (elem), !(elem), (cont), !(cont).

[0] https://docs.raku.org/language/unicode_ascii#Other_acceptabl...

Re: Raku: A language for gremlins

#57
post #6

When I was looking at the language, I didn't find the documentation "really poor". In fact I was impressed at how much of a one-stop-shop the official docs site was for both conceptual docs and API docs. https://docs.raku.org/ Look at the following page as a jumping off point for conceptual stuff. Absolutely top class: https://docs.raku.org/language

The Perl man pages were always excellent.

Re: Raku: A language for gremlins

#58
post #45

Earlier quoted context omitted.

I found about raku one time I had an assignment for college where I needed to create a parser. I found raku's grammar features really interesting and used it for my project, it felt almost like cheating since it did pretty much every thing for me (actually it was probably just cheating but it was still fun).

That’s exactly what you want in a language. It should always feel like cheating! Also debuggers. Give RR a try some time :)

I imagine you are referring to https://rr-project.org/ ?

Had never heard of it, looks pretty amazing, I might actually enjoy debugging now!

Re: Raku: A language for gremlins

#59
post #30

Let's face it, the Perl 5/PCRE regex syntax is atrocious. The only reason it exists is that (? was a syntax error in earlier regex syntaxes, so it could be redefined to mean anything. Raku is an attempt to design a sane regular expression language from first principles, now that we know what we want them to be able to express. The alternative is being stuck with (?:this|(?>or that)) for the next 30 years.

Awful? It is inscrutable black magic and it is wonderful once you get it.

I haven't touched perl in years but I still find myself writing regex often!

Re: Raku: A language for gremlins

#60

My favorite feature of Raku: Integer division and decimal literals both return `Rat`, a rational fraction type. Even though everyone knows floats suck, nobody is actually moving away from them except Raku. If you want a float literal you specifically have to use scientific notation.

I'm not sure what I think about that. I know when to use decimal/rational types vs floats, but my own Python code has a whole lot more float() calls than Decimal()s. Floats are almost always what I want unless I'm directly working with money.

Are they almost always what you want? Like, what kind of code do you work on? I personally find, that I need floats quite rarely and rationals usually are just fine, when I write Scheme. And when I write Python, floats also don't come up that often, except for in places where I would rather like to have exact numbers than inexact ones, always making me doubt, whether what I calculate here might have too big error in it.
Post reply on HN